您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

configuration.md 3.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. # Configuration
  2. With all the customizable features of Frappe Charts, this section is dedicated to enabling / disabling existing functionality.
  3. ## Container
  4. The first parameter required by the `Chart` constructor is the container element. You can pass in a CSS Selector or a DOM Object.
  5. ```javascript
  6. const chart = new Chart('#chart', options);
  7. // or
  8. const container = document.querySelector('#chart');
  9. const chart = new Chart(container, options);
  10. ```
  11. ## Options
  12. The second parameter required by the `Chart` constructor is the options object. The minimum required configuration is to pass `data` values, which itself requires an array of `labels` and an array of `datasets`.
  13. ```javascript
  14. const options = {
  15. data: {
  16. labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm"],
  17. datasets: [
  18. {
  19. name: "Some Data", values: [25, 40, 30, 35, 8]
  20. },
  21. {
  22. name: "Another Set", values: [25, 50, -10, 15, 18]
  23. }
  24. ]
  25. }
  26. }
  27. const chart = new Chart(container, options);
  28. ```
  29. ### data
  30. - Type: `Object`
  31. - Required Properties: `labels`, `datasets`
  32. - Optional Properties: `yMarkers`, `yRegions`
  33. Contains an array of `labels` and an array of `datasets`, each a value for the 2-dimensional data points.
  34. May also have [annotation]() parameters, for example those for `yMarkers` and `yRegions`. This is because all properties defined inside data are meant to be animatable.
  35. ```javascript
  36. data: {
  37. labels: ["12am-3am", "3am-6am", "6am-9am", "9am-12pm", "12pm-3pm"],
  38. datasets: [
  39. { name: "Some Data", values: [25, 40, 30, 35, 8] },
  40. { name: "Another Set", values: [25, 50, -10, 15, 18] }
  41. ],
  42. yMarkers: [{ label: "Marker", value: 70 }],
  43. yRegions: [{ label: "Region", start: -10, end: 50 }]
  44. }
  45. ```
  46. Other configurable options are listed as follows:
  47. ### title
  48. - Type: `String`
  49. - Default: `''`
  50. Add a title to the Chart.
  51. ---
  52. ### type
  53. - Type: `String`
  54. - Values: `line | bar | axis-mixed | pie | percentage | heatmap`
  55. - Default: `line`
  56. Let the chart know what type to render.
  57. #### type: 'axis-mixed'
  58. Mixed axis chart. For this to work, you must pass the `chartType` value for each dataset.
  59. ```javascript
  60. const data = {
  61. labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  62. datasets: [
  63. {
  64. name: "Some Data",
  65. values: [18, 40, 30, 35, 8, 52, 17],
  66. chartType: 'bar'
  67. },
  68. {
  69. name: "Yet Another",
  70. values: [15, 20, -3, -15, 58, 12, -17],
  71. chartType: 'line'
  72. }
  73. ]
  74. }
  75. const chart = new Chart('#chart', {
  76. data: data
  77. });
  78. ```
  79. ---
  80. ### colors
  81. - Type: `Array`
  82. - Default: `['light-blue', 'blue', 'violet', 'red', 'orange',
  83. 'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey']`
  84. Set the colors to be used for each individual unit type, depending on the chart type.
  85. ---
  86. ### height
  87. - Type: `Number`
  88. - Default: `240`
  89. Set the height of the chart in pixels.
  90. ---
  91. ### axisOptions
  92. - Type: `Object`
  93. - Default: `{}`
  94. #### xAxisMode and yAxisMode
  95. - Type: `String`
  96. - Values: `span | tick`
  97. - Default: `span`
  98. Foo
  99. #### xIsSeries
  100. - Type: `Boolean`
  101. - Default: `0`
  102. Foo
  103. ---
  104. ### TooltipOptions
  105. - Type: `Object`
  106. - Default: `{}`
  107. ####
  108. ---
  109. ### barOptions
  110. - Type: `Object`
  111. - Default: `{}`
  112. This option controls how width of each `column` is calculated in the chart.
  113. #### spaceRatio
  114. - Type: `Number`
  115. - Min: `0`
  116. - Max: `2`
  117. - Default: `0.5`
  118. #### stacked
  119. - Type: `Boolean`
  120. - Default: `0`
  121. ---
  122. ### lineOptions
  123. - Type: `Object`
  124. - Default: `{}`
  125. Foo
  126. ---
  127. ### isNavigable
  128. - Type: `Boolean`
  129. - Default: `0`
  130. Foo
  131. Example
  132. ```javascript
  133. {
  134. dropdownButton: '<span class="fa fa-chevron-down"></span>'
  135. }
  136. ```
  137. ### valuesOverPoints
  138. - Type: `Boolean`
  139. - Default: `0`
  140. Foo
  141. ###