Modèle:ChartDirect
Apparence
Utilisation
[modifier le code]Le modèle permet d'intégrer un graphique interactif sur Wikipédia.
Le graphique interactif avec l'extension Chart. Il utilize la fonctionalité transform et le module c:Module:Graph:Chart.
Avec standard templates
{{ChartDirect
| type =
| x= | y1= | y1Title=
| y2= | y2Title=
| y3= | y3Title=
| y4= | y4Title=
| y5= | y5Title=
| thumb =
| align =
| width =
| border =
| style =
| caption =
| source =
}}
or Avec autres templates
{{ChartDirect
| chart =
| x= | y1= | y1Title=
| y2= | y2Title=
| y3= | y3Title=
| y4= | y4Title=
| y5= | y5Title=
| thumb =
| align =
| width =
| border =
| style =
| caption =
| source =
}}
or X/Y chart simple (idéal pour pie charts)
{{ChartDirect
| type =
| x= | y=
| thumb =
| align =
| width =
| border =
| style =
| caption =
| source =
}}
Paramètres
[modifier le code]Includes a chart with source attribution and allows adjusting alignment, width, and border.
| Paramètre | Description | Type | État | |
|---|---|---|---|---|
| x | x | Values x-Axis. Note: with pie charts either use only x and y, or use y1-y15 as needed | Ligne de texte | facultatif |
| xTitle | xTitle | Option to show a Title on the X-axis, if the other values are just x and y (no y1-y15) | Ligne de texte | facultatif |
| y | y | Values y-Axis. Note: values y and y1-15 cannot be combined. If y is used, every new entry will be interpreted as one additional data row. Data rows are limited to 15. | Ligne de texte | facultatif |
| yTitle | yTitle | Legend value y-Axis | Ligne de texte | facultatif |
| y1 | y1 | Values first row y-Axis. Further parameters y2-y15 are supported
| Nombre | suggéré |
| y1Title | y1Title | Legend value y-Axis. It is necessary for each y-Axis row (e.g. y1 and y1Title). Additional parameters y2-y15 are supported
| Ligne de texte | suggéré |
| xType | xType | Data format of the x-Axis
| Ligne de texte | facultatif |
| yType | yType | Data format of the x-Axis
| Ligne de texte | facultatif |
| Use of predefined template charts | type | Data:...chart on Wikimedia Commons. Predefined charts based on the selected plot type. If parameter <code>chart</code> or <code>definition</code> is set, this parameter will be ignored.
| Ligne de texte | facultatif |
| swap | swap | Option to transpose an already defined chart (swapping rows/columns). Up to 15 values can be swapped per data row.
| Booléen | facultatif |
| Display as thumbnail | thumb 1 | Set to any value to display in a gray box like an image thumbnail
| Ligne de texte | facultatif |
| Alignment | align 2 | Chart alignment, either "left", "right", or "center"
| Ligne de texte | facultatif |
| Width | width 3 | Width in pixels or percent
| Ligne de texte | facultatif |
| Caption | caption 4 | Caption to display before the source information. Make sure to use ending punctuation.
| Chaîne | facultatif |
| Chart definition | chart definition | Chart on Wikimedia Commons, without the "Data:" prefix
| Ligne de texte | obligatoire |
| Source attribution | source | Option to cite a source
| Ligne de texte | facultatif |
| Border | border | Set to "1" to enable a border
| Booléen | facultatif |
| CSS styles | style | Additional CSS styles (beyond width and border)
| Ligne de texte | facultatif |
| Hide source | hideSource | Set to any value to disable linking to the source
| Booléen | facultatif |
Exemple
[modifier le code]simple bar plot, multiple data rows
[modifier le code]{{ChartDirect
|type=bar
|x=Oranges, Strawberries, Pineapple
|xTitle=Fruit
|y=58,23,77
| align = left
| width = 400px
}}
simple bar plot, one data row only
[modifier le code]{{ChartDirect
|type=bar
|y=58,23,77
|yTitle=amount
| align = left
| width = 400px
}}
full width
[modifier le code]{{ChartDirect
|type=pie
|x=Oranges, Strawberries, Pineapple
|y=58,23,77
}}
other data source and border
[modifier le code]{{ChartDirect
|x=1,5,100
|y1=20,4,80
|y1Title=Oranges
|y2=3,6,9
|y2Title=Bananas
|y3=20,18,15
|y3Title=Apples
|y4=3,25,15
|y4Title=Mangos
|y5=5,5,15
|y5Title=Grapes
| border = 1
}}
thumbnail
[modifier le code]{{ChartDirect
| thumb
|title=Fruit trend
|type=line
|x=1,5,100
|y1=20,4,80
|y1Title=Oranges
|y2=3,6,9
|y2Title=Bananas
|y3=20,18,15
|y3Title=Apples
|y4=3,25,15
|y4Title=Mangos
|y5=5,5,15
|y5Title=Grapes
}}
aligned and fixed width
[modifier le code]{{ChartDirect
| chart = Template line population by year.chart
| align = right
| width = 400px
|x=1980,1990,2000,2010,2020
|y1=98,87,201,252,325
|y1Title=Population
}}
aligned and fixed width thumbnail
[modifier le code]{{ChartDirect
| thumb
| align = left
| width = 400px
| chart = Template line population by year.chart
|x=1980,1990,2000,2010,2020
|y1=98,87,201,252,325
|y1Title=Population
}}
centered, fixed width, border, caption and source
[modifier le code]{{ChartDirect
| chart = Template line population by year.chart
| x=1980,1990,2000,2010,2020
| y1=98,87,201,252,325
| y1Title=Population
| align = center
| width = 400px
| caption = Population of Exampleville
| source = per reference xyz
}}
Population of Exampleville Source: per reference xyz
swap
[modifier le code]Demonstration of the swap parameter effect. Intention: figuring out in an easy way what is the best way to plot rows and columns.
{{ChartDirect
|y1Title=Bregenz|y2Title=Eisenstadt|y3Title=Graz|y4Title=Innsbruck|y5Title=Klagenfurt|y6Title=Linz|y7Title=Salzburg|y8Title=St. Pölten|y9Title=Wien
|x=traffic choice, air quality, bicycle traffic, public transport, parking space, pedestrians, car alternatives, MEAN
|y1=6.25,10,3,5.75,3.75,6.75,3,5.5
|y2=3,9,1.75,1.75,4,7,3.75,4.32
|y3=5.75,3.75,2.5,6.75,4.75,6,4.5,4.86
|y4=7,8.25,4.25,7.25,4.75,4,3.5,5.57
|y5=3.5,8.75,6,5.75,3.25,5,3.5,5.11
|y6=5,4.5,4,6.75,4.25,6.25,3,4.82
|y7=5.5,5.25,3,5,4.5,6,3,4.61
|y8=4.5,9.5,5.25,2.5,3,4.25,3.25,4.61
|y9=7,5,6.5,7.75,7.25,5.5,6.75,6.54
}}
{{ChartDirect
|y1Title=Bregenz|y2Title=Eisenstadt|y3Title=Graz|y4Title=Innsbruck|y5Title=Klagenfurt|y6Title=Linz|y7Title=Salzburg|y8Title=St. Pölten|y9Title=Wien
|x=traffic choice, air quality, bicycle traffic, public transport, parking space, pedestrians, car alternatives, MEAN
|y1=6.25,10,3,5.75,3.75,6.75,3,5.5
|y2=3,9,1.75,1.75,4,7,3.75,4.32
|y3=5.75,3.75,2.5,6.75,4.75,6,4.5,4.86
|y4=7,8.25,4.25,7.25,4.75,4,3.5,5.57
|y5=3.5,8.75,6,5.75,3.25,5,3.5,5.11
|y6=5,4.5,4,6.75,4.25,6.25,3,4.82
|y7=5.5,5.25,3,5,4.5,6,3,4.61
|y8=4.5,9.5,5.25,2.5,3,4.25,3.25,4.61
|y9=7,5,6.5,7.75,7.25,5.5,6.75,6.54
|swap=1
}}
Further information
[modifier le code]Create own templates
[modifier le code]By using the parameter chart an own chart can be selected as template. The advantage is a better adaptability of the chart, especially descriptions of the axes. It is important to include the Transform-section for the commons module.
Transform-Section
[modifier le code]More detailed information can be found in the commons module c:Module:Graph:Chart.
"transform": {
"module": "Graph:Chart",
"function": "main",
"args": {
"x": "1,5",
"y": "10,15"
}
},
"source": "Graph:Chart.tab"
Troubleshooting
[modifier le code]1) error message when generating the plot
- hint: for each data row y1...y15, one corresponding y1Title...y15Title must be defined
2) the x-axis is interpreted as a number
- hint: setting
xTypecan force a different behaviour (usuallyxType=string)
3) the y-axis should be based on zero
- response: unfortunately, this cannot be configured at the moment with the chart extension. See Phab:Task T385344. Area und Line charts are not going to zero. Bar charts are going to zero. Therefore bar charts can be a workaround for this limitation.
4) height of the plot should be configurable
- response: unfortunately, this cannot be configured at the moment with the chart extension. See Phab:Task T376845.
5) the plot shows in different colors, but it should be one color only
- hint: change
ytoy1andyTitletoy1Title
La documentation de ce modèle est générée par le modèle {{Documentation}}.
Elle est incluse depuis sa sous-page de documentation. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (créer) et la page de test (créer).
Voir les statistiques d'utilisation du modèle sur l'outil wstat.