| 12345678910111213141516171819202122232425262728293031323334353637 |
- <template>
- <div>
- <canvas ref="chart"></canvas>
- </div>
- </template>
-
- <script>
- import { Chart, LineElement, CategoryScale, LinearScale, Title } from 'chart.js';
-
- export default {
- name: 'LineChart',
- props: {
- chartData: {
- type: Object,
- required: true
- },
- chartOptions: {
- type: Object,
- required: true
- }
- },
- mounted() {
- this.renderChart();
- },
- methods: {
- renderChart() {
- const ctx = this.$refs.chart.getContext('2d');
- new Chart(ctx, {
- type: 'line',
- data: this.chartData,
- options: this.chartOptions
- });
- }
- }
- }
- </script>
-
|