@carbon/charts-angular 1.8.0 → 1.9.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.eslintrc.json +51 -0
  2. package/.storybook/carbon-charts-theme.ts +8 -0
  3. package/.storybook/main.ts +39 -0
  4. package/.storybook/manager-head.html +22 -0
  5. package/.storybook/manager.ts +6 -0
  6. package/.storybook/preview-head.html +6 -0
  7. package/.storybook/preview.ts +42 -0
  8. package/.storybook/tsconfig.json +21 -0
  9. package/.storybook/typings.d.ts +4 -0
  10. package/README.md +0 -2
  11. package/angular.json +91 -0
  12. package/carbon.yml +277 -0
  13. package/ng-package.json +14 -0
  14. package/package.json +89 -63
  15. package/src/index.ts +53 -0
  16. package/src/lib/charts/alluvial-chart.component.ts +30 -0
  17. package/src/lib/charts/area-chart-stacked.component.ts +30 -0
  18. package/src/lib/charts/area-chart.component.ts +30 -0
  19. package/src/lib/charts/bar-chart-grouped.component.ts +30 -0
  20. package/src/lib/charts/bar-chart-simple.component.ts +30 -0
  21. package/src/lib/charts/bar-chart-stacked.component.ts +30 -0
  22. package/src/lib/charts/base-chart.component.ts +91 -0
  23. package/src/lib/charts/boxplot-chart.component.ts +30 -0
  24. package/src/lib/charts/bubble-chart.component.ts +30 -0
  25. package/src/lib/charts/bullet-chart.component.ts +30 -0
  26. package/src/lib/charts/charts.module.ts +92 -0
  27. package/src/lib/charts/choropleth.component.ts +33 -0
  28. package/src/lib/charts/circle-pack-chart.component.ts +30 -0
  29. package/src/lib/charts/combo-chart.component.ts +30 -0
  30. package/src/lib/charts/donut-chart.component.ts +30 -0
  31. package/src/lib/charts/gauge-chart.component.ts +30 -0
  32. package/src/lib/charts/heatmap-chart.component.ts +30 -0
  33. package/src/lib/charts/histogram-chart.component.ts +30 -0
  34. package/src/lib/charts/index.ts +28 -0
  35. package/src/lib/charts/line-chart.component.ts +30 -0
  36. package/src/lib/charts/lollipop-chart.component.ts +30 -0
  37. package/src/lib/charts/meter-chart.component.ts +30 -0
  38. package/src/lib/charts/pie-chart.component.ts +30 -0
  39. package/src/lib/charts/radar-chart.component.ts +30 -0
  40. package/src/lib/charts/scatter-chart.component.ts +30 -0
  41. package/src/lib/charts/tree-chart.component.ts +30 -0
  42. package/src/lib/charts/treemap-chart.component.ts +30 -0
  43. package/src/lib/charts/wordcloud-chart.component.ts +30 -0
  44. package/src/lib/diagrams/config.ts +1 -0
  45. package/src/lib/diagrams/edges/edge.component.ts +41 -0
  46. package/src/lib/diagrams/edges/edge.module.ts +11 -0
  47. package/src/lib/diagrams/edges/marker/marker.component.ts +112 -0
  48. package/src/lib/diagrams/edges/marker/marker.module.ts +43 -0
  49. package/src/lib/diagrams/index.ts +23 -0
  50. package/src/lib/diagrams/nodes/cards/card-node-column.component.ts +22 -0
  51. package/src/lib/diagrams/nodes/cards/card-node-label.component.ts +14 -0
  52. package/src/lib/diagrams/nodes/cards/card-node-subtitle.component.ts +14 -0
  53. package/src/lib/diagrams/nodes/cards/card-node-title.component.ts +14 -0
  54. package/src/lib/diagrams/nodes/cards/card-node.component.ts +98 -0
  55. package/src/lib/diagrams/nodes/cards/card-node.module.ts +32 -0
  56. package/src/lib/diagrams/nodes/shape/shape-node.component.ts +120 -0
  57. package/src/lib/diagrams/nodes/shape/shape-node.module.ts +11 -0
  58. package/src/lib/index.ts +50 -0
  59. package/src/stories/0-api.stories.mdx +69 -0
  60. package/src/stories/1-color-palette.stories.mdx +73 -0
  61. package/src/stories/2-combo-charts.stories.mdx +107 -0
  62. package/src/stories/3-dual-axes-charts.stories.mdx +51 -0
  63. package/src/stories/4-event-listeners.stories.mdx +26 -0
  64. package/src/stories/5-tabular-data-format.stories.mdx +132 -0
  65. package/src/stories/6-themes.stories.mdx +50 -0
  66. package/src/stories/all.stories.ts +104 -0
  67. package/src/stories/angular.stories.mdx +136 -0
  68. package/src/stories/diagrams/0-diagrams-start-here.stories.ts +219 -0
  69. package/src/stories/diagrams/diagrams-edges-marker.stories.ts +189 -0
  70. package/src/stories/diagrams/diagrams-edges.stories.ts +177 -0
  71. package/src/stories/diagrams/diagrams-nodes-card.stories.ts +245 -0
  72. package/src/stories/diagrams/diagrams-nodes-shape.stories.ts +141 -0
  73. package/src/stories/diagrams/utils.ts +5 -0
  74. package/src/test.ts +28 -0
  75. package/tsconfig.json +43 -0
  76. package/tsconfig.lib.json +14 -0
  77. package/tsconfig.lib.prod.json +11 -0
  78. package/tsconfig.spec.json +17 -0
  79. package/tsconfig.vite.json +13 -0
  80. package/vite.config.ts +22 -0
  81. package/LICENSE.md +0 -201
  82. package/alluvial-chart.component.d.ts +0 -13
  83. package/area-chart-stacked.component.d.ts +0 -13
  84. package/area-chart.component.d.ts +0 -13
  85. package/bar-chart-grouped.component.d.ts +0 -13
  86. package/bar-chart-simple.component.d.ts +0 -13
  87. package/bar-chart-stacked.component.d.ts +0 -13
  88. package/base-chart.component.d.ts +0 -44
  89. package/boxplot-chart.component.d.ts +0 -13
  90. package/bubble-chart.component.d.ts +0 -13
  91. package/bullet-chart.component.d.ts +0 -13
  92. package/bundles/carbon-charts-angular.umd.js +0 -2156
  93. package/bundles/carbon-charts-angular.umd.js.map +0 -1
  94. package/bundles/carbon-charts-angular.umd.min.js +0 -16
  95. package/bundles/carbon-charts-angular.umd.min.js.map +0 -1
  96. package/carbon-charts-angular.d.ts +0 -5
  97. package/carbon-charts-angular.metadata.json +0 -1
  98. package/charts.module.d.ts +0 -2
  99. package/choropleth.component.d.ts +0 -13
  100. package/circle-pack-chart.component.d.ts +0 -13
  101. package/combo-chart.component.d.ts +0 -13
  102. package/diagrams/card-node/card-node-column.component.d.ts +0 -4
  103. package/diagrams/card-node/card-node-label.component.d.ts +0 -3
  104. package/diagrams/card-node/card-node-subtitle.component.d.ts +0 -3
  105. package/diagrams/card-node/card-node-title.component.d.ts +0 -3
  106. package/diagrams/card-node/card-node.component.d.ts +0 -17
  107. package/diagrams/card-node/card-node.module.d.ts +0 -8
  108. package/diagrams/configs.d.ts +0 -1
  109. package/diagrams/edge/edge.component.d.ts +0 -17
  110. package/diagrams/edge/edge.module.d.ts +0 -3
  111. package/diagrams/marker/marker.component.d.ts +0 -37
  112. package/diagrams/marker/marker.module.d.ts +0 -4
  113. package/diagrams/shape-node/shape-node.component.d.ts +0 -22
  114. package/diagrams/shape-node/shape-node.module.d.ts +0 -3
  115. package/donut-chart.component.d.ts +0 -13
  116. package/esm2015/alluvial-chart.component.js +0 -33
  117. package/esm2015/area-chart-stacked.component.js +0 -33
  118. package/esm2015/area-chart.component.js +0 -36
  119. package/esm2015/bar-chart-grouped.component.js +0 -33
  120. package/esm2015/bar-chart-simple.component.js +0 -33
  121. package/esm2015/bar-chart-stacked.component.js +0 -33
  122. package/esm2015/base-chart.component.js +0 -137
  123. package/esm2015/boxplot-chart.component.js +0 -33
  124. package/esm2015/bubble-chart.component.js +0 -33
  125. package/esm2015/bullet-chart.component.js +0 -33
  126. package/esm2015/carbon-charts-angular.js +0 -11
  127. package/esm2015/charts.module.js +0 -97
  128. package/esm2015/choropleth.component.js +0 -33
  129. package/esm2015/circle-pack-chart.component.js +0 -33
  130. package/esm2015/combo-chart.component.js +0 -33
  131. package/esm2015/diagrams/card-node/card-node-column.component.js +0 -41
  132. package/esm2015/diagrams/card-node/card-node-label.component.js +0 -27
  133. package/esm2015/diagrams/card-node/card-node-subtitle.component.js +0 -27
  134. package/esm2015/diagrams/card-node/card-node-title.component.js +0 -27
  135. package/esm2015/diagrams/card-node/card-node.component.js +0 -148
  136. package/esm2015/diagrams/card-node/card-node.module.js +0 -23
  137. package/esm2015/diagrams/configs.js +0 -8
  138. package/esm2015/diagrams/edge/edge.component.js +0 -80
  139. package/esm2015/diagrams/edge/edge.module.js +0 -19
  140. package/esm2015/diagrams/marker/marker.component.js +0 -141
  141. package/esm2015/diagrams/marker/marker.module.js +0 -35
  142. package/esm2015/diagrams/shape-node/shape-node.component.js +0 -187
  143. package/esm2015/diagrams/shape-node/shape-node.module.js +0 -19
  144. package/esm2015/donut-chart.component.js +0 -33
  145. package/esm2015/gauge-chart.component.js +0 -33
  146. package/esm2015/heatmap-chart.component.js +0 -33
  147. package/esm2015/histogram-chart.component.js +0 -33
  148. package/esm2015/index.js +0 -45
  149. package/esm2015/line-chart.component.js +0 -33
  150. package/esm2015/lollipop-chart.component.js +0 -33
  151. package/esm2015/meter-chart.component.js +0 -33
  152. package/esm2015/pie-chart.component.js +0 -33
  153. package/esm2015/radar-chart.component.js +0 -33
  154. package/esm2015/scatter-chart.component.js +0 -33
  155. package/esm2015/tree-chart.component.js +0 -33
  156. package/esm2015/treemap-chart.component.js +0 -33
  157. package/esm2015/wordcloud-chart.component.js +0 -33
  158. package/esm5/alluvial-chart.component.js +0 -47
  159. package/esm5/area-chart-stacked.component.js +0 -47
  160. package/esm5/area-chart.component.js +0 -47
  161. package/esm5/bar-chart-grouped.component.js +0 -47
  162. package/esm5/bar-chart-simple.component.js +0 -47
  163. package/esm5/bar-chart-stacked.component.js +0 -47
  164. package/esm5/base-chart.component.js +0 -160
  165. package/esm5/boxplot-chart.component.js +0 -47
  166. package/esm5/bubble-chart.component.js +0 -47
  167. package/esm5/bullet-chart.component.js +0 -47
  168. package/esm5/carbon-charts-angular.js +0 -11
  169. package/esm5/charts.module.js +0 -101
  170. package/esm5/choropleth.component.js +0 -47
  171. package/esm5/circle-pack-chart.component.js +0 -47
  172. package/esm5/combo-chart.component.js +0 -47
  173. package/esm5/diagrams/card-node/card-node-column.component.js +0 -43
  174. package/esm5/diagrams/card-node/card-node-label.component.js +0 -25
  175. package/esm5/diagrams/card-node/card-node-subtitle.component.js +0 -25
  176. package/esm5/diagrams/card-node/card-node-title.component.js +0 -25
  177. package/esm5/diagrams/card-node/card-node.component.js +0 -86
  178. package/esm5/diagrams/card-node/card-node.module.js +0 -27
  179. package/esm5/diagrams/configs.js +0 -8
  180. package/esm5/diagrams/edge/edge.component.js +0 -64
  181. package/esm5/diagrams/edge/edge.module.js +0 -23
  182. package/esm5/diagrams/marker/marker.component.js +0 -188
  183. package/esm5/diagrams/marker/marker.module.js +0 -39
  184. package/esm5/diagrams/shape-node/shape-node.component.js +0 -104
  185. package/esm5/diagrams/shape-node/shape-node.module.js +0 -23
  186. package/esm5/donut-chart.component.js +0 -47
  187. package/esm5/gauge-chart.component.js +0 -47
  188. package/esm5/heatmap-chart.component.js +0 -47
  189. package/esm5/histogram-chart.component.js +0 -47
  190. package/esm5/index.js +0 -45
  191. package/esm5/line-chart.component.js +0 -47
  192. package/esm5/lollipop-chart.component.js +0 -47
  193. package/esm5/meter-chart.component.js +0 -47
  194. package/esm5/pie-chart.component.js +0 -47
  195. package/esm5/radar-chart.component.js +0 -47
  196. package/esm5/scatter-chart.component.js +0 -47
  197. package/esm5/tree-chart.component.js +0 -47
  198. package/esm5/treemap-chart.component.js +0 -47
  199. package/esm5/wordcloud-chart.component.js +0 -47
  200. package/fesm2015/carbon-charts-angular.js +0 -1722
  201. package/fesm2015/carbon-charts-angular.js.map +0 -1
  202. package/fesm5/carbon-charts-angular.js +0 -1924
  203. package/fesm5/carbon-charts-angular.js.map +0 -1
  204. package/gauge-chart.component.d.ts +0 -13
  205. package/heatmap-chart.component.d.ts +0 -13
  206. package/histogram-chart.component.d.ts +0 -13
  207. package/index.d.ts +0 -38
  208. package/line-chart.component.d.ts +0 -13
  209. package/lollipop-chart.component.d.ts +0 -13
  210. package/meter-chart.component.d.ts +0 -13
  211. package/pie-chart.component.d.ts +0 -13
  212. package/radar-chart.component.d.ts +0 -13
  213. package/scatter-chart.component.d.ts +0 -13
  214. package/tree-chart.component.d.ts +0 -13
  215. package/treemap-chart.component.d.ts +0 -13
  216. package/wordcloud-chart.component.d.ts +0 -13
