Issue with responsive static chart

58 views
Skip to first unread message

corentin caix

unread,
May 4, 2020, 9:42:50 AM5/4/20
to Smoothie Charts
hello,

I've been using smoothie chart for an HMI and i'm using static charts to display parameters

i was using the example given here http://jsfiddle.net/drewnoakes/xVm6w/  

it wasn't working properly with responsive:true since this.canvas didn't have the canvas object 

To fix this i added   if(!this.canvas){this.canvas = canvas;} in SmoothieChart.prototype.render like so


=================================================================

SmoothieChart.prototype.render = function(canvas, time) {
    var nowMillis = Date.now();

    // Respect any frame rate limit.
    if (this.options.limitFPS > 0 && nowMillis - this.lastRenderTimeMillis < (1000/this.options.limitFPS))
      return;

    if (!this.isAnimatingScale) {
      // We're not animating. We can use the last render time and the scroll speed to work out whether
      // we actually need to paint anything yet. If not, we can return immediately.

      // Render at least every 1/6th of a second. The canvas may be resized, which there is
      // no reliable way to detect.
      var maxIdleMillis = Math.min(1000/6, this.options.millisPerPixel);

      if (nowMillis - this.lastRenderTimeMillis < maxIdleMillis) {
        return;
      }
    }

    if(!this.canvas){this.canvas = canvas;}

    this.resize();
    this.updateTooltip();

=================================================================

is there a proper way to do it ?


thanks for the awsome library 

Have a nice day
Reply all
Reply to author
Forward
0 new messages