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

Draw problem after a few value updates #273

Open
AtaraHalamish opened this issue Sep 7, 2023 · 4 comments
Open

Draw problem after a few value updates #273

AtaraHalamish opened this issue Sep 7, 2023 · 4 comments

Comments

@AtaraHalamish
Copy link

I recently updated from v1 to v2.1.7.

I have some gaugaes on a page, updated from PLC values.

I noticed that after a few updates, without me moving the browser window, the gauge is drawn on another part of the screen (the left-top-quarter of the original position) - see screenshot.

How can I avoid it?
gauge_canvas_problem_230907

@AtaraHalamish
Copy link
Author

(using FireFox 117.0 (64-bit))

@marcopiai
Copy link

i have the same problem, but only with firefox (now release 118.0.2)
I have solved moving the creation of the gauge in a function with a value parameter for start the needle in the last position and every 5 or 10 second i destroy the gauge and recreate it, preserving the value for mantaining the last value

@marcopiai
Copy link

example:
function create_gauge(valuestart){
var GAUGE = new RadialGauge({
renderTo: 'gauge1',
width: 180,
height: 180,
units: '°C',
title: 'Temp',
value: valuestart,
minValue: -10,
maxValue: 60,
ticksAngle: 225,
startAngle: 67.5,
majorTicks: [
'-10','0','10','20','30','40','50','60'
],
minorTicks: 5,
strokeTicks: false,
//barStrokeWidth: 1,
//barWidth:5,
highlights: [
{ from: -10, to: 10, color: 'rgba(0,0,255,.7)' },
{ from: 10, to: 20, color: 'rgba(0,226,255,.8)' },
{ from: 20, to: 34, color: 'rgba(0,255,0,.7)' },
{ from: 34, to: 44, color: 'rgba(255,245,0,.7)' },
{ from: 44, to: 50, color: 'rgba(255,120,0,.8)' },
{ from: 50, to: 60, color: 'rgba(255,0,0,.6)' }
],
colorPlate: '#fff',
colorMajorTicks: '#f5f5f5',
colorMinorTicks: '#ddd',
colorTitle: '#000',
colorUnits: '#000',
colorNumbers: '#000',
colorNeedle: 'rgba(240, 128, 128, 1)',
colorNeedleEnd: 'rgba(255, 160, 122, .9)',
colorBorderOuter:'#fff',
colorBorderOuterEnd:'#fff',
colorBorderMiddle:'#fff',
colorBorderMiddleEnd:'#fff',
colorBorderInner:'#fff',
colorBorderInnerEnd:'#fff',
colorBorderShadow: '#fff',
valueDec:1,
valueInt:1,
fontNumbers: "Verdana",
fontValueStyle: 'italic',
fontNumbersSize: 22,
fontNumbersStyle: 'italic',
fontNumbersWeight: 'bold',
fontTitleSize: 40,
fontUnitsSize: 30,
fontValueSize: 50,
colorValueText: "#000",
colorValueBoxRect: "#fff",
colorValueBoxRectEnd: "#fff",
colorValueBoxBackground: "#fff",
colorValueBoxShadow: false,
colorValueTextShadow: false,
//fontValueSize:30,
valueBox: true,
animationRule: 'linear',
animationDuration: 500
}).draw();
return GAUGE;
}

then add a onload call in body for first draw:
onload="create_gauge(0);"

and in the refresh animation some changes:
// animage all gauges on a page

window.addEventListener('load', function() {
	
	setInterval(function() {
		document.gauges.forEach(function(gauge) {
				var value = gauge.value;
				var new_value = Math.random() *
				(gauge.options.maxValue - gauge.options.minValue) + gauge.options.minValue;
				gauge.destroy();
				var GAUGE_new = create_gauge(value);
				GAUGE_new.value = new_value;
			});
					   
	}, 1000);
	
});

this for me works well
i have also added a counter for refresh the draw only every 10 second

@Strandinator
Copy link

Strandinator commented Feb 14, 2024

Different issue but similar workaround: #248 (comment)

You can use the "render" event to count the render ticks. Then call redraw after a certain limit.

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

No branches or pull requests

3 participants