implement dynamic font size
Currently the highcharts have fixed font size, in the javascript many references are found to hard-coded font-sizes of e.g. 9px and 11px. Instead I would prefer that Highcharts use relative font-size (and paddings etc.) like 1em or 0.8em based on the font-size of the container. This would allow to print large-scale graphs on high-resolutions screens and small graphs on tablets.
Implemented with Highcharts 5, see http://jsfiddle.net/gh/get/jquery/1.7.2/highcharts/highcharts/tree/master/samples/highcharts/css/em/
-
@Jack It seems to me that you are not redrawing the chart, so the layout isn't adjusted to the new font size. This part of the code is removed:
// Update layout based on new font and line sizes
chart.isDirtyLegend = true;
chart.redraw(false); -
Jack Smith commented
I used this feature. But as thre are lots of categories so I have to manage width of chart dynamic.
When I use https://code.highcharts.com/js/highcharts.js file then the width increase but scroll bar does not shown and can not see complete graph.
When I use https://code.highcharts.com/highcharts.js file width issue resolved and I can see a scroll bar to get all categories but then dynamic font size feature doesn't work.
Below are two versions with issue
http://design.tribondinfosystems.com/vertical.php
http://design.tribondinfosystems.com/vertical2.php -
@Derek Moore: It is pure SVG. If you found pieces of HTML in Highcharts, it is because you have added the useHTML option for certain labels. Read more at http://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html.
-
Derek Moore commented
Why can't Highcharts be pure SVG? Instead it is currently a mix of SVG for graph components and HTML for label and text components. The text should scale with with the graph components. Take, for example, the following SVG:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="210mm"
height="297mm"
viewBox="0 0 744.09448819 1052.3622047"
id="svg1"
version="1.1">
<g id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="184"
y="131.3622"
id="text1"><tspan
id="tspan1"
x="184"
y="131.3622">This is scalable?</tspan></text>
<ellipse
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:6;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path1"
cx="347"
cy="272.36221"
rx="126"
ry="116" />
</g>
</svg>Here the text will scale with the graph, and there is no need for programmatic access to font scaling.
-
Hans Wijnveen commented
Looks promising, I'll go and try to implement this.
Thanks! -
Hans Wijnveen commented
This idea is extended in http://highcharts.uservoice.com/forums/55896-general/suggestions/3378262-scalable-graph-and-gauge
-
Hans Wijnveen commented
this idea is basically an extension of http://highcharts.uservoice.com/forums/55896-general/suggestions/2258241-implement-dynamic-font-size