Example shows Vuejs chart with zooming & panning features which are helpful when there is large dataset. Library supports zooming horizontally, vertically or both.
/* App.vue */ <script> export default { data() { return { chart: null, options: { zoomEnabled: true, title:{ text: "Try Zooming & Panning" }, data: [{ type: "line", dataPoints: this.generateRandomData() }] }, styleOptions: { width: "100%", height: "360px" } } }, methods: { generateRandomData() { var y = 1000, dps = []; for(var i = 0; i < 1000; i++) { y += Math.round(Math.random() * 10 - 5); dps.push({ y: y}); } return dps; }, chartInstance(chart) { this.chart = chart; } } } </script> <template> <CanvasJSChart :options="options" :style="styleOptions" @chart-ref="chartInstance"/> </template>
/*main.js*/ import { createApp } from 'vue' import App from './App.vue' import CanvasJSChart from '@canvasjs/vue-charts'; const app = createApp(App); app.use(CanvasJSChart); // install the CanvasJS Vuejs Chart Plugin app.mount('#app');
You can customize along which axis zooming / panning should occur using zoomType property. Some other frequently used customization options include animationEnabled, animationDuration, theme, etc.
Note For step by step instructions, follow our Vuejs Integration Tutorial