P粉3389695672023-08-31 18:14:05
You are not setting data into the response. Please use to calculate
This code can solve the problem:
<script setup> import { storeToRefs } from 'pinia' import { useStore} from '@/store/pinia-store-file'; import { Chart as ChartJS, CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend } from 'chart.js'; import { Line } from 'vue-chartjs'; import { computed } from "vue" ChartJS.register( CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend ); const store = useStore(); const storeData= storeToRefs(store); const data = computed(() => ({ labels: [...Array(storeData.arr.value.length).keys()], datasets: [ { label: 'Data One', backgroundColor: '#f87979', data: storeData.arr.value } ] })) const options = { responsive: true, maintainAspectRatio: false } </script> <template> <Line :data="data" :options="options" /> </template>