jackfrost
jackfrost

Reputation: 15

Canvas not displaying after changing size

Can someone know a way to change the size of the canvas? It is currently in width = 10 and height = 10 because it is hidden when checkbox is checked it will display but the size is to small. I tried changing the width and height but it doesn't display now.

        if($(this).is(":checked")) {
            $('.headertrading').show(200);
            $(".tradingtabtd").show(200);
            $(".plswork").show(200);
            
            $('.flot-base').attr({width:130,height:60}).css({width:'130px',height:'60px'});
        $('.flot-overlay').attr({width:130,height:60}).css({width:'130px',height:'60px'});
            
            $(".tradingcheckbox").prop("checked", this.checked);
        } else {
            $(".headertrading").hide(300);
            $(".tradingtabtd").hide(300);
            $(".plswork").hide(300);
            $(".tradingcheckbox").prop("checked", false);
        }
        })
    ```

Upvotes: 0

Views: 134

Answers (1)

Helder Sepulveda
Helder Sepulveda

Reputation: 17584

Yes you can change the size of the canvas, it has width & height attributes: https://www.w3schools.com/tags/att_canvas_height.asp

Here is an example:

var canvas = document.getElementById("canvas");
var slider = document.getElementById("slider");
slider.oninput = function() {
  canvas.width = canvas.height = this.value;
}
<input type="range" min="10" max="300" value="20" id="slider"><br>
<canvas id="canvas" width="20" height="20" style="border:2px solid"></canvas>

Upvotes: 1

Related Questions