Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time scale Deprecation issue. #6677

Closed
rashearth opened this issue Nov 2, 2019 · 4 comments
Closed

Time scale Deprecation issue. #6677

rashearth opened this issue Nov 2, 2019 · 4 comments

Comments

@rashearth
Copy link

rashearth commented Nov 2, 2019

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,
                        
						
                        }, 
											
					   
				    }
			    }
			};

@benmccann
Copy link
Contributor

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

@rashearth
Copy link
Author

rashearth commented Jan 11, 2020

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

@benmccann
Copy link
Contributor

Are you using version 0.7.5 of the zoom plugin?

@rashearth
Copy link
Author

rashearth commented Jan 12, 2020

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/moment@2.24.0/min/moment.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3"></script>
	<script src="https://www.chartjs.org/chartjs-chart-financial/chartjs-chart-financial.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-streaming@1.8.0"></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>



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants