Extension:Chart/ja
![]() リリースの状態: 安定Category:Stable extensions/ja |
|
---|---|
実装 | タグCategory:Tag extensions/ja |
説明 | Renders charts |
作者 | TODO |
互換性の方針 | master は後方互換性を維持しています。 |
MediaWiki | >= 1.44 |
データベースの変更 | いいえ |
ライセンス | GNU 一般公衆利用許諾書 3.0 以降 |
ダウンロード | Category:Extensions in Wikimedia version control/ja README |
|
|
四半期ごとのダウンロード数 | 26 (Ranked 69th) |
translatewiki.net で翻訳を利用できる場合は、Chart 拡張機能の翻訳にご協力ください | |
問題点 | 未解決のタスク · バグを報告 |
The Chart extension provides basic interactive data visualization capabilities designed to replace the Graph extension, and possibly also the EasyTimeline extension. This extension is currently in development for Wikimedia wikis. See Extension:Chart/プロジェクト for more details on the development process.
This extension supports the following chart types:
- Line chart
- Area chart
- Bar chart
- Pie chart
インストール
The Chart extension requires having the JsonConfig extension installed, as well as downloading the Chart Renderer JavaScript (actually TypeScript) library.
See the README.md file in the repository for the full setup instructions.
For Wikimedia production usage, see Wikitech:Kubernetes/Deployments for general instructions on service deployments.
使い方
To render a chart, you must define a chart definition to associate with the data source you want to render. A chart definition is structured as a relatively simple JSON file; see Extension:Chart/Specification for the syntax details.
All the charts in this example can be rendered from the same data source: Data:Chart_Example_Data.tab, a fictional dataset. Sample contents for these pages can be found in the sample directory.
{
"license": "CC0-1.0",
"version": 1,
"source": "Chart Example Data.tab",
"type": "line",
"title": {
"en": "Example Chart Title"
},
"xAxis": {
"title": {
"en": "Example X Axis Title"
},
"format": "none"
},
"yAxis": {
"title": {
"en": "Example Y Axis Title"
},
"format": "none"
},
"mediawikiCategories": [
{
"name": "Example category",
"sort": "Its sortkey"
}
],
"transform": {
"module": "Optional lua module for data transforms",
"function": "transform_func",
"args": {
"arg_name": "arg_value"
}
}
}
Once a chart is defined, you can render it easily using the #chart parser function. In this case, the chart data is defined in Data:Chart_Example_Data.tab, and the chart itself is defined in Data:Example.Line.chart:
{{#chart:Example.Line.chart}}
カスタマイズ
Customization of charts is currently limited. The hope is that, after testing, discussion and evaluation, solutions for customization can be found that do not compromise accessibility, device-specific rendering, or security.
サイズ調整
Currently, charts occupy the entire container width where you place them.
The eventual goal is to ensure that charts can be rendered legibly no matter what device they are read on; see T376845 for more details.
テーマの処理
Currently, charts are restricted to a single default color palette. This palette has been carefully designed with accessibility in mind. The thinking behind these color choices can be explored in T369863.
Some charts do require specific color themes, for example, to represent data relating to political parties. It remains an open question of how best to support this type of customization without compromising the ability of readers with accessibility needs (e.g., color blindness) to use them.
留意点
Note, while chart's currently render SVG output which can be styled via TemplateStyles, please note that styling associated SVG elements should not be considered stable as it may change at any time. Please do not rely on CSS to alter chart appearance as this may result in non-functional charts in future or may interfere with accessibility features that change font size and features such as dark mode.
国際化
Charts can only be embedded in the wiki's content language; so, for example, the "uselang" query string (e.g. ?uselang=es
) will not impact the chart.
The chart format supports defining text like title and labels in different languages, so that the same chart can be used in wikis of different languages. See this example of a chart with support for multiple languages being displayed in a Spanish-language wiki.
既知の問題点
グラフの種類
For all charts, data is expected to be arranged in columns, with the first column representing the x-axis
and the following columns representing series on the y-axis
.
折れ線グラフ
棒グラフ
Area
円グラフ
Pie charts are a special chart type, and data sources may require modification to be rendered appropriately.
When reading data, any non-number columns (e.g., the x-axis) will be discarded, and the sum of all rows will be represented on the chart.
For example, where multiple rows depict values for A, B, and C on numerous dates, e.g., January 1st and January 2nd, the pie chart segment for A will represent the sum of all A's row values across those dates.
既存のグラフを検索
Charts that can be used in articles live on Wikimedia Commons and can be tracked using MediaWiki categories.
This query can be used as a proxy to find charts that others have made and contribute translations.
The set of wiki pages that use charts on any particular wiki can be found in the category whose name is defined at MediaWiki:chart-render-category および MediaWiki:Chart-error-category (Category:Pages using the Chart extension および Category:Pages using the Chart extension with rendering errors on this wiki). Please make sure to connect your wiki categories to d:Q131382738 and d:Q131406605 to make the interwiki search easier.
グラフ拡張機能から移行するには
Please see the category pages with disabled graphs in various languages for old graphs that need to be migrated to the Charts extension. Some have however already been deleted without replacing them with new charts. The list can be compared with an archived list of the first 200 out of 23,811 English Wikipedia pages with disabled graphs from 2023, soon after the templates were added to that category, and corresponding in other languages.
技術的な説明文書
Extension:Graph 関連の問題が提示され、新しい拡張機能に代替するなら信頼と自信を築くと期待して、関連する全ての決定事項を慎重に検討しました。
現状では技術面の決定は doc/adr フォルダ内のコードリポジトリに記録してあります。
Error Monitoring
Errors with client side chart rendering will be logged to logstash.
Tools for producing the charts
There are several conceivable methods to semi-automatically produce and edit the charts and their tabular data:
- The script graphDataImport can be used in the web browser to extract data from existing graph wikicode and similar, and convert it to a .tab page, and a .chart definition page.
- Generative AI can be prompted to extract data from existing graph wikicode and tables, and convert it to .tab and .chart pages and generate new wikicode, according to given specifications. It can also provide translation of titles, and be utilized to extend and update the .tab page with new data.
- The gadget TabularImportExport can convert Excel and .csv files to and from the .tab pages. You can activate it via your Commons preferences.
- The JSON "edit as table" user interface (part of the Jsonconfig extension) is available from the .tab edit page.
- Some bots can periodically import statistics from the web, or from existing Wikipedia graphs, to .tab or .chart pages, upon request. Such bots include DPLA bot and SLiuBot.
- GraphBot ports english wikipedia graphs to charts.
See also
![]() | この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |