If you prefer Yarn, use the following command instead:
yarnadd-D @carbon/charts-svelte@next
The required styles should be imported from @carbon/charts-svelte/styles.css.
Breaking Change
This release is for Svelte 5.20+ ONLY as it uses runes mode and passing of callback functions as
properties in place of event handlers. If you need support for Svelte 3 or 4, please use the
latest.
SvelteKit
While this component library can be used with any build environments for Svelte,
SvelteKit is the official framework for building Svelte apps supporting
client and server-side rendering (SSR). SvelteKit is powered by Vite.
The module @carbon/charts should not be externalized for SSR when building for production.
Dynamically importing a chart within onMount() avoids issues with server-side rendering (SSR). The
reason @carbon/charts-svelte does not work with SRR is because its dependency @carbon/charts
expects the window object to be present for fullscreen display.
Use the ComponentProps utility type from svelte to extract the props for chart components.
You can then use an
indexed access type to
extract types for individual properties.
importtype{ ComponentProps }from'svelte'import{ BarChartSimple }from'@carbon/charts-svelte'import{ options }from'./options'import{ data }from'./data'// Errors if these aren't the correct props expected by BarChartSimpleconst props: ComponentProps<typeof BarChartSimple>={ options, data }
IBM Telemetry
This package uses IBM Telemetry to collect de-identified and anonymized metrics data. By installing
this package as a dependency you are agreeing to telemetry collection. To opt out, see
Opting out of IBM Telemetry data collection.
For more information on the data being collected, please see the
IBM Telemetry documentation.