chartjs-chart-financial icon indicating copy to clipboard operation
chartjs-chart-financial copied to clipboard

Strip random data and replace with my own

Open ackmiecik opened this issue 3 years ago • 1 comments

Are there any instructions available that show how to replace the random data code with my own code? eg. a MySQL table, PHP array...

ackmiecik avatar Feb 08 '22 10:02 ackmiecik

I think that it is kind of agnostic how you get your data. Once you have it simply call:

const myChart = new Chart(ctx, {
        type: 'candlestick',
        data: {
            datasets: [{
                label: 'Stock Data',
                data: []
            }]
        }
    });
myChart.config.data.datasets = [{label:"stock",data:yourData}];
myChart.update();

The data does need to be formatted properly, but other then that you can do an http request to get the data from your data source or whatever api your using. I hope this was helpful

msj121 avatar Mar 03 '22 01:03 msj121