@carbon/charts-svelte 1.7.6 → 1.9.0-next.0

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 (111) hide show
  1. package/CHANGELOG.md +16 -6
  2. package/README.md +127 -235
  3. package/dist/AlluvialChart.svelte +20 -0
  4. package/dist/AlluvialChart.svelte.d.ts +25 -0
  5. package/dist/AreaChart.svelte +20 -0
  6. package/dist/AreaChart.svelte.d.ts +25 -0
  7. package/dist/BarChartGrouped.svelte +20 -0
  8. package/dist/BarChartGrouped.svelte.d.ts +25 -0
  9. package/dist/BarChartSimple.svelte +20 -0
  10. package/dist/BarChartSimple.svelte.d.ts +25 -0
  11. package/dist/BarChartStacked.svelte +20 -0
  12. package/dist/BarChartStacked.svelte.d.ts +25 -0
  13. package/dist/BaseChart.svelte +35 -0
  14. package/dist/BaseChart.svelte.d.ts +29 -0
  15. package/dist/BoxplotChart.svelte +20 -0
  16. package/dist/BoxplotChart.svelte.d.ts +25 -0
  17. package/dist/BubbleChart.svelte +20 -0
  18. package/dist/BubbleChart.svelte.d.ts +25 -0
  19. package/dist/BulletChart.svelte +20 -0
  20. package/dist/BulletChart.svelte.d.ts +25 -0
  21. package/dist/ChoroplethChart.svelte +20 -0
  22. package/dist/ChoroplethChart.svelte.d.ts +25 -0
  23. package/dist/CirclePackChart.svelte +20 -0
  24. package/dist/CirclePackChart.svelte.d.ts +25 -0
  25. package/dist/ComboChart.svelte +20 -0
  26. package/dist/ComboChart.svelte.d.ts +25 -0
  27. package/dist/DonutChart.svelte +20 -0
  28. package/dist/DonutChart.svelte.d.ts +25 -0
  29. package/dist/GaugeChart.svelte +20 -0
  30. package/dist/GaugeChart.svelte.d.ts +25 -0
  31. package/dist/HeatmapChart.svelte +20 -0
  32. package/dist/HeatmapChart.svelte.d.ts +25 -0
  33. package/dist/HistogramChart.svelte +20 -0
  34. package/dist/HistogramChart.svelte.d.ts +25 -0
  35. package/dist/LineChart.svelte +20 -0
  36. package/dist/LineChart.svelte.d.ts +25 -0
  37. package/dist/LollipopChart.svelte +20 -0
  38. package/dist/LollipopChart.svelte.d.ts +25 -0
  39. package/dist/MeterChart.svelte +20 -0
  40. package/dist/MeterChart.svelte.d.ts +25 -0
  41. package/dist/PieChart.svelte +20 -0
  42. package/dist/PieChart.svelte.d.ts +25 -0
  43. package/dist/RadarChart.svelte +20 -0
  44. package/dist/RadarChart.svelte.d.ts +25 -0
  45. package/dist/ScatterChart.svelte +20 -0
  46. package/dist/ScatterChart.svelte.d.ts +25 -0
  47. package/dist/StackedAreaChart.svelte +20 -0
  48. package/dist/StackedAreaChart.svelte.d.ts +25 -0
  49. package/dist/TreeChart.svelte +20 -0
  50. package/dist/TreeChart.svelte.d.ts +25 -0
  51. package/dist/TreemapChart.svelte +20 -0
  52. package/dist/TreemapChart.svelte.d.ts +25 -0
  53. package/dist/WordCloudChart.svelte +20 -0
  54. package/dist/WordCloudChart.svelte.d.ts +25 -0
  55. package/dist/index.d.ts +26 -0
  56. package/{src → dist}/index.js +10 -35
  57. package/dist/styles.css +28463 -0
  58. package/dist/styles.css.map +1 -0
  59. package/dist/styles.min.css +1 -0
  60. package/dist/styles.min.css.map +1 -0
  61. package/package.json +91 -63
  62. package/src/AlluvialChart.svelte +0 -16
  63. package/src/AreaChart.svelte +0 -16
  64. package/src/BarChartGrouped.svelte +0 -16
  65. package/src/BarChartSimple.svelte +0 -16
  66. package/src/BarChartStacked.svelte +0 -16
  67. package/src/BaseChart.svelte +0 -80
  68. package/src/BoxplotChart.svelte +0 -16
  69. package/src/BubbleChart.svelte +0 -16
  70. package/src/BulletChart.svelte +0 -16
  71. package/src/CirclePackChart.svelte +0 -16
  72. package/src/ComboChart.svelte +0 -16
  73. package/src/DonutChart.svelte +0 -16
  74. package/src/GaugeChart.svelte +0 -16
  75. package/src/HeatmapChart.svelte +0 -16
  76. package/src/HistogramChart.svelte +0 -16
  77. package/src/LineChart.svelte +0 -16
  78. package/src/LollipopChart.svelte +0 -16
  79. package/src/MeterChart.svelte +0 -16
  80. package/src/PieChart.svelte +0 -16
  81. package/src/RadarChart.svelte +0 -16
  82. package/src/ScatterChart.svelte +0 -16
  83. package/src/StackedAreaChart.svelte +0 -16
  84. package/src/TreeChart.svelte +0 -16
  85. package/src/TreemapChart.svelte +0 -16
  86. package/src/WordCloudChart.svelte +0 -16
  87. package/types/AlluvialChart.d.ts +0 -5
  88. package/types/AreaChart.d.ts +0 -5
  89. package/types/BarChartGrouped.d.ts +0 -5
  90. package/types/BarChartSimple.d.ts +0 -5
  91. package/types/BarChartStacked.d.ts +0 -5
  92. package/types/BaseChart.d.ts +0 -69
  93. package/types/BoxplotChart.d.ts +0 -5
  94. package/types/BubbleChart.d.ts +0 -5
  95. package/types/BulletChart.d.ts +0 -5
  96. package/types/CirclePackChart.d.ts +0 -5
  97. package/types/ComboChart.d.ts +0 -5
  98. package/types/DonutChart.d.ts +0 -5
  99. package/types/GaugeChart.d.ts +0 -5
  100. package/types/HistogramChart.d.ts +0 -5
  101. package/types/LineChart.d.ts +0 -5
  102. package/types/LollipopChart.d.ts +0 -5
  103. package/types/MeterChart.d.ts +0 -5
  104. package/types/PieChart.d.ts +0 -5
  105. package/types/RadarChart.d.ts +0 -5
  106. package/types/ScatterChart.d.ts +0 -5
  107. package/types/StackedAreaChart.d.ts +0 -5
  108. package/types/TreeChart.d.ts +0 -15
  109. package/types/TreemapChart.d.ts +0 -5
  110. package/types/WordCloudChart.d.ts +0 -5
  111. package/types/index.d.ts +0 -23
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.8.0](https://github.com/carbon-design-system/carbon-charts/compare/v1.7.6...v1.8.0) (2023-06-03)
7
+
8
+ ### Features
9
+
10
+ - **core:** Add choropleth chart
11
+ ([#1487](https://github.com/carbon-design-system/carbon-charts/issues/1487))
12
+ ([62caeb1](https://github.com/carbon-design-system/carbon-charts/commit/62caeb1fd6fab9e2a39d85b024f2d9b97f8bd1fa))
13
+
14
+ # Change Log
15
+
16
+ All notable changes to this project will be documented in this file. See
17
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
18
+
6
19
  ## [1.7.6](https://github.com/carbon-design-system/carbon-charts/compare/v1.7.5...v1.7.6) (2023-05-01)
7
20
 
8
21
  **Note:** Version bump only for package @carbon/charts-svelte
@@ -154,8 +167,7 @@ All notable changes to this project will be documented in this file. See
154
167
  - **core:** allow theme to be set via options prop
155
168
  ([#1412](https://github.com/carbon-design-system/carbon-charts/issues/1412))
156
169
  ([6288548](https://github.com/carbon-design-system/carbon-charts/commit/62885487a700e2222d51f70aea790eddd5d6d086)),
157
- closes
158
- [#1411](https://github.com/carbon-design-system/carbon-charts/issues/1411)
170
+ closes [#1411](https://github.com/carbon-design-system/carbon-charts/issues/1411)
159
171
 
160
172
  ## [1.3.2](https://github.com/carbon-design-system/carbon-charts/compare/v1.3.1...v1.3.2) (2022-06-30)
161
173
 
@@ -361,8 +373,7 @@ All notable changes to this project will be documented in this file. See
361
373
 
362
374
  ### Features
363
375
 
364
- - **svelte:** add TypeScript definitions for Alluvial, Histogram, and Tree
365
- charts
376
+ - **svelte:** add TypeScript definitions for Alluvial, Histogram, and Tree charts
366
377
  ([#1219](https://github.com/carbon-design-system/carbon-charts/issues/1219))
367
378
  ([3e7fcc2](https://github.com/carbon-design-system/carbon-charts/commit/3e7fcc2f16d16d67c4f39f4d4389878b5d829aba))
368
379
 
@@ -465,8 +476,7 @@ All notable changes to this project will be documented in this file. See
465
476
  - **core:** create alluvial chart
466
477
  ([#1132](https://github.com/carbon-design-system/carbon-charts/issues/1132))
467
478
  ([08fa194](https://github.com/carbon-design-system/carbon-charts/commit/08fa194f1c59ab2110c0d221886fc0174c936194)),
468
- closes
469
- [#871](https://github.com/carbon-design-system/carbon-charts/issues/871)
479
+ closes [#871](https://github.com/carbon-design-system/carbon-charts/issues/871)
470
480
 
471
481
  ## [0.48.4](https://github.com/carbon-design-system/carbon-charts/compare/v0.48.3...v0.48.4) (2021-09-13)
472
482
 
package/README.md CHANGED
@@ -1,10 +1,6 @@
1
- # Notice
1
+ # Carbon Charts Svelte
2
2
 
3
- ### This version relies on **Carbon v11**. If you're using Carbon v10, [see the legacy demo site](https://carbon-charts-0x.netlify.app)
4
-
5
- ## `@carbon/charts-svelte`
6
-
7
- > Carbon Charting Svelte Wrappers
3
+ Carbon Charts Svelte is a thin Svelte wrapper around the vanilla JavScript `@carbon/charts` component library. The charts are based on D3.js, a peer dependency. Documentation is provided below and in the Storybook demos.
8
4
 
9
5
  **[Storybook demos](https://carbon-design-system.github.io/carbon-charts/svelte)**
10
6
 
@@ -12,124 +8,78 @@
12
8
 
13
9
  ## Maintenance & support
14
10
 
15
- These Svelte wrappers have been developed by Eric Liu.
11
+ These Svelte wrappers were developed by Eric Liu.
16
12
 
17
- Please direct all questions regarding support, bug fixes, and feature requests
18
- to [@metonym](https://github.com/metonym).
13
+ Please direct all questions regarding support, bug fixes, and feature requests to [@metonym](https://github.com/metonym).
19
14
 
20
15
  ## Getting started
21
16
 
22
17
  Run the following command using [npm](https://www.npmjs.com/):
23
18
 
24
19
  ```bash
25
- npm install -D @carbon/charts-svelte d3
20
+ npm install -D @carbon/charts-svelte @carbon/styles d3
26
21
  ```
27
22
 
28
- If you prefer [Yarn](https://yarnpkg.com/en/), use the following command
29
- instead:
23
+ If you prefer [Yarn](https://yarnpkg.com/en/), use the following command instead:
30
24
 
31
25
  ```bash
32
- yarn add -D @carbon/charts-svelte d3
26
+ yarn add -D @carbon/charts-svelte @carbon/styles d3
33
27
  ```
34
28
 
35
- **Note:** you'd also need to install `carbon-components` if you're not using a
36
- bundled version of the library.
37
-
38
- ## Set-up
29
+ ## Setup
39
30
 
40
- This is an overview of using Carbon Charts with common Svelte set-ups.
31
+ This is an overview of using Carbon Charts with common Svelte setups.
41
32
 
42
- - [SvelteKit](#sveltekit)
43
- - [Vite](#vite)
44
- - [Rollup](#rollup)
45
- - [Webpack](#webpack)
33
+ - [SvelteKit](#sveltekit)
34
+ - [Vite](#vite)
46
35
 
47
36
  ### SvelteKit
48
37
 
49
- [SvelteKit](https://github.com/sveltejs/kit) is the official framework for
50
- building apps that support client-side rendering (CSR) and server-side rendering
51
- (SSR). SvelteKit is powered by [Vite](https://github.com/vitest-dev/vitest).
38
+ [SvelteKit](https://github.com/sveltejs/kit) is the official framework for building apps that
39
+ support client-side rendering (CSR) and server-side rendering (SSR). SvelteKit is powered by
40
+ [Vite](https://github.com/vitest-dev/vitest).
52
41
 
53
- `@carbon/charts` and `carbon-components` should not be externalized for SSR when
54
- building for production.
42
+ Modules `@carbon/charts` and `carbon-components` should not be externalized for SSR when building for production.
55
43
 
56
44
  ```js
57
45
  // vite.config.js
58
- import { sveltekit } from '@sveltejs/kit/vite';
46
+ import { sveltekit } from '@sveltejs/kit/vite'
59
47
 
60
48
  /** @type {import('vite').UserConfig} */
61
- export default {
49
+ const config = {
62
50
  plugins: [sveltekit()],
63
51
  ssr: {
64
- noExternal:
65
- process.env.NODE_ENV === 'production'
66
- ? ['@carbon/charts', 'carbon-components']
67
- : [],
68
- },
69
- };
52
+ noExternal: process.env.NODE_ENV === 'production' ? ['@carbon/charts', 'carbon-components'] : []
53
+ }
54
+ }
55
+
56
+ export default config
70
57
  ```
71
58
 
72
59
  ### Vite
73
60
 
74
- You can also use Vite without SvelteKit. Instruct `vite` to optimize
75
- `@carbon/charts` in `vite.config.js`.
61
+ You can also use Vite without SvelteKit. Instruct `vite` to optimize `@carbon/charts` in
62
+ `vite.config.js`.
76
63
 
77
64
  ```js
78
65
  // vite.config.js
79
- import { svelte } from '@sveltejs/vite-plugin-svelte';
66
+ import { svelte } from '@sveltejs/vite-plugin-svelte'
80
67
 
81
68
  /** @type {import('vite').UserConfig} */
82
- export default {
69
+ const config = {
83
70
  plugins: [svelte()],
84
- optimizeDeps: { include: ['@carbon/charts'] },
85
- };
86
- ```
87
-
88
- ### Rollup
89
-
90
- #### ReferenceError: process is not defined
91
-
92
- Install and add
93
- [@rollup/plugin-replace](https://github.com/rollup/plugins/tree/master/packages/replace)
94
- to the list of plugins in `rollup.config.js` to avoid the
95
- `process is not defined` runtime error.
96
-
97
- This plugin statically replaces strings in bundled files with the specified
98
- value.
99
-
100
- In the example below, all instances of `process.env.NODE_ENV` will be replaced
101
- with `"production"` while bundling.
102
-
103
- ```js
104
- // rollup.config.js
105
- import replace from '@rollup/plugin-replace';
106
-
107
- export default {
108
- // ...
109
- plugins: [
110
- replace({
111
- preventAssignment: true,
112
- 'process.env.NODE_ENV': JSON.stringify('production'),
113
- }),
114
- ],
115
- };
116
- ```
117
-
118
- #### `this` has been rewritten to `undefined`
119
-
120
- Set [`context: "window"`](https://rollupjs.org/guide/en/#context) to address the
121
- `this has been rewritten to undefined` Rollup error.
71
+ optimizeDeps: {
72
+ include: ['@carbon/charts', 'carbon-components'],
73
+ exclude: ['@carbon/telemetry']
74
+ }
75
+ }
122
76
 
123
- ```diff
124
- export default {
125
- + context: "window",
126
- };
77
+ export default config
127
78
  ```
128
79
 
129
80
  #### Circular dependency warnings
130
81
 
131
- You may see circular dependency warnings for `d3` and `@carbon/charts` packages
132
- that can be safely ignored.
82
+ You may see circular dependency warnings for `d3` and `@carbon/charts` packages that can be safely ignored.
133
83
 
134
84
  Use the `onwarn` option to selectively ignore these warnings.
135
85
 
@@ -140,101 +90,64 @@ export default {
140
90
  // omit circular dependency warnings emitted from
141
91
  // "d3-*" packages and "@carbon/charts"
142
92
  if (warning.code === 'CIRCULAR_DEPENDENCY') {
143
- if (
144
- warning.ids.some((id) =>
145
- /node_modules\/(d3-|@carbon\/charts)/.test(id)
146
- )
147
- ) {
148
- return;
93
+ if (warning.ids.some((id) => /node_modules\/(d3-|@carbon\/charts)/.test(id))) {
94
+ return
149
95
  }
150
96
  }
151
97
 
152
98
  // preserve all other warnings
153
- warn(warning);
154
- },
155
- };
156
- ```
157
-
158
- #### Code-splitting
159
-
160
- If using [dynamic imports](https://rollupjs.org/guide/en/#dynamic-import), use
161
- `type="module"` alongside `output.dir` for code-splitting.
162
-
163
- ```diff
164
- # index.html
165
- - <script src="build/bundle.js"></script>
166
- + <script type="module" src="build/index.js"></script>
167
- ```
168
-
169
- ```diff
170
- # rollup.config.js
171
- export default {
172
- output: {
173
- - format: "iife",
174
- - file: "public/build/bundle.js",
175
- + dir: "public/build",
176
- }
99
+ warn(warning)
100
+ }
177
101
  }
178
102
  ```
179
103
 
180
- ### Webpack
181
-
182
- [Webpack](https://github.com/webpack/webpack) is another popular application
183
- bundler used to build Svelte apps.
184
-
185
- No additional configuration should be necessary.
186
-
187
104
  ## Usage
188
105
 
189
- Styles must be imported from both `@carbon/charts` and `@carbon/styles`.
106
+ Styles must be imported from both `@carbon/charts-svelte` and `@carbon/styles`.
190
107
 
191
108
  ```js
192
- import '@carbon/styles/css/styles.css';
193
- import '@carbon/charts/styles.css';
109
+ import '@carbon/styles/css/styles.css'
110
+ import '@carbon/charts-svelte/styles.css'
194
111
  ```
195
112
 
196
113
  ### Basic
197
114
 
198
115
  ```svelte
199
116
  <script>
200
- import "@carbon/styles/css/styles.css";
201
- import "@carbon/charts/styles.css";
202
- import { BarChartSimple } from "@carbon/charts-svelte";
117
+ import '@carbon/styles/css/styles.css'
118
+ import '@carbon/charts-svelte/styles.css'
119
+ import { BarChartSimple } from '@carbon/charts-svelte'
203
120
  </script>
204
121
 
205
122
  <BarChartSimple
206
- data={[
207
- { group: "Qty", value: 65000 },
208
- { group: "More", value: 29123 },
209
- { group: "Sold", value: 35213 },
210
- { group: "Restocking", value: 51213 },
211
- { group: "Misc", value: 16932 },
212
- ]}
213
- options={{
214
- title: "Simple bar (discrete)",
215
- height: "400px",
216
- axes: {
217
- left: { mapsTo: "value" },
218
- bottom: { mapsTo: "group", scaleType: "labels" },
219
- },
220
- }}
221
- />
222
-
123
+ data={[
124
+ { group: 'Qty', value: 65000 },
125
+ { group: 'More', value: 29123 },
126
+ { group: 'Sold', value: 35213 },
127
+ { group: 'Restocking', value: 51213 },
128
+ { group: 'Misc', value: 16932 }
129
+ ]}
130
+ options={{
131
+ title: 'Simple bar (discrete)',
132
+ height: '400px',
133
+ axes: {
134
+ left: { mapsTo: 'value' },
135
+ bottom: { mapsTo: 'group', scaleType: 'labels' }
136
+ }
137
+ }} />
223
138
  ```
224
139
 
225
140
  ### Theming
226
141
 
227
142
  `@carbon/styles` uses
228
- [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
229
- for dynamic, client-side theming. Update the Carbon theme using the `theme`
230
- prop.
143
+ [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for dynamic, client-side theming. Update the Carbon theme using the `theme` prop.
231
144
 
232
145
  Supported themes include:
233
146
 
234
- - `"white"`
235
- - `"g10"` (Gray 10)
236
- - `"g90"` (Gray 90)
237
- - `"g100"` (Gray 100)
147
+ - `"white"`
148
+ - `"g10"` (Gray 10)
149
+ - `"g90"` (Gray 90)
150
+ - `"g100"` (Gray 100)
238
151
 
239
152
  The default theme is `"white"`.
240
153
 
@@ -250,20 +163,12 @@ The default theme is `"white"`.
250
163
 
251
164
  Each Svelte chart component dispatches the following events:
252
165
 
253
- - **on:load**: fired when the chart is instantiated
254
- - **on:update**: fired when `data` or `options` are updated
255
- - **on:destroy**: fired when the component is unmounted and the chart is
256
- destroyed
166
+ - **on:load**: fired when the chart is instantiated
167
+ - **on:update**: fired when `data` or `options` are updated
168
+ - **on:destroy**: fired when the component is unmounted and the chart is destroyed
257
169
 
258
170
  ```svelte
259
- <BarChartSimple
260
- {data}
261
- {options}
262
- on:load
263
- on:update
264
- on:destroy
265
- />
266
-
171
+ <BarChartSimple {data} {options} on:load on:update on:destroy />
267
172
  ```
268
173
 
269
174
  ### Dynamic import
@@ -273,109 +178,98 @@ Dynamically import a chart and instantiate it using the
273
178
 
274
179
  ```svelte
275
180
  <script>
276
- import "@carbon/styles/css/styles.css";
277
- import "@carbon/charts/styles.css";
278
- import { onMount } from "svelte";
181
+ import '@carbon/styles/css/styles.css'
182
+ import '@carbon/charts-svelte/styles.css'
183
+ import { onMount } from 'svelte'
279
184
 
280
- let chart;
185
+ let chart
281
186
 
282
- onMount(async () => {
283
- const charts = await import("@carbon/charts-svelte");
284
- chart = charts.BarChartSimple;
285
- });
187
+ onMount(async () => {
188
+ const charts = await import('@carbon/charts-svelte')
189
+ chart = charts.BarChartSimple
190
+ })
286
191
  </script>
287
192
 
288
193
  <svelte:component
289
- this={chart}
290
- data={[
291
- { group: "Qty", value: 65000 },
292
- { group: "More", value: 29123 },
293
- { group: "Sold", value: 35213 },
294
- { group: "Restocking", value: 51213 },
295
- { group: "Misc", value: 16932 },
296
- ]}
297
- options={{
298
- title: "Simple bar (discrete)",
299
- height: "400px",
300
- axes: {
301
- left: { mapsTo: "value" },
302
- bottom: { mapsTo: "group", scaleType: "labels" },
303
- },
304
- }}
305
- />
306
-
194
+ this={chart}
195
+ data={[
196
+ { group: 'Qty', value: 65000 },
197
+ { group: 'More', value: 29123 },
198
+ { group: 'Sold', value: 35213 },
199
+ { group: 'Restocking', value: 51213 },
200
+ { group: 'Misc', value: 16932 }
201
+ ]}
202
+ options={{
203
+ title: 'Simple bar (discrete)',
204
+ height: '400px',
205
+ axes: {
206
+ left: { mapsTo: 'value' },
207
+ bottom: { mapsTo: 'group', scaleType: 'labels' }
208
+ }
209
+ }} />
307
210
  ```
308
211
 
309
212
  ### Event listeners
310
213
 
311
- In this example, an event listener is attached to the `BarChartSimple` component
312
- that fires when hovering over a bar.
214
+ In this example, an event listener is attached to the `BarChartSimple` component that fires when hovering over a bar.
313
215
 
314
216
  ```svelte
315
217
  <script>
316
- import "@carbon/styles/css/styles.css";
317
- import "@carbon/charts/styles.css";
318
- import { onMount } from "svelte";
319
- import { BarChartSimple } from "@carbon/charts-svelte";
218
+ import '@carbon/styles/css/styles.css'
219
+ import '@carbon/charts-svelte/styles.css'
220
+ import { onMount } from 'svelte'
221
+ import { BarChartSimple } from '@carbon/charts-svelte'
320
222
 
321
- let chart;
223
+ let chart
322
224
 
323
- function barMouseOver(e) {
324
- console.log(e.detail);
325
- }
225
+ function barMouseOver(e) {
226
+ console.log(e.detail)
227
+ }
326
228
 
327
- onMount(() => {
328
- return () => {
329
- if (chart) chart.services.events.removeEventListener("bar-mouseover", barMouseOver);
330
- };
331
- });
229
+ onMount(() => {
230
+ return () => {
231
+ if (chart) chart.services.events.removeEventListener('bar-mouseover', barMouseOver)
232
+ }
233
+ })
332
234
 
333
- $: if (chart) chart.services.events.addEventListener("bar-mouseover", barMouseOver);
235
+ $: if (chart) chart.services.events.addEventListener('bar-mouseover', barMouseOver)
334
236
  </script>
335
237
 
336
238
  <BarChartSimple
337
- bind:chart
338
- data={[
339
- { group: "Qty", value: 65000 },
340
- { group: "More", value: 29123 },
341
- { group: "Sold", value: 35213 },
342
- { group: "Restocking", value: 51213 },
343
- { group: "Misc", value: 16932 },
344
- ]}
345
- options={{
346
- title: "Simple bar (discrete)",
347
- height: "400px",
348
- axes: {
349
- left: { mapsTo: "value" },
350
- bottom: { mapsTo: "group", scaleType: "labels" },
351
- },
352
- }}
353
- />
354
-
239
+ bind:chart
240
+ data={[
241
+ { group: 'Qty', value: 65000 },
242
+ { group: 'More', value: 29123 },
243
+ { group: 'Sold', value: 35213 },
244
+ { group: 'Restocking', value: 51213 },
245
+ { group: 'Misc', value: 16932 }
246
+ ]}
247
+ options={{
248
+ title: 'Simple bar (discrete)',
249
+ height: '400px',
250
+ axes: {
251
+ left: { mapsTo: 'value' },
252
+ bottom: { mapsTo: 'group', scaleType: 'labels' }
253
+ }
254
+ }} />
355
255
  ```
356
256
 
357
- ## Codesandbox examples
257
+ ## CodeSandbox examples
358
258
 
359
259
  [Sample use cases can be seen here](https://carbon-design-system.github.io/carbon-charts/svelte).
360
260
 
361
- **When opening the link above**, click on the **Edit on Codesandbox** button for
362
- each demo to see an isolated project showing you how to reproduce the demo.
261
+ **When opening the link above**, click on the **Edit on Codesandbox** button for each demo to see an isolated project showing you how to reproduce the demo.
363
262
 
364
263
  ## Charting data & options
365
264
 
366
- Although we will definitely introduce new models in the future as we start
367
- shipping new components such as maps, Data and options follow the same model in
368
- all charts, with minor exceptions and differences in specific components.
265
+ Although we will definitely introduce new models in the future as we start shipping new components such as maps, Data and options follow the same model in all charts, with minor exceptions and differences in specific components.
369
266
 
370
- For instance in the case of a donut chart you're able to pass in an additional
371
- field called `center` in your options configuring the donut center.
267
+ For instance, in the case of a donut chart, you're able to pass in an additional field called `center` in your options configuring the donut center.
372
268
 
373
269
  For instructions on using the **tabular data format**, see
374
270
  [here](https://carbon-design-system.github.io/carbon-charts/?path=/story/docs-tutorials--tabular-data-format)
375
271
 
376
- There are also additional options available depending on the chart type being
377
- used,
378
- [see our demo examples here](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/demo/data).
272
+ There are additional options available depending on the chart type being used, [see our demo examples here](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/core/demo/data).
379
273
 
380
274
  Customizable options (specific to chart type) can be found
381
275
  [here](https://carbon-design-system.github.io/carbon-charts/documentation/modules/_interfaces_charts_.html)
@@ -383,5 +277,3 @@ Customizable options (specific to chart type) can be found
383
277
  ## TypeScript support
384
278
 
385
279
  Svelte version 3.31 or greater is required to use this library with TypeScript.
386
-
387
- TypeScript definitions are located in the [types folder](types/).
@@ -0,0 +1,20 @@
1
+ <script>import {
2
+ AlluvialChart as AlluvialChartCore
3
+ } from "@carbon/charts";
4
+ import BaseChart from "./BaseChart.svelte";
5
+ export let chart;
6
+ export let options;
7
+ export let data;
8
+ export let ref;
9
+ </script>
10
+
11
+ <BaseChart
12
+ {...$$restProps}
13
+ Chart={AlluvialChartCore}
14
+ {options}
15
+ {data}
16
+ bind:ref
17
+ bind:chart
18
+ on:load
19
+ on:update
20
+ on:destroy />
@@ -0,0 +1,25 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import { AlluvialChart as AlluvialChartCore, AlluvialChartOptions, ChartTabularData } from '@carbon/charts';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ chart: AlluvialChartCore;
7
+ options: AlluvialChartOptions;
8
+ data: ChartTabularData;
9
+ ref: HTMLDivElement;
10
+ };
11
+ events: {
12
+ load: CustomEvent<any>;
13
+ update: CustomEvent<any>;
14
+ destroy: CustomEvent<any>;
15
+ } & {
16
+ [evt: string]: CustomEvent<any>;
17
+ };
18
+ slots: {};
19
+ };
20
+ export type AlluvialChartProps = typeof __propDef.props;
21
+ export type AlluvialChartEvents = typeof __propDef.events;
22
+ export type AlluvialChartSlots = typeof __propDef.slots;
23
+ export default class AlluvialChart extends SvelteComponentTyped<AlluvialChartProps, AlluvialChartEvents, AlluvialChartSlots> {
24
+ }
25
+ export {};
@@ -0,0 +1,20 @@
1
+ <script>import {
2
+ AreaChart as AreaChartCore
3
+ } from "@carbon/charts";
4
+ import BaseChart from "./BaseChart.svelte";
5
+ export let chart;
6
+ export let options;
7
+ export let data;
8
+ export let ref;
9
+ </script>
10
+
11
+ <BaseChart
12
+ {...$$restProps}
13
+ Chart={AreaChartCore}
14
+ {options}
15
+ {data}
16
+ bind:ref
17
+ bind:chart
18
+ on:load
19
+ on:update
20
+ on:destroy />
@@ -0,0 +1,25 @@
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import { AreaChart as AreaChartCore, AreaChartOptions, ChartTabularData } from '@carbon/charts';
3
+ declare const __propDef: {
4
+ props: {
5
+ [x: string]: any;
6
+ chart: AreaChartCore;
7
+ options: AreaChartOptions;
8
+ data: ChartTabularData;
9
+ ref: HTMLDivElement;
10
+ };
11
+ events: {
12
+ load: CustomEvent<any>;
13
+ update: CustomEvent<any>;
14
+ destroy: CustomEvent<any>;
15
+ } & {
16
+ [evt: string]: CustomEvent<any>;
17
+ };
18
+ slots: {};
19
+ };
20
+ export type AreaChartProps = typeof __propDef.props;
21
+ export type AreaChartEvents = typeof __propDef.events;
22
+ export type AreaChartSlots = typeof __propDef.slots;
23
+ export default class AreaChart extends SvelteComponentTyped<AreaChartProps, AreaChartEvents, AreaChartSlots> {
24
+ }
25
+ export {};
@@ -0,0 +1,20 @@
1
+ <script>import {
2
+ GroupedBarChart as GroupedBarChartCore
3
+ } from "@carbon/charts";
4
+ import BaseChart from "./BaseChart.svelte";
5
+ export let chart;
6
+ export let options;
7
+ export let data;
8
+ export let ref;
9
+ </script>
10
+
11
+ <BaseChart
12
+ {...$$restProps}
13
+ Chart={GroupedBarChartCore}
14
+ {options}
15
+ {data}
16
+ bind:ref
17
+ bind:chart
18
+ on:load
19
+ on:update
20
+ on:destroy />