0👍
You could have a <select>
with options containing values equal to your .js filenames. When the selection is changed, run a method that dynamically imports that file and assigns the imported data to the variable you pass down as a prop to your Graph component. Simple example code:
<select @change="selectFile">
<option value="dataFile1">file one</option>
<option value="dataFile2">file two</option>
</select>
<Graph :vul_data="data" />
data() {
return {
data: null,
};
},
methods: {
selectFile(e) {
import(`@/data/${e.target.value}.js`).then((res) => {
this.data = res.data;
});
},
},
- Chartjs-How to reuse a Chart.js chart in Blazor wasm?
- Chartjs-Angular Charts – not able to read data
Source:stackexchange.com