@carbon/charts-svelte 1.13.8 → 1.13.11

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,37 @@
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.13.11 (2023-12-18)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **svelte:** strongly type dispatched events
11
+ ([#1703](https://github.com/carbon-design-system/carbon-charts/issues/1703))
12
+ ([1a37ef2](https://github.com/carbon-design-system/carbon-charts/commit/1a37ef2be692400b257446f62d1350899e27dd59))
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
+
19
+ ## 1.13.10 (2023-12-18)
20
+
21
+ **Note:** Version bump only for package @carbon/charts-svelte
22
+
23
+ # Change Log
24
+
25
+ All notable changes to this project will be documented in this file. See
26
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
27
+
28
+ ## 1.13.9 (2023-12-06)
29
+
30
+ **Note:** Version bump only for package @carbon/charts-svelte
31
+
32
+ # Change Log
33
+
34
+ All notable changes to this project will be documented in this file. See
35
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
36
+
6
37
  ## 1.13.8 (2023-11-15)
7
38
 
8
39
  **Note:** Version bump only for package @carbon/charts-svelte
package/README.md CHANGED
@@ -54,7 +54,7 @@ You may see circular dependency warnings for `d3` packages. These can be safely
54
54
 
55
55
  ## Usage
56
56
 
57
- Styles must be imported from `@carbon/charts-svelte`.
57
+ Styles must be imported from `@carbon/charts-svelte/styles.css`.
58
58
 
59
59
  ```js
60
60
  import '@carbon/charts-svelte/styles.css'
@@ -87,11 +87,6 @@ import '@carbon/charts-svelte/styles.css'
87
87
  }} />
88
88
  ```
89
89
 
90
- ### Theming
91
-
92
- `@carbon/styles` uses
93
- [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for dynamic, client-side theming. Care should be exercised as the styles apply to the HTML body.
94
-
95
90
  ### Dispatched events
96
91
 
97
92
  Each Svelte chart component dispatches the following events:
@@ -150,7 +145,7 @@ In this example, an event listener is attached to the `BarChartSimple` component
150
145
  ```svelte
151
146
  <script>
152
147
  import '@carbon/charts-svelte/styles.css'
153
- import { onDestroy, onMount } from 'svelte'
148
+ import { onMount } from 'svelte'
154
149
  import { BarChartSimple } from '@carbon/charts-svelte'
155
150
 
156
151
  let chart
@@ -160,16 +155,12 @@ In this example, an event listener is attached to the `BarChartSimple` component
160
155
  }
161
156
 
162
157
  onMount(() => {
163
- // do something
164
- })
158
+ chart.services.events.addEventListener('bar-mouseover', barMouseOver)
165
159
 
166
- onDestroy(() => {
167
- if (chart) {
168
- chart.services.events.removeEventListener('bar-mouseover', barMouseOver)
160
+ return () => {
161
+ chart?.services.events.removeEventListener('bar-mouseover', barMouseOver)
169
162
  }
170
163
  })
171
-
172
- $: if (chart) chart.services.events.addEventListener('bar-mouseover', barMouseOver)
173
164
  </script>
174
165
 
175
166
  <BarChartSimple
@@ -211,3 +202,58 @@ Customizable options (specific to chart type) can be found
211
202
  ## TypeScript support
212
203
 
213
204
  Svelte version 3.31 or greater is required to use this library with TypeScript. Svelte 4.x+ is recommended.
205
+
206
+ ### Enums and types
207
+
208
+ For your convenience, enums and types from `@carbon/charts` are re-exported from
209
+ `@carbon/charts-svelte`.
210
+
211
+ ```ts
212
+ import { ScaleTypes, type BarChartOptions } from '@carbon/charts-svelte'
213
+
214
+ const options: BarChartOptions = {
215
+ title: 'Simple bar (discrete)',
216
+ height: '400px',
217
+ axes: {
218
+ left: { mapsTo: 'value' },
219
+ bottom: {
220
+ mapsTo: 'group',
221
+ scaleType: ScaleTypes.LABELS
222
+ }
223
+ }
224
+ }
225
+ ```
226
+
227
+ ### Component type
228
+
229
+ Use the `ComponentType` utility type from `svelte` to extract the component type for chart
230
+ components.
231
+
232
+ ```ts
233
+ import { onMount, type ComponentType } from 'svelte'
234
+ import type { BarChartSimple } from '@carbon/charts-svelte'
235
+
236
+ let component: ComponentType<BarChartSimple> = null
237
+
238
+ onMount(async () => {
239
+ component = (await import('@carbon/charts-svelte')).BarChartSimple
240
+ })
241
+ ```
242
+
243
+ ### Component props
244
+
245
+ Use the `ComponentProps` utility type from `svelte` to extract the props for chart components.
246
+
247
+ You can then use an
248
+ [indexed access type](https://www.typescriptlang.org/docs/handbook/2/indexed-access-types.html) to
249
+ extract types for individual properties.
250
+
251
+ ```ts
252
+ import { type ComponentProps } from 'svelte'
253
+ import { BarChartSimple } from '@carbon/charts-svelte'
254
+
255
+ type ChartProps = ComponentProps<BarChartSimple>
256
+
257
+ // Indexed access type to access the type of the `chart` property
258
+ let chart: ChartProps['chart'] = null
259
+ ```
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -14,9 +14,12 @@ declare const __propDef: {
14
14
  id?: string;
15
15
  };
16
16
  events: {
17
- load: CustomEvent<any>;
18
- update: CustomEvent<any>;
19
- destroy: CustomEvent<any>;
17
+ load: CustomEvent<null>;
18
+ update: CustomEvent<{
19
+ data: ChartTabularData;
20
+ options: ChartOptions;
21
+ }>;
22
+ destroy: CustomEvent<null>;
20
23
  } & {
21
24
  [evt: string]: CustomEvent<any>;
22
25
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };
@@ -9,9 +9,12 @@ declare const __propDef: {
9
9
  ref?: HTMLDivElement | null;
10
10
  };
11
11
  events: {
12
- load: CustomEvent<any>;
13
- update: CustomEvent<any>;
14
- destroy: CustomEvent<any>;
12
+ load: CustomEvent<null>;
13
+ update: CustomEvent<{
14
+ data: ChartTabularData;
15
+ options: import("@carbon/charts").ChartOptions;
16
+ }>;
17
+ destroy: CustomEvent<null>;
15
18
  } & {
16
19
  [evt: string]: CustomEvent<any>;
17
20
  };