You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

annotations.md 2.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ## Annotations
  2. Special values (like range points) on a chart can be annotated for quick comparisions. As they are among the components of a graph that can be updated, they are defined within the `data` property itself. There are two kinds of annotations that can be used to mark the vertical axis values: **markers** and **regions**.
  3. #### Markers
  4. To highlight certain values on the Y axis, `yMarkers` can be set. They will shown as dashed lines on the graph.
  5. ```js
  6. data = {
  7. // labels: [],
  8. // datasets: [],
  9. yMarkers: [
  10. {
  11. label: "Threshold",
  12. value: 650,
  13. options: { labelPos: 'left' } // default: 'right'
  14. }
  15. ]
  16. }
  17. ```
  18. <chart-demo data="ymarkers"
  19. v-bind:config="{
  20. type: 'line',
  21. height: 180,
  22. colors: ['violet'],
  23. axisOptions: {
  24. yAxisMode: 'tick'
  25. },
  26. }">
  27. </chart-demo>
  28. #### Regions
  29. 2D counterparts to markers, they have a `start` and `end` instead of value:
  30. ```js
  31. yRegions: [
  32. {
  33. label: "Optimum Value",
  34. start: 100,
  35. end: 600,
  36. options: { labelPos: 'right' }
  37. }
  38. ],
  39. ```
  40. Shown as a greyed-out area between the extremes.
  41. <chart-demo data="yregions"
  42. v-bind:config="{
  43. type: 'line',
  44. height: 180,
  45. colors: ['violet'],
  46. axisOptions: {
  47. yAxisMode: 'tick'
  48. },
  49. }">
  50. </chart-demo>
  51. ## Tooltips
  52. Frappe Charts are known for their [awesome tooltips](https://twitter.com/Elijah_Meeks/status/934338534143488000). What's more, they are also customizable for the format of the label and value displayed on them.
  53. ```js
  54. tooltipOptions: {
  55. formatTooltipX: d => (d + '').toUpperCase(),
  56. formatTooltipY: d => d + ' pts',
  57. }
  58. ```
  59. <chart-demo data="0"
  60. v-bind:config="{
  61. type: 'line',
  62. height: 150,
  63. colors: ['violet'],
  64. axisOptions: {
  65. yAxisMode: 'tick'
  66. },
  67. tooltipOptions: {
  68. formatTooltipX: d => (d + '').toUpperCase(),
  69. formatTooltipY: d => d + ' pts',
  70. }
  71. }">
  72. </chart-demo>
  73. For a non-web or static interface, where tooltips are absent, `valuesOverPoints` is a useful tweak to show value information at a glance.
  74. ```js
  75. {
  76. valuesOverPoints: 1 // default: 0
  77. }
  78. ```
  79. <chart-demo data="1" v-bind:config="{
  80. type: 'line',
  81. height: 200,
  82. colors:['violet', 'magenta'],
  83. valuesOverPoints: 1
  84. }"
  85. v-bind:options="[
  86. {
  87. name: 'type',
  88. path: ['type'],
  89. type: 'String',
  90. states: { 'Bar': 'bar', 'Line': 'line' },
  91. activeState: 'Bar'
  92. }
  93. ]">
  94. </chart-demo>
  95. Next up we'll look at perhaps one the more exciting parts in axis charts: **Mixed Charts**.