Skip to content

Commit

Permalink
Add reactivity to update chart options when options change
Browse files Browse the repository at this point in the history
  • Loading branch information
bmanth60 committed Oct 30, 2024
1 parent 41fe139 commit d7c5a40
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/charts/Chart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import type { ApexOptions } from 'apexcharts';
import type ApexCharts from 'apexcharts';
interface $$Props {
options: ApexOptions;
class?: string;
Expand All @@ -11,11 +11,16 @@
export let options: ApexOptions;
let chart: ApexCharts | undefined;
// Add reactivity to update options when options change
$: {
chart?.updateOptions(options);
}
interface ChartAction {
update: (options: ApexOptions) => void;
destroy: () => void;
}
function initChart(node: HTMLElement, options: ApexOptions): ChartAction {
async function asyncInitChart(): Promise<void> {
const ApexChartsModule = await import('apexcharts');
Expand Down

0 comments on commit d7c5a40

Please sign in to comment.