Example shows vue.js line chart with category axis that uses axis labels on x-axis. Y-Axis labels are formatted to show comma separator according to Indian Number System.
Note that if you set x value of datapoints, it becomes a numeric/date-time axis.
/* App.vue */ <script> export default { data() { return { chart: null, options: { animationEnabled: true, exportEnabled: true, theme: "light2", title:{ text: "UPI Transactions in India" }, axisX:{ valueFormatString: "YYYY", labelTextAlign: "center", labelAngle: 0 }, axisY: { title: "Amount (in ₹ Crore)", valueFormatString: "₹##,##,##0cr" }, data: [{ type: "line", yValueFormatString: "₹##,##,##0.## crores", dataPoints: [ { label: "2016", y: 893.07 }, { label: "2017", y: 57020.87 }, { label: "2018", y: 585710.45 }, { label: "2019", y: 1836638.18 }, { label: "2020", y: 3387744.72 }, { label: "2021", y: 7159285.80 }, { label: "2022 (Jan-Oct)", y: 10122170.33 } ] }] }, styleOptions: { width: "100%", height: "360px" } } }, methods: { 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');
Color & thickness of the line can be changed by setting lineColor & lineThickness properties respectively. In the above example, valueFormatString & yValueFormatString properties are used to define custom format for the axis labels & y-value shown in tooltip.
Note For step by step instructions, follow our Vuejs Integration Tutorial