I’m not having any luck drawing a chart in a Canvas sized to 100% width and height. It looks magnified several times and only shows the upper left of the chart (though the title looks centered). I’ve attached a screen shot of a Chrome session with the developer tools open. (The chart lines are only visible because I had scrolled them into view.) The code to create the chart is:
Yes, that works: you’re using a fixed-size canvas. I am doing something like “<canvas id=“canvas1” style=“width: 100%;” height=“400”>”. Is it not possible?
and inspect the elements, the canvas is correctly sized. It’s just that the chart doesn’t draw correctly.
FWIW, I have found a workaround. I am starting with the HTML generated by TeeSaveToJavascriptFile (Delphi XE, TeeChart Pro v2012.07.121105) and making the following changes:
Insert the missing element, with style=“height: 100%; margin: 0;”.
Update the to v2014.04.28.1.6.
Change “Chart1.draw()” to “resize()”.
Insert a resize() function (below).
Change body tab to .
Remove width & height attributes from the canvas tag.
function resize() {
var body = document.body;
var canvas = Chart1.canvas;
canvas.width = body.clientWidth;
canvas.height = body.clientHeight - 4; // prevents vertical scroll bar on <iframe> - haven't figured out where it comes from yet
Chart1.bounds.width = canvas.width;
Chart1.bounds.height = canvas.height;
Chart1.draw();
}
I’ve just realised we actually have a demo doing this since the first version at “Other/Panel/Full page align” in the features demo. Direct link to the example.