@@ -0,0 +1,73 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Color palette" />
4
+ # Color palette
5
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
6
+
7
+ Carbon charts recently updated the default color palettes for `@carbon/charts` to follow the new IBM Design Language data vizualization palette.
8
+ This means more accessibility and usability in terms of the color variants provided by the library.
9
+
10
+ > For more guidance on using the IBM Design Language dataviz palette, see [here](https://www.carbondesignsystem.com/data-visualization/color-palettes/)
11
+
12
+ <br/>
13
+ ## Using a default palette
14
+ You can add the following chart options if you want to choose a color palette option from the Carbon dataviz palette.
15
+ By default, carbon-charts will assign the first color option for the appropriate amount of data groups (ex. charts with 4 data groups will get the first option for the 4-color palettes).
16
+
17
+ ```ts
18
+ const verySimpleBarData = [
19
+ { group: "Qty", value: 65000 },
20
+ { group: "More", value: 29123 }
21
+ ] // bar chart with 2 data groups "Qty" and "More"
22
+
23
+ const verySimpleBarOptions = {
24
+ color: {
25
+ pairing: {
26
+ option: 2 // use the second color palette option for 2-group charts
27
+ }
28
+ }
29
+ }
30
+ ```
31
+ > Refer to the Carbon Design Website for the full index of color palette options (by group size).
32
+
33
+ <br/>
34
+ ## Using a different size color palette
35
+
36
+ > Note: It is not suggested to use a color palette designed for a different number of data groups than the chart is rendering.
37
+
38
+ ```ts
39
+ // line chart with 2 data groups "Saturday" and "Sunday" initially but expecting
40
+ // 3 data groups on some data loads when long weekend "Friday" or "Monday" is included
41
+ const lineData = [
42
+ { group: "Saturday", sales: 65000 },
43
+ { group: "Sunday", sales: 29123 }
44
+ ]
45
+
46
+ const lineOptions = {
47
+ color: {
48
+ pairing: {
49
+ numberOfVariants: 3, // use a palette with 3 color variants
50
+ option: 2 // use the 2nd option of 3 color charts
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ <br/>
57
+ ## Using a custom color scale
58
+
59
+ You're also able to provide a custom
60
+ `color range` to be used within the color scale.
61
+ You are expected to define values for _all the data groups_ in your chart. If less data groups are provided than the chart contains, it will
62
+ default to using the IBM Design Language dataviz palette.
63
+
64
+ ```ts
65
+ const simpleBarOptions = {
66
+ color: {
67
+ scale: {
68
+ "Dataset 1": "blue",
69
+ "Dataset 2": "red"
70
+ } // chart only has 2 data groups
71
+ }
72
+ }
73
+ ```
@@ -0,0 +1,107 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Combo charts" />
4
+
5
+ # Combo charts
6
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
7
+
8
+ Combo charts allow users to visually compare complex datasets by superimposing different graphing components within one chart.
9
+ Combination charts **may or may not** use dual axes although it is common that they do. For more information on dual axes with **carbon-charts**, please see the [dual axes tutorial](/?path=/story/docs-tutorials--dual-axes-charts).
10
+
11
+ > Note: `ComboChart` extends axis chart functionality and should only comprise of graphs/components that use axes.
12
+
13
+ <br/>
14
+ ### Using the carbon-charts defaults
15
+
16
+ There is support for using pre-existing carbon-charts graphs and combining them together within a `ComboChart`.
17
+ The charts that can be seamlessly combined are all different **axis charts only**. This is the **recommended way to use `ComboCharts`**.
18
+
19
+ Supported `ChartTypes` to combine:
20
+ - `LineChart`
21
+ - `ScatterChart`
22
+ - `StackedScatterChart`
23
+ - `AreaChart`
24
+ - `StackedAreaChart`
25
+ - `BarChart`
26
+ - `GroupedBarChart`
27
+ - `StackedBarChart`
28
+
29
+ Below is an example of combining a carbon-charts `AreaChart` with a `LineChart`.
30
+
31
+ ```ts
32
+ import { ChartTypes } from "@carbon/charts"
33
+ const verySimpleComboData = [
34
+ { group: "Dataset 1", value: 650, date: "Tuesday" },
35
+ { group: "Dataset 2", value: 296, date: "Tuesday" },
36
+ // ...more data
37
+ ]
38
+
39
+ const comboOptions = {
40
+ ...otherOptions, // global options apply to all the charts listed in chartTypes (where relevant)
41
+ axes: {...},
42
+ comboChartTypes: [ // takes an array of objects
43
+ {
44
+ type: ChartTypes.AREA // use a valid ChartType from enums
45
+ options: {}, // component specific options (i.e, turn on the scatter points, adjust scatter radius)
46
+ correspondingDatasets: ["Dataset 1"] // the datasets that we want to map with this type of chart
47
+ },
48
+ {
49
+ type: ChartTypes.LINE, // use a valid ChartType from enums
50
+ options: {
51
+ points: {
52
+ enabled: false // disabling the scatter points on the LineChart here won't affect the points in the AreaChart
53
+ }
54
+ }, // component specific options
55
+ correspondingDatasets: ["Dataset 2"]
56
+ }
57
+ ]
58
+ }
59
+ ```
60
+ > See the storybook demos for more combinations of charts and configurations.
61
+
62
+ <br/>
63
+ ### Using custom graphs & components
64
+ Custom components and **independent** carbon-charts components can also be rendered into a `ComboChart`. This allows
65
+ users to create their own components and combine them with the pre-existing componentry offered.
66
+
67
+ Below is an example of combining a carbon-charts `AreaChart` with a standalone `Line` class constructor.
68
+
69
+ > Reminder: `ComboChart` extends axis chart functionality and should only comprise of graphs/components that use axes.
70
+
71
+ ```ts
72
+ import { ChartTypes, Configuration, Component } from "@carbon/charts"
73
+
74
+ const verySimpleComboData = [
75
+ { group: "Dataset 1", value: 650, date: "Tuesday" },
76
+ { group: "Dataset 2", value: 296, date: "Tuesday" },
77
+ // ...more data
78
+ ]
79
+
80
+ const comboOptions = {
81
+ ...otherOptions, // global options apply to all the charts listed in chartTypes (where relevant)
82
+ axes: {...},
83
+ comboChartTypes: [ // takes an array of objects
84
+ {
85
+ type: ChartTypes.AREA // use a valid ChartType from enums
86
+ options: {},
87
+ correspondingDatasets: ["Dataset 1"] // the datasets that we want to map with this type of chart
88
+ },
89
+ {
90
+ type: Component.Line // using an imported class constructor
91
+ // add the base options for that type of chart if it is in the carbon-charts library and any additional configurations needed
92
+ options: Object.assign({}, Configuration.options.lineChart, {
93
+ points: {
94
+ enabled: false // disabling the scatter points on the LineChart here won't affect the points in the AreaChart
95
+ }
96
+ }), // component specific options
97
+ correspondingDatasets: ["Dataset 2"]
98
+ }
99
+ ]
100
+ }
101
+ ```
102
+
103
+ Users can omit using any defaults (chartTypes) and build up the charts with independent class contructors if they choose. In the case where all the types are constructors,
104
+ ComboChart **will still render some additional componetry for axis-charts** in addition to the custom/standalone components in the options.
105
+
106
+ Keep in mind that when using components/graphs independently, the library will not enforce any type checking.
107
+ This enables the user to extend `ComboChart` to cover complex cases but also leaves responsibility on the developers to use the right chart combinations.
@@ -0,0 +1,51 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Dual axes charts" />
4
+
5
+ # Dual Axes Charts
6
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
7
+
8
+ If a chart is considered to be a **dual axes** chart, it means that the chart uses 2 **different** axes for visually mapping [ranges](https://www.mathsisfun.com/sets/domain-range-codomain.html) for the data.
9
+ Careful consideration should be taken when using dual axes charts because they can more often misrepresent the data.
10
+
11
+ Please refer to dataviz guidelines [here](https://www.carbondesignsystem.com/data-visualization/getting-started) for more information on IBM's best practices.
12
+
13
+ <br/>
14
+ ## Setting up a dual axes chart
15
+
16
+ When using multiple Y or X axes, it is best to specify which axes will be primary (used for ranges or domain).
17
+ Below we define options for an axis chart with **two dual axes (both vertical)** and one horizontal axis (bottom). In this case, we want to
18
+ set up the horizontal axis (bottom) as the domain, and have the datasets' ranges mapped to the different vertical axes - "Temperature" on the left axis and "Products sold" on the right.
19
+
20
+ Use the `main` option to define the `left` axis as the primary axis. The axis defined as `main` will be used to map **all datasets** until we set the
21
+ `correspondingDatasets` on the non-primary (secondary) axis. If `correspondingDatasets` isn't set on the secondary axis, then the chart will render
22
+ a read-only axis (without datasets mapped to it).
23
+
24
+ ```ts
25
+ const dualAxesOptions = {
26
+ ...otherOptions,
27
+ axes: {
28
+ bottom: {
29
+ mapsTo: date,
30
+ scaleType: time
31
+ },
32
+ left: {
33
+ mapsTo: temperature,
34
+ scaleType: linear,
35
+ main: true // this will be the primary axis
36
+ },
37
+ right: {
38
+ mapsTo: value,
39
+ scaleType: linear,
40
+ // the dataset "Products sold" will map to this axis instead
41
+ correspondingDatasets: [
42
+ "Products sold"
43
+ ]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ Note: The library tries to determine the orientation/primary axes **without the use of `main`**,
50
+ however it is best to be explicit when working with dual axes charts. If `main` is not specified, the library
51
+ will try to determine the best primary/secondary assignments to make which could result in some confusion down the road.
@@ -0,0 +1,26 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Event listeners" />
4
+
5
+ # Events in Carbon Charts
6
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
7
+
8
+ Event dispatching for chart elements allows applications to trigger custom UI actions and states when users interact with the charts.
9
+
10
+ You can see the current dispatched events [here](https://carbon-design-system.github.io/carbon-charts/documentation/modules/_interfaces_events_.html).
11
+
12
+ <br/>
13
+ ### Listening for events
14
+ To listen for event just use a reference to the chart to add an event listener for one of the dispatched events above.
15
+ This is an example for adding an event listener for a mouseover event on bar chart `rect`s.
16
+
17
+ ```ts
18
+ barChart.services.events.addEventListener("bar-mouseover", e => console.log(e.detail))
19
+ ```
20
+
21
+ <br/>
22
+ ### Code examples
23
+ Here are some possible solutions for event binding:
24
+
25
+ - [Vanilla JavaScript](https://codesandbox.io/p/sandbox/carbon-charts-vanilla-event-binding-9b1i5?file=/src/index.js)
26
+ - [React](https://codesandbox.io/p/sandbox/carbon-charts-react-event-binding-contributed-by-eric-lowry-upztp?file=/src/App.js)
@@ -0,0 +1,132 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Tabular data format" />
4
+
5
+ # Tabular data format
6
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
7
+
8
+ The default data format in Carbon Charts has a tabular nature.
9
+
10
+ This means more flexibility for our users in terms of the shape
11
+ of the data they can provide to the library.
12
+
13
+ ```ts
14
+ const simpleBarData = [
15
+ { group: "Qty", value: 65000 },
16
+ { group: "More", value: 29123 },
17
+ { group: "Sold", value: 35213 },
18
+ { group: "Restocking", value: 51213 },
19
+ { group: "Misc", value: 16932 }
20
+ ]
21
+ ```
22
+
23
+ Imagine an **array where each element is a datapoint.**
24
+
25
+ Now we need to introduce some new fields into our `axes`
26
+ options in order to map keys within our datapoints to axis values.
27
+
28
+ <br/>
29
+ ##### Additions to charting options:
30
+ *Note:* **This section does not apply to any
31
+ non-axis charting components (e.g. pie & donut)**
32
+
33
+ We'd still need a way to know which keys map to
34
+ your values (`rangeIdentifier`) and which map to
35
+ the labels you'd be showing on an axis (`domainIdentifier`).
36
+
37
+ These identifiers can be set through the `mapsTo`
38
+ option within each axis, and are defeaulted to `value`
39
+ & (`key` or `date` - depending on whether your datapoints
40
+ include dates).
41
+
42
+ > Although the library will set fallback `mapsTo` defaults, you should always set your own.
43
+
44
+ ```ts
45
+ const simpleBarOptions = {
46
+ title: "Simple bar (discrete)",
47
+ axes: {
48
+ left: {
49
+ mapsTo: "value"
50
+ },
51
+ bottom: {
52
+ mapsTo: "group",
53
+ scaleType: "labels"
54
+ }
55
+ }
56
+ }
57
+ ```
58
+ <br/>
59
+ ##### Non-axis chart types:
60
+
61
+ In the case of pie and donut, the library will
62
+ always look for the `value` key within your datapoints:
63
+
64
+ ```ts
65
+ export const pieData = [
66
+ { group: "2V2N 9KYPM version 1", value: 20000 },
67
+ { group: "L22I P66EP L22I P66EP L22I P66EP", value: 65000 },
68
+ { group: "JQAI 2M4L1", value: 75000 },
69
+ { group: "J9DZ F37AP", value: 1200 },
70
+ { group: "YEL48 Q6XK YEL48", value: 10000 },
71
+ { group: "Misc", value: 25000 }
72
+ ]
73
+ ```
74
+ <br/>
75
+ ##### Customizable options:
76
+
77
+ You're able to customize the `groupMapsTo`
78
+ which is used to determine the key within your data that
79
+ identifies the grouping of the datapoints.
80
+
81
+ ```ts
82
+ const simpleBarOptions = {
83
+ data: {
84
+ groupMapsTo: "category"
85
+ }
86
+ }
87
+
88
+ const simpleBarData = [
89
+ { category: "Qty", value: 65000 },
90
+ { category: "More", value: 29123 },
91
+ { category: "Sold", value: 35213 },
92
+ { category: "Restocking", value: 51213 },
93
+ { category: "Misc", value: 16932 }
94
+ ]
95
+ ```
96
+
97
+ For bubble charts, you're able to customize the "radius" identifier:
98
+ ```ts
99
+ export const bubbleDoubleLinearOptions = {
100
+ title: "Bubble (linear)",
101
+ axes: {
102
+ bottom: {
103
+ title: "No. of employees",
104
+ mapsTo: "sales",
105
+ includeZero: false
106
+ },
107
+ left: {
108
+ title: "Annual sales",
109
+ mapsTo: "profit",
110
+ includeZero: false
111
+ }
112
+ },
113
+ bubble: {
114
+ radiusMapsTo: "surplus"
115
+ }
116
+ }
117
+
118
+ const bubbleDoubleLinearData = [
119
+ { group: "Dataset 1", sales: 10000, profit: 32100, surplus: 50000 },
120
+ { group: "Dataset 1", sales: 12000, profit: 23500, surplus: 34000 },
121
+ { group: "Dataset 1", sales: 14000, profit: 53100, surplus: 63000 },
122
+ { group: "Dataset 1", sales: 15000, profit: 42300, surplus: 43000 },
123
+ { group: "Dataset 1", sales: 16000, profit: 12300, surplus: 55000 },
124
+ { group: "Dataset 2", sales: 11000, profit: 12400, surplus: 25000 },
125
+ { group: "Dataset 2", sales: 13000, profit: 34500, surplus: 35000 },
126
+ { group: "Dataset 2", sales: 13500, profit: 23100, surplus: 55000 },
127
+ { group: "Dataset 2", sales: 15500, profit: 63200, surplus: 35000 },
128
+ { group: "Dataset 2", sales: 15750, profit: 24300, surplus: 64000 }
129
+ ]
130
+ ```
131
+
132
+ > Default value for `radiusMapsTo` is `radius`
@@ -0,0 +1,50 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Tutorials/Themes" />
4
+
5
+ # Themes
6
+ > This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>.
7
+
8
+ We support all 4 Carbon themes (white, g10, g90 & g100), which are all included inside the main CSS bundle.
9
+ After importing the carbon styles, pass in one of the four Carbon themes in options like in the examples below.
10
+
11
+ **If using CSS:**
12
+
13
+ You'd need to import our **CSS bundle** `@carbon/charts/styles.css`
14
+
15
+ e.g.
16
+
17
+ ```html
18
+ <div id="my-sample-chart"></div>
19
+ ```
20
+
21
+ ```ts
22
+ const chartHolder = document.getElementById("my-sample-chart")
23
+ new SimpleBarChart(chartHolder, {
24
+ data,
25
+ options: {
26
+ ...myChartOptions,
27
+ theme: "g100", // Pass theme in options
28
+ }
29
+ })
30
+ ```
31
+
32
+ **If using SCSS:**
33
+
34
+ ```scss
35
+ @import "@carbon/charts/styles/styles.scss";
36
+ ```
37
+
38
+ ```ts
39
+ const chartHolder = document.getElementById("my-sample-chart")
40
+ new SimpleBarChart(chartHolder, {
41
+ data,
42
+ options: {
43
+ ...myChartOptions,
44
+ theme: "g100", // Pass theme in options
45
+ }
46
+ })
47
+ ```
48
+ <br/>
49
+ ## Color palette
50
+ - Our color palette udpates automatically on theme switches
@@ -0,0 +1,104 @@
1
+ import { storiesOf, type Args, type StoryFn } from '@storybook/angular'
2
+ import sdk from '@stackblitz/sdk'
3
+ import { ChartTheme } from '@carbon/charts'
4
+ import { type Demo, type DemoGroup, storybookDemoGroups } from '@carbon/charts/demo'
5
+ import { ChartsModule } from '../'
6
+
7
+ const DEFAULT_THEME = ChartTheme.G100
8
+
9
+ storiesOf('Docs', module).add(
10
+ 'Welcome',
11
+ () => ({
12
+ template: `
13
+ <div class="container intro">
14
+ <div
15
+ class="welcome__container"
16
+ style="background: url(./welcome.png) no-repeat center center fixed; background-size: cover;">
17
+ <div class="welcome__content">
18
+ <h2 class="welcome__heading">Carbon Charts</h2>
19
+ <h4 class="welcome__heading welcome__heading--subtitle">(Angular)</h4>
20
+ <h5 class="welcome__heading welcome__heading--other">Other versions</h5>
21
+ <ul>
22
+ <li><a href="https://charts.carbondesignsystem.com" class="welcome__heading welcome__heading--other">Vanilla JavaScript</a></li>
23
+ <li><a href="https://charts.carbondesignsystem.com/react" class="welcome__heading welcome__heading--other">React</a></li>
24
+ <li><a href="https://charts.carbondesignsystem.com/vue" class="welcome__heading welcome__heading--other">Vue</a></li>
25
+ <li><a href="https://charts.carbondesignsystem.com/svelte" class="welcome__heading welcome__heading--other">Svelte</a></li>
26
+ </ul>
27
+ <span class="netlify">Deploys by <a href="https://netlify.com" target="_blank">Netlify</a></span>
28
+ </div>
29
+ </div>
30
+ </div>`
31
+ }),
32
+ {
33
+ controls: {
34
+ hideNoControlsWarning: true
35
+ }
36
+ }
37
+ )
38
+
39
+ const getTemplate = (componentSelector: string) => `
40
+ <div class="container">
41
+ <div class="v10-banner">
42
+ This version relies on <b>Carbon v11</b>. If you're using Carbon v10, <a href="https://carbon-charts-0x.netlify.app" target="_blank" rel="noreferrer">see the legacy demo site</a>
43
+ </div>
44
+ <h3>
45
+ <b>Component:</b>
46
+ <span class="cds--tag cds--tag--green component-name">${componentSelector}</span>
47
+ </h3>
48
+ <p class="props">
49
+ <b>Props:</b> data, <a href="https://carbon-design-system.github.io/carbon-charts/documentation/modules/_interfaces_charts_.html" target="_blank">options</a>
50
+ </p>
51
+ <div class="marginTop-30" id="chart-demo">
52
+ <${componentSelector} [data]="data" [options]="options"></${componentSelector}>
53
+ </div>
54
+ <h3 class="marginTop-30">Code sample</h3>
55
+ <p>Opens in a new tab. Please ensure pop-up blocker is not on.</p><br/>
56
+ <a href="#" (click)="openSandbox($event)">
57
+ <img
58
+ src="https://developer.stackblitz.com/img/open_in_stackblitz.svg"
59
+ className="marginTop"
60
+ alt="Edit on StackBlitz"
61
+ />
62
+ </a>
63
+ </div>`
64
+
65
+ // Loop through demo groups array
66
+ storybookDemoGroups.forEach((demoGroup: DemoGroup) => {
67
+ // Create story group
68
+ const groupStories = storiesOf(`${demoGroup.storyGroupTitle}/${demoGroup.title}`, module)
69
+
70
+ // Create stories within story group
71
+ demoGroup.demos.forEach((demo: Demo) => {
72
+ demo.options.theme = DEFAULT_THEME
73
+ document.documentElement.setAttribute('data-carbon-theme', DEFAULT_THEME)
74
+ const demoStory: StoryFn = (args: Args) => ({
75
+ template: getTemplate(demo.chartType.angular as string),
76
+ moduleMetadata: {
77
+ imports: [ChartsModule]
78
+ },
79
+ props: {
80
+ data: args['data'],
81
+ options: args['options'],
82
+ // StackBlitz
83
+ openSandbox: (event: Event) => {
84
+ event.preventDefault()
85
+ sdk.openProject(demo.code.angular, { newWindow: true })
86
+ }
87
+ }
88
+ })
89
+ groupStories.add(demo.title, demoStory, {
90
+ args: {
91
+ data: demo.data,
92
+ options: demo.options
93
+ },
94
+ argTypes: {
95
+ data: {
96
+ control: { type: 'object' }
97
+ },
98
+ options: {
99
+ control: { type: 'object' }
100
+ }
101
+ }
102
+ })
103
+ })
104
+ })
@@ -0,0 +1,136 @@
1
+ import { Meta } from '@storybook/blocks'
2
+
3
+ <Meta title="Docs/Getting Started/Angular" />
4
+
5
+ # Carbon Charts - Angular
6
+
7
+ The Carbon Charts Angular library provides a collection of reusable charting components to build websites
8
+ and user interfaces.
9
+
10
+ Adopting the library enables developers to use consistent markup, styles, and behavior
11
+ in prototype and production work.
12
+
13
+ [Angular wrappers - storybook](https://carbon-design-system.github.io/carbon-charts/angular)
14
+
15
+ <br/>
16
+ ## Install
17
+
18
+ **with yarn (preferred):**
19
+ ```bash
20
+ yarn add @carbon/charts-angular @carbon/styles d3
21
+ ```
22
+
23
+ **with npm:**
24
+ ```bash
25
+ npm install --save @carbon/charts-angular @carbon/styles d3
26
+ ```
27
+
28
+ ## Getting started
29
+
30
+ To start using the `StackedBarChart` component, try the example below:
31
+
32
+
33
+ <br/>
34
+ ###### app.module.ts
35
+ ```ts
36
+ import { NgModule } from '@angular/core'
37
+ import { BrowserModule } from '@angular/platform-browser'
38
+
39
+ import { ChartsModule } from '@carbon/charts-angular'
40
+
41
+ import { AppComponent } from './app.component'
42
+
43
+ @NgModule({
44
+ imports: [BrowserModule, ChartsModule],
45
+ declarations: [AppComponent],
46
+ bootstrap: [AppComponent],
47
+ })
48
+ export class AppModule {}
49
+ ```
50
+
51
+ ###### app.component.html
52
+ ```html
53
+ <ibm-stacked-bar-chart
54
+ class="n-chart"
55
+ [data]="stackedBarData"
56
+ [options]="stackedBarOptions"
57
+ #stackedBarChart
58
+ ></ibm-bar-chart>
59
+ ```
60
+
61
+ ###### app.component.ts
62
+ ```ts
63
+ import { Component } from '@angular/core'
64
+
65
+ import '@carbon/styles/css/styles.css' // may affect global styles
66
+ import '@carbon/charts-angular/styles.css'
67
+
68
+ @Component({
69
+ selector: 'my-app',
70
+ templateUrl: './app.component.html',
71
+ styleUrls: ['./app.component.css'],
72
+ })
73
+ export class AppComponent {
74
+ stackedBarData = [
75
+ // refer to tabular data format tutorial
76
+ ]
77
+
78
+ stackedBarOptions = {
79
+ // refer to chart specific options
80
+ }
81
+ }
82
+ ```
83
+
84
+ <br/>
85
+ ## Data
86
+ Data follows the same model in all charts.
87
+ See tutorial on tabular data format for more information on chart data.
88
+
89
+ <br/>
90
+ ## Options
91
+
92
+ You can see the default options for all charts
93
+ [here](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/src/configuration.ts).
94
+
95
+ <br/>
96
+ ## Demos and Examples
97
+ + **[Storybook - Demos](https://carbon-design-system.github.io/carbon-charts/angular)**
98
+ + **[Storybook - Story Sources](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/angular/stories)**
99
+ + **[Storybook - Data & options used](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/demo/data)**
100
+
101
+ <br/>
102
+ ## Guidance
103
+
104
+ Please refer to the
105
+ [Carbon Design Systems guidance](https://www.carbondesignsystem.com/data-visualization/chart-types)
106
+ on using the different charts available in this library.
107
+
108
+ <br/>
109
+ ## Development
110
+ Please refer to the
111
+ [Contribution Guidelines](https://github.com/carbon-design-system/carbon-charts/blob/master/CONTRIBUTING.md)
112
+ before starting any work.
113
+
114
+ #### Using the server
115
+ We recommend the use of [Angular Storybook](https://github.com/storybookjs/storybook/tree/next/app/angular)
116
+ for developing components.
117
+
118
+ **Start the server:**
119
+ ```bash
120
+ cd packages/angular
121
+ yarn storybook
122
+ ```
123
+
124
+ Open browser to `http://localhost:9005`
125
+
126
+ <br/>
127
+ ## List of available components
128
+ View available components [here](https://github.com/carbon-design-system/carbon-charts#component-status)
129
+
130
+ <br/>
131
+ ## Troubleshoot
132
+
133
+ If you experience any issues while getting set up with Carbon Charts, please head over to the
134
+ [GitHub repo](https://github.com/carbon-design-system/carbon-charts) for more guidelines and support.
135
+ Please [create an issue](https://github.com/carbon-design-system/carbon-charts/issues) if your issue
136
+ does not already exist.