项目作者: GiovanniSalmeri

项目描述 :
Animated and responsive charts.
高级语言: PHP
项目地址: git://github.com/GiovanniSalmeri/yellow-chartjs.git
创建时间: 2021-03-14T15:52:38Z
项目社区:https://github.com/GiovanniSalmeri/yellow-chartjs

开源协议:GNU General Public License v2.0

下载


Chartjs 0.9.2

Animated and responsive charts.

Screenshot

How to install an extension

Download ZIP file and copy it into your system/extensions folder. Learn more about extensions.

How to show a chart

Chart.js is a graphic engine that allows to define a chart in JavaScript Object Literal notation. In this extension you must use JSON, which is a stricter subset of JavaScript Object Literal notation.

Insert the data with a code block. Wrap the data in ``` and add the language identifier chartjs.

Add to the options a setting "canvasDimensions": [width, height] and set "responsive": false if you want to assign a fixed dimension to the chart.

Differences between JavaScript Object Literal notation and JSON

Unlike in JavaScript Object Literal notation, in JSON:

  • there are only double quotes "
  • keys must be always quoted
  • comments (// or /* */) are not allowed.

If needed, online services (for example ConvertOnline) transform JavaScript Object Literal notation into JSON.

Examples

Showing a bar chart:

  1. ``` chartjs
  2. {
  3. "type": "bar",
  4. "data": {
  5. "labels": ["Red", "Blue", "Green", "Purple", "Yellow", "Orange"],
  6. "datasets": [{
  7. "label": "# of Votes",
  8. "data": [12, 3, 5, 2, 19, 3],
  9. "backgroundColor": [
  10. "#ff638433",
  11. "#36a2eb33",
  12. "#4bc0c033",
  13. "#9966ff33",
  14. "#ffce5633",
  15. "#ff9f4033"
  16. ],
  17. "borderColor": [
  18. "#ff6384",
  19. "#36a2eb",
  20. "#4bc0c0",
  21. "#9966ff",
  22. "#ffce56",
  23. "#ff9f40"
  24. ],
  25. "borderWidth": 1
  26. }]
  27. },
  28. "options": {
  29. "animation": true,
  30. "scales": {
  31. "y": {
  32. "beginAtZero": true
  33. }
  34. }
  35. }
  36. }
  37. ```

Showing a pie chart:

  1. {
  2. "type": "pie",
  3. "data": {
  4. "labels": ["Red", "Blue", "Green", "Purple", "Yellow", "Orange"],
  5. "datasets": [{
  6. "label": "# of Votes",
  7. "data": [12, 3, 5, 2, 19, 3],
  8. "backgroundColor": [
  9. "#ff6384",
  10. "#36a2eb",
  11. "#4bc0c0",
  12. "#9966ff",
  13. "#ffce56",
  14. "#ff9f40"
  15. ]
  16. }]
  17. },
  18. "options": {
  19. "canvasDimensions": [800, 300],
  20. "responsive": false
  21. }
  22. }

Acknowledgements

This extension includes Chartjs 4.4.4. Thank you for the good work.

Developer

Giovanni Salmeri. Get help.