@revolist/svelte-charts 4.0.2-rc → 4.0.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.
package/README.md CHANGED
@@ -50,15 +50,26 @@ wrapper trial package is published.
50
50
 
51
51
  ```svelte
52
52
  <script lang="ts">
53
- import { RevoChart, type ChartComponentOptions } from '@revolist/svelte-charts';
53
+ import {
54
+ RevoChart,
55
+ type ChartComponentOptions,
56
+ } from '@revolist/svelte-charts';
54
57
  let options = $state.raw<ChartComponentOptions>({
55
58
  chartType: 'line',
56
- data: [{ month: 'Jan', revenue: 120 }, { month: 'Feb', revenue: 180 }],
59
+ data: [
60
+ { month: 'Jan', revenue: 120 },
61
+ { month: 'Feb', revenue: 180 },
62
+ ],
57
63
  mapping: { category: { field: 'month' }, series: [{ field: 'revenue' }] },
58
64
  });
59
65
  </script>
60
- <RevoChart {options} onReady={chart => console.log(chart.model)}
61
- style="height:400px" class="sales-chart" />
66
+
67
+ <RevoChart
68
+ {options}
69
+ onReady={(chart) => console.log(chart.model)}
70
+ style="height:400px"
71
+ class="sales-chart"
72
+ />
62
73
  ```
63
74
 
64
75
  ## Updates and lifecycle
@@ -2,7 +2,10 @@
2
2
  import { onMount, untrack } from 'svelte';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { createChartComponentController } from '@revolist/charts/framework';
5
- import type { ChartComponentController, ChartComponentOptions } from '@revolist/charts/framework';
5
+ import type {
6
+ ChartComponentController,
7
+ ChartComponentOptions,
8
+ } from '@revolist/charts/framework';
6
9
  import type { ChartRef, ChartServerRender } from '@revolist/charts';
7
10
 
8
11
  interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
@@ -10,17 +13,39 @@
10
13
  onReady?: (chart: ChartRef) => void;
11
14
  serverRender?: ChartServerRender;
12
15
  }
13
- let { options, onReady, serverRender, style = '', ...attributes }: Props = $props();
16
+ let {
17
+ options,
18
+ onReady,
19
+ serverRender,
20
+ style = '',
21
+ ...attributes
22
+ }: Props = $props();
14
23
  // Snapshot markup belongs to the initial mount, not subsequent prop updates.
15
24
  const initial = untrack(() => serverRender);
16
25
  let host: HTMLDivElement;
17
26
  let controller: ChartComponentController | undefined;
18
27
  onMount(() => {
19
- controller = createChartComponentController(host, chart => onReady?.(chart), !!initial);
28
+ controller = createChartComponentController(
29
+ host,
30
+ (chart) => onReady?.(chart),
31
+ !!initial,
32
+ );
20
33
  void controller.setOptions(options);
21
- return () => { controller?.destroy(); controller = undefined; };
34
+ return () => {
35
+ controller?.destroy();
36
+ controller = undefined;
37
+ };
38
+ });
39
+ $effect(() => {
40
+ const next = options;
41
+ void controller?.setOptions(next);
22
42
  });
23
- $effect(() => { const next = options; void controller?.setOptions(next); });
24
43
  </script>
25
44
 
26
- <div {...attributes} bind:this={host} style={`width:100%;height:${initial?.height ?? 300}px;${style}`}>{@html initial?.svg ?? ''}</div>
45
+ <div
46
+ {...attributes}
47
+ bind:this={host}
48
+ style={`width:100%;height:${initial?.height ?? 300}px;${style}`}
49
+ >
50
+ {@html initial?.svg ?? ''}
51
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revolist/svelte-charts",
3
- "version": "4.0.2-rc",
3
+ "version": "4.0.3",
4
4
  "description": "Svelte components for RevoGrid Charts",
5
5
  "type": "module",
6
6
  "license": "Commercial",
@@ -20,7 +20,7 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@revolist/charts": "4.0.2-rc"
23
+ "@revolist/charts": "4.0.3"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "svelte": "^5.55.0"