Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reactivity to update chart options when options change #1478

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}

bmanth60 marked this conversation as resolved.
Show resolved Hide resolved
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