chartjs / chartjs-chart-financial

Chart.js module for charting financial securities
MIT License
725 stars 197 forks source link

dynamic candlestick chart update #33

Closed saadamin closed 6 years ago

saadamin commented 6 years ago

I want to dynamically update candlestick chart.

        candlest = document.getElementById("chart3").getContext("2d");
        candlest.canvas.width = 1000;
        candlest.canvas.height = 250;
        new Chart(candlest, {
            type: 'candlestick',
            data: {
                datasets: [{
                    label: [],
                    data: jdata,
                    fractionalDigitsCount: 6,
                }]
            },
            options: {
                legend: {display: false},
                scales: {
                    yAxes: [
                        {
                        id: 'y-axis-0',
                              ticks: {
                                //autoSkip: true,
                                stacked: true
                              },
                            display: true,
                            position: 'right',
                            scaleLabel: {
                                display: true,
                                labelString: 'Price'
                              }
                            },{
                                display: true,
                                position: 'left',
                               }
                          ],
                    xAxes: [
                        {
                        id: 'x-axis-0',
                             display: true,
                        scaleLabel: {
                                display: true,
                        },
                        ticks: {
                                autoSkip: true,
                                stacked: true,
                                maxTicksLimit: 10,
                                //callback:(v)=>this.formatSecsAsMins(v),
                                stepSize:300, //add a tick every 5 minutes
                        },
                        }
                  ]
                },
                tooltips: {
                    position: 'nearest',
                    mode: 'index',
                },
            },
        });

tried this codes to update the chart dynamically. but didn't work out .

candlest.jdata.datasets[0].data[t]={c: min2.c,h: min2.h,l: min2.l,o: min2.o,t: min2.t};
candlest.options.scales.yAxes[0].scaleLabel.labelString = cval;
candlest.update()
benmccann commented 6 years ago

I'm sorry. I don't offer any support. This issue tracker is only for clearly demonstrated bugs in the code