Home
Analytics
[chart] how to change font family to sans-serif - via java
dermoritz
i am creating charts via the java-api and need to change all fonts used in chart to sans serif. But at least i need to change the font for labeling the xAxis.<br />
I don't really want to specify a concrete font because i don't know if it is available on target system.<br />
the only thing i found to chang font was this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>FontDefinition oldFont = xAxisPrimary.getLabel().getCaption().getFont();
xAxisPrimary.getLabel()
.getCaption()
.setFont(FontDefinitionImpl.create("Helvetica",
oldFont.getSize(),
false,
false,
false,
false,
true,
oldFont.getRotation(),
oldFont.getAlignment()));</pre>
<br />
but this is <strong class='bbc'>not</strong> working (Labels just disapear). Another problem with this code is that i have to specify other stuff and not only the font family (i want nothing change but the font-family).
Find more posts tagged with
Comments
kclark
If you want to change only the font you can use<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
getLabel().getCaption().getFont().setName("fontName");
</pre>
dermoritz
Thanks!
It is also working with "sans-serif" as name!