0👍
You can use d3-fetch to get the csv data, assuming the csv file is in public
directory present in project root directory:
import { csv } from "d3-fetch";
function fetchData() {
return csv('/filename.csv').then((data) => (data));
}
export default fetchData;
You can use await
to get results from fetch data, or use then
to get data when fetch is resolved.
let data = await fetchData();
let chartDataHolder;
fetchData.then((result) => {
chartDataHolder = result;
});
Hope this helps.
- Chartjs-How to realize a discontinuous section (jumps) in a continuous line plot with Chart.js?
- Chartjs-Radar Chart, Chart.js v3.2 labels customization
Source:stackexchange.com