i want to create multiple chart from chart.js in one .vue component and one .js file, how i can create it?
so far what i try is creating another .js file for each chart.
here my code
LineChart.js file
import {Line} from 'vue-chartjs'
export default {
extends: Line,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'Data One',
backgroundColor: '#FC2525',
data: [40, 39, 10, 40, 39, 80, 40]
},{
label: 'Data Two',
backgroundColor: '#05CBE1',
data: [60, 55, 32, 10, 2, 12, 53]
}
]
}, {responsive: true, maintainAspectRatio: false})
}
}
Step2.vue component
<template>
<div class="Chart">
<h2>Linechart</h2>
<line-example></line-example>
</div>
</template>
<script>
import LineExample from './LineChart.js'
export default {
name: 'tes',
components: {
LineExample
}
}
</script>
this code is for one chart, if i want to add more chart then i have to create another .js file.