chartjs / chartjs-chart-financial

Chart.js module for charting financial securities
MIT License
720 stars 195 forks source link

Strip random data and replace with my own #121

Open ackmiecik opened 2 years ago

ackmiecik commented 2 years ago

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

msj121 commented 2 years ago

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