1

Using the code below.

var canvas = $('<canvas/>').addClass('chart').appendTo(element);

// ...

canvas.css({ width: 700, height: 400 });
var ctx = canvas[0].getContext("2d");
new Chart(ctx).Line(data);

The canvas always gets resized to 300x150 when the last line is called. Why?

Chris
  • 27,596
  • 25
  • 124
  • 225

1 Answers1

1

The styles you apply via css are lost when you getContext. You should try using prop too/instead.

canvas.prop({ width: 700, height: 400 });
Jack
  • 20,735
  • 11
  • 48
  • 48