Chart.js: Time scale Deprecation issue.

Created on 2 Nov 2019  Â·  4Comments  Â·  Source: chartjs/Chart.js

Hi, I am now using these plugin.
since i updated the chart.js to 2.9.1, there is some issues occurring.
this occurs even though i am not using time scale in option.
is this a bug?
i checked the stack overflow, or other sites, but i couldnt find same issue.

ISSUE
after the chart.js 2.9.1 update,
there is below error coming up, even though i am not using time.format.
it comes up 20times per second, and affecting the memory.
Also, this comes out when i use zoom plugin
スクリーンショット 2019-11-02 15 00 20

"time.format" is deprecated. Please use "time.parser" instead

PLUGIN USED
â‘ financial plugin
â‘¡zoom plugin
â‘¢datalabel plugin
â‘£chart.js streaming
⑤annotation plugin

options code:

    options: { 
                    hover: {
                        animationDuration: 0           // duration of animations when hovering an item 
                    },
                    responsiveAnimationDuration: 0,    // animation duration after a resize 

                    tooltips: { 
                            enabled: true, 
                            //intersect: true,
                            position: "nearest",
                            mode:"nearest",

                        },

                    animation: {

                        duration: 0                    // general animation time

                    },            

                    annotation: {

                        events: ['click'],
                        annotations:annotations ,           


                    drawTime: "afterDraw"
                },


                    maintainAspectRatio: false,

                    layout: {
                        padding: {
                            left: -5,
                            right: 0,
                            top: 0,
                            bottom: -10
                                }
                            },      
                    title: {
                        display: false,
                        fontColor: "white",

                    },
                    legend: {
                        display: false,
                    },

                    scales: {
                        yAxes:[{
                            stacked: false,
                            gridLines: {
                                color: 'rgba(42,46,57,1)',
                                lineWidth: 1
                            },
                            id:'y-axis-0',
                            ticks: {

                                fontColor: "white",

                            }
                        },
                        {
                            stacked: false,
                            id:'y-axis-barchart',
                            display:false,
                            ticks: { 
                                beginAtZero: true, 

                                max:periods*700000,
                            }

                        }
                        ],
                        xAxes: [{
                            stacked: true,
                            gridLines: {
                                color: 'rgba(42,46,57,1)',
                                lineWidth: 1
                            },
                            id:"normal",
                            ticks: {
                                autoSkip:true,
                                maxTicksLimit: 20, 
                                fontColor: "white",
                                min: new Date(candledata[candledata.length]).getTime(),
                                max: new Date(candledata[0]).getTime()

                            },
                            time: {
                                minUnit:'second',
                                // min: new Date(candledata[candledata.length]).getTime(),
                                // max: new Date(candledata[0]).getTime()
                            },
                            type: 'realtime',

                            realtime: {

                                duration: setduration,
                                refresh: refres,
                                delay: setdelay,
                                pause: false,       // chart is not paused
                                ttl: pasttime,
                                //onRefresh: onRefresh  
                            },
                        },


                        ],

                    },
                    plugins: { 

                        zoom : zooom,
                        doughnutlabel:false,
                        datalabels: {

                            backgroundColor: "transparent",                         
                            borderRadius: 4,
                            clip: true,
                            color: "white",
                            font: {
                                weight: 'bold'
                            },
                            formatter: function(value, context) {

                                return  context.chart.data.array[context.dataIndex];

                            }

                        },
                        streaming: { 
                            frameRate: 10,   
                            onRefresh: onRefresh_chart_bitmex,


                        }, 


                    }
                }
            };

bug

Most helpful comment

This will be fixed in the next version of the zoom plugin. A fix has already been committed there and just needs to be released

All 4 comments

This will be fixed in the next version of the zoom plugin. A fix has already been committed there and just needs to be released

hi, thx for your support!
but still, i get these errors, with some words changed.
if there is any way to avoid, could you kindly let us know?

i have tried many ways to solve this issue, (for example changing the time scale )
but couldnt solve it .

time scale: "time.format" is deprecated. Please use "time.parser" instead

スクリーンショット 2020-01-11 16 25 16

Are you using version 0.7.5 of the zoom plugin?

thx for the quick response.

yes, i am using 0.7.5 zoom plugin.

in fact, i found out that these three plugin makes the warning.

â‘ chart.js 2.9.3
â‘¡chart.js financial plugin
â‘¢chart.js streaming plugin 1.8.0

I have made a quick sample html so that you could confirm.
http://aifx2.sakura.ne.jp/realtimecharttest2.html

<!DOCTYPE HTML>
<html>
 <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">



<head>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/min/moment.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
    <script src="https://www.chartjs.org/chartjs-chart-financial/chartjs-chart-financial.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<body>
    <div>
        <canvas id="myChart"></canvas>
    </div>
</body>


<script>

 var past =  {t:Date.now()-20000, o:87, h: 101, l: 78, c: 100};
 var past2 = {t:Date.now()-40000, o:87, h: 101, l: 78, c: 100}
 console.log(past);
var ask = Math.random();


setInterval(function () {

    annotationx= Date.now();

    annotationy = 90;
    return annotationx;
    return annotationy; 


}, 10000); 





function onRefresh(chart) {
    var t = Date.now();
    var data2 = chart.data.datasets[0].data;
    var last;

    t -= t % 1000;
    if (data2.length === 0) {
        data2.push(past);
        data2.push(past2);
    }
    last = data2[data2.length - 1];
    if (t != last.t) {
        var c = last.c;
        last = { t: t, o: c, h: c, l: c, c: c };
        data2.push(last);
    }
    last.c += Math.random() - 0.5;
    last.h = Math.max(last.h, last.c);
    last.l = Math.min(last.l, last.c);





}

var config = {
    type: 'candlestick',
    data: {
        datasets: [
{
            data: [],
            fractionalDigitsCount: 2
        },





]
    },
    options: {


        title: {
            display: true,
            text: 'Financial chart sample'
        },
        legend: {
            display: false,
        },
        scales: {
            xAxes: [{
                type: 'realtime',
                realtime: {
                    duration: 120000,
                    refresh: 100,
                    delay: 0,
                    onRefresh: onRefresh
                }
            }]
        },
        tooltips: {
            position: 'nearest',
            intersect: false
        },
        animation: {
            duration: 0
        }
    }
};

window.onload = function() {
    var ctx = document.getElementById('myChart').getContext('2d');
    window.myChart = new Chart(ctx, config);
};


</script>



Was this page helpful?
0 / 5 - 0 ratings

Related issues

srijitcoder picture srijitcoder  Â·  3Comments

JAIOMP picture JAIOMP  Â·  3Comments

lizbanach picture lizbanach  Â·  3Comments

akashrajkn picture akashrajkn  Â·  3Comments

JewelsJLF picture JewelsJLF  Â·  3Comments