joewalnes / smoothie

Smoothie Charts: smooooooth JavaScript charts for realtime streaming data
http://smoothiecharts.org
Other
2.25k stars 232 forks source link

If chart become invisible, data is reset. #61

Closed livep2000 closed 9 years ago

livep2000 commented 9 years ago

At the point the chart becomes invisible, the canvas.clientWidth go to zero. Based on that oldestValidTime is incorrect calculated.

Then in dropOldData the data array is cleared. Found a little workaround, there must be a better way:

EDIT : "There must be a better way."

Much better: use stop and start in your script. This also prevents rending graphs, that cannot be seen.

Closed, was'nt a real issues afterwards. Old: just for reference:

  1. Make 'dimensions' globally accesable by 'this.dimensions'
  2. At this part:
return Math.round(self.dimensions.width - ((time - t) / chartOptions.millisPerPixel));

'this' is not accessible, so I did a

var self = this;
  1. Block this behaviour :
// Round time down to pixel granularity, so motion appears smoother.
time -= time % this.options.millisPerPixel;
var w = canvas.clientWidth,
h = canvas.clientHeight,
context = canvas.getContext('2d'),
chartOptions = this.options;

if (w > 0) this.dimensions = { top: 0, left: 0, width: w, height: h };
nikolayh commented 7 years ago

this is not fixed yet?