Chartjs-Chart.js Display Prediction Data

0👍

What about adding an extra dataset for your forecast data. Style this second set with a dashed line? Yes, that results in 2 datasets. One for the data and one for the prediction. Hope that helps.

As example (not tested, just as example):

const lineChart = new Chart(lineCanvas, {
type: "line",
data: {
    labels: ["2019", "2020", "2021", "2022"],
    datasets: [{
        label: "Revenues",
        data: [2195, 2225, 2166, 2250],
        backgroundColor: "orange",
        borderColor: "orange",
    }, {
        label: "Revenues",
        data: [2195, 2225, 2166, 2250, 6000, 9000], /* Add the extra data points */
        borderColor: "red" /* Whatever style you like */
    }]
}, options:[] });

Leave a comment