@carbon/charts-svelte 1.22.16 → 1.22.18

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 (59) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -2
  3. package/dist/AlluvialChart.svelte +6 -11
  4. package/dist/AlluvialChart.svelte.d.ts +34 -31
  5. package/dist/AreaChart.svelte +6 -11
  6. package/dist/AreaChart.svelte.d.ts +34 -31
  7. package/dist/BarChartGrouped.svelte +6 -11
  8. package/dist/BarChartGrouped.svelte.d.ts +34 -31
  9. package/dist/BarChartSimple.svelte +6 -11
  10. package/dist/BarChartSimple.svelte.d.ts +34 -31
  11. package/dist/BarChartStacked.svelte +6 -10
  12. package/dist/BarChartStacked.svelte.d.ts +34 -31
  13. package/dist/BaseChart.svelte +9 -24
  14. package/dist/BaseChart.svelte.d.ts +31 -35
  15. package/dist/BoxplotChart.svelte +6 -11
  16. package/dist/BoxplotChart.svelte.d.ts +34 -31
  17. package/dist/BubbleChart.svelte +6 -11
  18. package/dist/BubbleChart.svelte.d.ts +34 -31
  19. package/dist/BulletChart.svelte +6 -11
  20. package/dist/BulletChart.svelte.d.ts +34 -31
  21. package/dist/ChoroplethChart.svelte +6 -11
  22. package/dist/ChoroplethChart.svelte.d.ts +34 -31
  23. package/dist/CirclePackChart.svelte +6 -11
  24. package/dist/CirclePackChart.svelte.d.ts +34 -31
  25. package/dist/ComboChart.svelte +6 -11
  26. package/dist/ComboChart.svelte.d.ts +34 -31
  27. package/dist/DonutChart.svelte +6 -11
  28. package/dist/DonutChart.svelte.d.ts +34 -31
  29. package/dist/GaugeChart.svelte +6 -11
  30. package/dist/GaugeChart.svelte.d.ts +34 -31
  31. package/dist/HeatmapChart.svelte +6 -11
  32. package/dist/HeatmapChart.svelte.d.ts +34 -31
  33. package/dist/HistogramChart.svelte +6 -11
  34. package/dist/HistogramChart.svelte.d.ts +34 -31
  35. package/dist/LineChart.svelte +6 -11
  36. package/dist/LineChart.svelte.d.ts +34 -31
  37. package/dist/LollipopChart.svelte +6 -11
  38. package/dist/LollipopChart.svelte.d.ts +34 -31
  39. package/dist/MeterChart.svelte +6 -11
  40. package/dist/MeterChart.svelte.d.ts +34 -31
  41. package/dist/PieChart.svelte +6 -11
  42. package/dist/PieChart.svelte.d.ts +34 -31
  43. package/dist/RadarChart.svelte +6 -11
  44. package/dist/RadarChart.svelte.d.ts +34 -31
  45. package/dist/ScatterChart.svelte +6 -11
  46. package/dist/ScatterChart.svelte.d.ts +34 -31
  47. package/dist/StackedAreaChart.svelte +6 -11
  48. package/dist/StackedAreaChart.svelte.d.ts +34 -31
  49. package/dist/TreeChart.svelte +6 -11
  50. package/dist/TreeChart.svelte.d.ts +34 -31
  51. package/dist/TreemapChart.svelte +6 -11
  52. package/dist/TreemapChart.svelte.d.ts +34 -31
  53. package/dist/WordCloudChart.svelte +6 -12
  54. package/dist/WordCloudChart.svelte.d.ts +35 -31
  55. package/dist/index.d.ts +141 -36
  56. package/dist/index.js +109 -31
  57. package/dist/styles.css +4458 -4357
  58. package/dist/styles.min.css +6900 -1
  59. package/package.json +14 -10
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.22.18 (2025-02-18)
7
+
8
+ **Note:** Version bump only for package @carbon/charts-svelte
9
+
10
+ # Change Log
11
+
12
+ All notable changes to this project will be documented in this file. See
13
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
14
+
15
+ ## 1.22.17 (2025-02-12)
16
+
17
+ ### Bug Fixes
18
+
19
+ - **stackblitz:** react examples
20
+ ([#1957](https://github.com/carbon-design-system/carbon-charts/issues/1957))
21
+ ([1427786](https://github.com/carbon-design-system/carbon-charts/commit/14277866a0933eb99b1097818d4611cc140b9da2))
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
+
6
28
  ## 1.22.16 (2025-02-10)
7
29
 
8
30
  **Note:** Version bump only for package @carbon/charts-svelte
package/README.md CHANGED
@@ -42,6 +42,8 @@ yarn add -D @carbon/charts-svelte
42
42
 
43
43
  The required styles should be imported from `@carbon/charts-svelte/styles.css`.
44
44
 
45
+ A release in the near future will move components to runes mode for Svelte 5 and beyond. As this would be a breaking change because event handlers will change to component properties, this version will be published with the distribution tag `next`. Please check <a href="https://www.npmjs.com/package/@carbon/charts-svelte?activeTab=versions">here</a> to see if a version for `latest` has been published.
46
+
45
47
  ### SvelteKit
46
48
 
47
49
  While this component library can be used with any build environments for Svelte,
@@ -200,9 +202,9 @@ hovering over a bar.
200
202
  }} />
201
203
  ```
202
204
 
203
- ## TypeScript support
205
+ ## Svelte and TypeScript support
204
206
 
205
- Svelte version 3.31 or greater is required to use this library with TypeScript. Svelte 4.x+ is
207
+ Svelte 3.31 or greater is required to use this library with TypeScript. Svelte 5.20+ is
206
208
  recommended.
207
209
 
208
210
  ### Enums and types
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- AlluvialChart as AlluvialChartCore,
4
- type AlluvialChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { AlluvialChart as AlluvialChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
-
9
- export let options: AlluvialChartOptions
10
- export let data: ChartTabularData
11
- export let chart: AlluvialChartCore | undefined = undefined
12
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
13
8
  </script>
14
9
 
15
10
  <BaseChart
@@ -1,32 +1,35 @@
1
- import { AlluvialChart as AlluvialChartCore, type AlluvialChartOptions, type ChartTabularData } from '@carbon/charts';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import {
3
+ AlluvialChart as AlluvialChartCore,
4
+ type AlluvialChartOptions,
5
+ type ChartTabularData
6
+ } from '@carbon/charts'
7
+ declare const __propDef: {
8
+ props: {
9
+ [x: string]: any
10
+ options: AlluvialChartOptions
11
+ data: ChartTabularData
12
+ chart?: AlluvialChartCore | undefined
13
+ ref?: HTMLDivElement | undefined
14
+ }
15
+ events: {
16
+ load: CustomEvent<null>
17
+ update: CustomEvent<{
18
+ data: ChartTabularData
19
+ options: import('@carbon/charts').BaseChartOptions
20
+ }>
21
+ destroy: CustomEvent<null>
22
+ } & {
23
+ [evt: string]: CustomEvent<any>
24
+ }
25
+ slots: {}
14
26
  }
15
- declare const AlluvialChart: $$__sveltets_2_IsomorphicComponent<{
16
- [x: string]: any;
17
- options: AlluvialChartOptions;
18
- data: ChartTabularData;
19
- chart?: AlluvialChartCore | undefined;
20
- ref?: HTMLDivElement | undefined;
21
- }, {
22
- load: CustomEvent<null>;
23
- update: CustomEvent<{
24
- data: ChartTabularData;
25
- options: import("@carbon/charts").BaseChartOptions;
26
- }>;
27
- destroy: CustomEvent<null>;
28
- } & {
29
- [evt: string]: CustomEvent<any>;
30
- }, {}, {}, string>;
31
- type AlluvialChart = InstanceType<typeof AlluvialChart>;
32
- export default AlluvialChart;
27
+ export type AlluvialChartProps = typeof __propDef.props
28
+ export type AlluvialChartEvents = typeof __propDef.events
29
+ export type AlluvialChartSlots = typeof __propDef.slots
30
+ export default class AlluvialChart extends SvelteComponentTyped<
31
+ AlluvialChartProps,
32
+ AlluvialChartEvents,
33
+ AlluvialChartSlots
34
+ > {}
35
+ export {}
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- AreaChart as AreaChartCore,
4
- type AreaChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { AreaChart as AreaChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
-
9
- export let options: AreaChartOptions
10
- export let data: ChartTabularData
11
- export let chart: AreaChartCore | undefined = undefined
12
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
13
8
  </script>
14
9
 
15
10
  <BaseChart
@@ -1,32 +1,35 @@
1
- import { AreaChart as AreaChartCore, type AreaChartOptions, type ChartTabularData } from '@carbon/charts';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import {
3
+ AreaChart as AreaChartCore,
4
+ type AreaChartOptions,
5
+ type ChartTabularData
6
+ } from '@carbon/charts'
7
+ declare const __propDef: {
8
+ props: {
9
+ [x: string]: any
10
+ options: AreaChartOptions
11
+ data: ChartTabularData
12
+ chart?: AreaChartCore | undefined
13
+ ref?: HTMLDivElement | undefined
14
+ }
15
+ events: {
16
+ load: CustomEvent<null>
17
+ update: CustomEvent<{
18
+ data: ChartTabularData
19
+ options: import('@carbon/charts').BaseChartOptions
20
+ }>
21
+ destroy: CustomEvent<null>
22
+ } & {
23
+ [evt: string]: CustomEvent<any>
24
+ }
25
+ slots: {}
14
26
  }
15
- declare const AreaChart: $$__sveltets_2_IsomorphicComponent<{
16
- [x: string]: any;
17
- options: AreaChartOptions;
18
- data: ChartTabularData;
19
- chart?: AreaChartCore | undefined;
20
- ref?: HTMLDivElement | undefined;
21
- }, {
22
- load: CustomEvent<null>;
23
- update: CustomEvent<{
24
- data: ChartTabularData;
25
- options: import("@carbon/charts").BaseChartOptions;
26
- }>;
27
- destroy: CustomEvent<null>;
28
- } & {
29
- [evt: string]: CustomEvent<any>;
30
- }, {}, {}, string>;
31
- type AreaChart = InstanceType<typeof AreaChart>;
32
- export default AreaChart;
27
+ export type AreaChartProps = typeof __propDef.props
28
+ export type AreaChartEvents = typeof __propDef.events
29
+ export type AreaChartSlots = typeof __propDef.slots
30
+ export default class AreaChart extends SvelteComponentTyped<
31
+ AreaChartProps,
32
+ AreaChartEvents,
33
+ AreaChartSlots
34
+ > {}
35
+ export {}
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- GroupedBarChart as GroupedBarChartCore,
4
- type BarChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { GroupedBarChart as GroupedBarChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
-
9
- export let options: BarChartOptions
10
- export let data: ChartTabularData
11
- export let chart: GroupedBarChartCore | undefined = undefined
12
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
13
8
  </script>
14
9
 
15
10
  <BaseChart
@@ -1,32 +1,35 @@
1
- import { GroupedBarChart as GroupedBarChartCore, type BarChartOptions, type ChartTabularData } from '@carbon/charts';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import {
3
+ GroupedBarChart as GroupedBarChartCore,
4
+ type BarChartOptions,
5
+ type ChartTabularData
6
+ } from '@carbon/charts'
7
+ declare const __propDef: {
8
+ props: {
9
+ [x: string]: any
10
+ options: BarChartOptions
11
+ data: ChartTabularData
12
+ chart?: GroupedBarChartCore | undefined
13
+ ref?: HTMLDivElement | undefined
14
+ }
15
+ events: {
16
+ load: CustomEvent<null>
17
+ update: CustomEvent<{
18
+ data: ChartTabularData
19
+ options: import('@carbon/charts').BaseChartOptions
20
+ }>
21
+ destroy: CustomEvent<null>
22
+ } & {
23
+ [evt: string]: CustomEvent<any>
24
+ }
25
+ slots: {}
14
26
  }
15
- declare const BarChartGrouped: $$__sveltets_2_IsomorphicComponent<{
16
- [x: string]: any;
17
- options: BarChartOptions;
18
- data: ChartTabularData;
19
- chart?: GroupedBarChartCore | undefined;
20
- ref?: HTMLDivElement | undefined;
21
- }, {
22
- load: CustomEvent<null>;
23
- update: CustomEvent<{
24
- data: ChartTabularData;
25
- options: import("@carbon/charts").BaseChartOptions;
26
- }>;
27
- destroy: CustomEvent<null>;
28
- } & {
29
- [evt: string]: CustomEvent<any>;
30
- }, {}, {}, string>;
31
- type BarChartGrouped = InstanceType<typeof BarChartGrouped>;
32
- export default BarChartGrouped;
27
+ export type BarChartGroupedProps = typeof __propDef.props
28
+ export type BarChartGroupedEvents = typeof __propDef.events
29
+ export type BarChartGroupedSlots = typeof __propDef.slots
30
+ export default class BarChartGrouped extends SvelteComponentTyped<
31
+ BarChartGroupedProps,
32
+ BarChartGroupedEvents,
33
+ BarChartGroupedSlots
34
+ > {}
35
+ export {}
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- SimpleBarChart as SimpleBarChartCore,
4
- type BarChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { SimpleBarChart as SimpleBarChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
-
9
- export let options: BarChartOptions
10
- export let data: ChartTabularData
11
- export let chart: SimpleBarChartCore | undefined = undefined
12
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
13
8
  </script>
14
9
 
15
10
  <BaseChart
@@ -1,32 +1,35 @@
1
- import { SimpleBarChart as SimpleBarChartCore, type BarChartOptions, type ChartTabularData } from '@carbon/charts';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import {
3
+ SimpleBarChart as SimpleBarChartCore,
4
+ type BarChartOptions,
5
+ type ChartTabularData
6
+ } from '@carbon/charts'
7
+ declare const __propDef: {
8
+ props: {
9
+ [x: string]: any
10
+ options: BarChartOptions
11
+ data: ChartTabularData
12
+ chart?: SimpleBarChartCore | undefined
13
+ ref?: HTMLDivElement | undefined
14
+ }
15
+ events: {
16
+ load: CustomEvent<null>
17
+ update: CustomEvent<{
18
+ data: ChartTabularData
19
+ options: import('@carbon/charts').BaseChartOptions
20
+ }>
21
+ destroy: CustomEvent<null>
22
+ } & {
23
+ [evt: string]: CustomEvent<any>
24
+ }
25
+ slots: {}
14
26
  }
15
- declare const BarChartSimple: $$__sveltets_2_IsomorphicComponent<{
16
- [x: string]: any;
17
- options: BarChartOptions;
18
- data: ChartTabularData;
19
- chart?: SimpleBarChartCore | undefined;
20
- ref?: HTMLDivElement | undefined;
21
- }, {
22
- load: CustomEvent<null>;
23
- update: CustomEvent<{
24
- data: ChartTabularData;
25
- options: import("@carbon/charts").BaseChartOptions;
26
- }>;
27
- destroy: CustomEvent<null>;
28
- } & {
29
- [evt: string]: CustomEvent<any>;
30
- }, {}, {}, string>;
31
- type BarChartSimple = InstanceType<typeof BarChartSimple>;
32
- export default BarChartSimple;
27
+ export type BarChartSimpleProps = typeof __propDef.props
28
+ export type BarChartSimpleEvents = typeof __propDef.events
29
+ export type BarChartSimpleSlots = typeof __propDef.slots
30
+ export default class BarChartSimple extends SvelteComponentTyped<
31
+ BarChartSimpleProps,
32
+ BarChartSimpleEvents,
33
+ BarChartSimpleSlots
34
+ > {}
35
+ export {}
@@ -1,14 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- StackedBarChart as StackedBarChartCore,
4
- type BarChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { StackedBarChart as StackedBarChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
- export let options: BarChartOptions
9
- export let data: ChartTabularData
10
- export let chart: StackedBarChartCore | undefined = undefined
11
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
12
8
  </script>
13
9
 
14
10
  <BaseChart
@@ -1,32 +1,35 @@
1
- import { StackedBarChart as StackedBarChartCore, type BarChartOptions, type ChartTabularData } from '@carbon/charts';
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import {
3
+ StackedBarChart as StackedBarChartCore,
4
+ type BarChartOptions,
5
+ type ChartTabularData
6
+ } from '@carbon/charts'
7
+ declare const __propDef: {
8
+ props: {
9
+ [x: string]: any
10
+ options: BarChartOptions
11
+ data: ChartTabularData
12
+ chart?: StackedBarChartCore | undefined
13
+ ref?: HTMLDivElement | undefined
14
+ }
15
+ events: {
16
+ load: CustomEvent<null>
17
+ update: CustomEvent<{
18
+ data: ChartTabularData
19
+ options: import('@carbon/charts').BaseChartOptions
20
+ }>
21
+ destroy: CustomEvent<null>
22
+ } & {
23
+ [evt: string]: CustomEvent<any>
24
+ }
25
+ slots: {}
14
26
  }
15
- declare const BarChartStacked: $$__sveltets_2_IsomorphicComponent<{
16
- [x: string]: any;
17
- options: BarChartOptions;
18
- data: ChartTabularData;
19
- chart?: StackedBarChartCore | undefined;
20
- ref?: HTMLDivElement | undefined;
21
- }, {
22
- load: CustomEvent<null>;
23
- update: CustomEvent<{
24
- data: ChartTabularData;
25
- options: import("@carbon/charts").BaseChartOptions;
26
- }>;
27
- destroy: CustomEvent<null>;
28
- } & {
29
- [evt: string]: CustomEvent<any>;
30
- }, {}, {}, string>;
31
- type BarChartStacked = InstanceType<typeof BarChartStacked>;
32
- export default BarChartStacked;
27
+ export type BarChartStackedProps = typeof __propDef.props
28
+ export type BarChartStackedEvents = typeof __propDef.events
29
+ export type BarChartStackedSlots = typeof __propDef.slots
30
+ export default class BarChartStacked extends SvelteComponentTyped<
31
+ BarChartStackedProps,
32
+ BarChartStackedEvents,
33
+ BarChartStackedSlots
34
+ > {}
35
+ export {}
@@ -1,35 +1,21 @@
1
- <script lang="ts" generics="T extends BaseChartOptions">
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
1
+ <script generics="T extends BaseChartOptions">
3
2
  import { onMount, afterUpdate, onDestroy, createEventDispatcher } from 'svelte'
4
- import type { Charts, ChartConfig, BaseChartOptions, ChartTabularData } from '@carbon/charts'
5
-
6
- interface DispatchedEvents {
7
- load: null
8
- update: { data: ChartTabularData; options: T }
9
- destroy: null
10
- }
11
-
12
- type CoreChartClass = new (holder: HTMLDivElement, chartConfigs: ChartConfig<T>) => Charts
13
-
14
3
  const chartHolderCssClass = 'cds--chart-holder' // Used by Carbon Charts CSS
15
- export let data: ChartTabularData = [] // Chart data, default is empty
16
- export let options: T = {} as T // Specific chart option type, default is empty
17
- export let Chart: CoreChartClass // Used to instantiate next property
18
- export let chart: Charts | undefined // Instance of the chart class
19
- export let ref: HTMLDivElement | undefined // Binding to chart 'holder' in template below
4
+ export let data = [] // Chart data, default is empty
5
+ export let options = {} // Specific chart option type, default is empty
6
+ export let Chart // Used to instantiate next property
7
+ export let chart // Instance of the chart class
8
+ export let ref // Binding to chart 'holder' in template below
20
9
  export let id = `chart-${Math.random().toString(36)}` // id for chart holder element
21
-
22
- const dispatch = createEventDispatcher<DispatchedEvents>()
23
-
10
+ const dispatch = createEventDispatcher()
24
11
  onMount(() => {
25
12
  try {
26
- chart = new Chart(ref as HTMLDivElement, { data, options })
13
+ chart = new Chart(ref, { data, options })
27
14
  dispatch('load')
28
15
  } catch (error) {
29
16
  console.error('Failed to initialize chart:', error)
30
17
  }
31
18
  })
32
-
33
19
  afterUpdate(() => {
34
20
  if (chart) {
35
21
  try {
@@ -41,11 +27,10 @@
41
27
  }
42
28
  }
43
29
  })
44
-
45
30
  onDestroy(() => {
46
31
  if (chart) {
47
32
  dispatch('destroy')
48
- // Like core's Chart.destroy() but keeps div chart holder bound to ref as it's part of the template below
33
+ // Like core's Chart.destroy() but keeps div chart holder bound to ref as it's part of this template
49
34
  chart.components.forEach(component => component.destroy())
50
35
  chart.model.set({ destroyed: true }, { skipUpdate: true })
51
36
  chart = undefined
@@ -1,37 +1,33 @@
1
- import type { Charts, ChartConfig, BaseChartOptions, ChartTabularData } from '@carbon/charts';
1
+ import { SvelteComponentTyped } from 'svelte'
2
+ import type { Charts, ChartConfig, BaseChartOptions, ChartTabularData } from '@carbon/charts'
2
3
  declare class __sveltets_Render<T extends BaseChartOptions> {
3
- props(): {
4
- [x: string]: any;
5
- data?: ChartTabularData | undefined;
6
- options?: T | undefined;
7
- Chart: new (holder: HTMLDivElement, chartConfigs: ChartConfig<T>) => Charts;
8
- chart: Charts | undefined;
9
- ref: HTMLDivElement | undefined;
10
- id?: string | undefined;
11
- };
12
- events(): {
13
- load: CustomEvent<null>;
14
- update: CustomEvent<{
15
- data: ChartTabularData;
16
- options: T;
17
- }>;
18
- destroy: CustomEvent<null>;
19
- } & {
20
- [evt: string]: CustomEvent<any>;
21
- };
22
- slots(): {};
23
- bindings(): string;
24
- exports(): {};
4
+ props(): {
5
+ [x: string]: any
6
+ data?: ChartTabularData | undefined
7
+ options?: T | undefined
8
+ Chart: new (holder: HTMLDivElement, chartConfigs: ChartConfig<T>) => Charts
9
+ chart: Charts | undefined
10
+ ref: HTMLDivElement | undefined
11
+ id?: string | undefined
12
+ }
13
+ events(): {
14
+ load: CustomEvent<null>
15
+ update: CustomEvent<{
16
+ data: ChartTabularData
17
+ options: T
18
+ }>
19
+ destroy: CustomEvent<null>
20
+ } & {
21
+ [evt: string]: CustomEvent<any>
22
+ }
23
+ slots(): {}
25
24
  }
26
- interface $$IsomorphicComponent {
27
- new <T extends BaseChartOptions>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
28
- $$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
29
- } & ReturnType<__sveltets_Render<T>['exports']>;
30
- <T extends BaseChartOptions>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {
31
- $$events?: ReturnType<__sveltets_Render<T>['events']>;
32
- }): ReturnType<__sveltets_Render<T>['exports']>;
33
- z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
34
- }
35
- declare const BaseChart: $$IsomorphicComponent;
36
- type BaseChart<T extends BaseChartOptions> = InstanceType<typeof BaseChart<T>>;
37
- export default BaseChart;
25
+ export type BaseChartProps<T extends BaseChartOptions> = ReturnType<__sveltets_Render<T>['props']>
26
+ export type BaseChartEvents<T extends BaseChartOptions> = ReturnType<__sveltets_Render<T>['events']>
27
+ export type BaseChartSlots<T extends BaseChartOptions> = ReturnType<__sveltets_Render<T>['slots']>
28
+ export default class BaseChart<T extends BaseChartOptions> extends SvelteComponentTyped<
29
+ BaseChartProps<T>,
30
+ BaseChartEvents<T>,
31
+ BaseChartSlots<T>
32
+ > {}
33
+ export {}
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import {
3
- BoxplotChart as BoxplotChartCore,
4
- type BoxplotChartOptions,
5
- type ChartTabularData
6
- } from '@carbon/charts'
1
+ <script>
2
+ import { BoxplotChart as BoxplotChartCore } from '@carbon/charts'
7
3
  import BaseChart from './BaseChart.svelte'
8
-
9
- export let options: BoxplotChartOptions
10
- export let data: ChartTabularData
11
- export let chart: BoxplotChartCore | undefined = undefined
12
- export let ref: HTMLDivElement | undefined = undefined
4
+ export let options
5
+ export let data
6
+ export let chart = undefined
7
+ export let ref = undefined
13
8
  </script>
14
9
 
15
10
  <BaseChart