[Vuejs]-How to call chart-zoom resetZoom function when char data changes?

0👍

You need to set a ref in your chart to access it, and then call resetZoom() on that ref when data changes:

<Line :data="chartData" :options="chartOptions" ref="myLineChart"/> 
setup() {
    const myLineChart = ref(null);
    
    watch(
        () => props.chartData,
        () => {
            myLineChart.resetZoom();
        },
        { deep: true }
    );

    return { myLineChart };
}

See the Vue docs for more info on template refs.

Leave a comment