bernii / gauge.js

100% native and cool looking JavaScript gauge
MIT License
1.42k stars 391 forks source link

Using gauge.js inside Shadow DOM #174

Open adamwolek opened 6 years ago

adamwolek commented 6 years ago

With chrome browser, inside shadow dom element there is the problem, that canvas.clientHeight and canvas.clientWidth are both 0. Fortunately canvas.height and canvas.width are still correct, so to fix this it was enough to comment a few lines: `

function Gauge(canvas) {
        // var h, w;
        this.canvas = canvas;
        Gauge.__super__.constructor.call(this);
        this.percentColors = null;
        if (typeof G_vmlCanvasManager !== 'undefined') {
          this.canvas = window.G_vmlCanvasManager.initElement(this.canvas);
        }
        this.ctx = this.canvas.getContext('2d');
        // h = this.canvas.clientHeight;
        // w = this.canvas.clientWidth;
        // this.canvas.height = h;
        // this.canvas.width = w;
        this.gp = [new GaugePointer(this)];
        this.setOptions();
}

`