This is a migrated thread and some comments may be shown as answers.

Setting the font-family for all the textual elements in chart

2 Answers 1220 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 28 Jun 2017, 09:03 AM

Hi,

Does the chart have a single property where I can set the font-family for all of the text elements (title, legend, tooltip, axis label, axis title, etc) that the chart may contain?

I'd like to apply our fonts to charts but not have to set half a dozen or more properties if it can be avoided.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 30 Jun 2017, 05:15 AM
Hello Simon,

There is a way to override fonts, however, it requires that you use SVG charts, not canvas charts:

http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-renderAs

Since SVG nodes are part of the document, they are susceptible to styling via CSS. All text nodes are named "text", so to override them you need the following CSS selector:

.k-chart text {
  font: inherit !important;
}

I made an example demonstrating this:

http://dojo.telerik.com/OKihOM

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Simon
Top achievements
Rank 1
answered on 30 Jun 2017, 07:09 AM

Thanks, much appreciated. (NB for people reading this SVG will run into perf issues with a lot of data quicker than a canvas will.)

Erm .. just a little bit of a whinge re the chart font properties. More often than not I want to change the font size and not meddle with the font-family. At the moment the font property requires both, which is how we often get in to downward spiral of having to set the font-family everywhere

Tags
Charts
Asked by
Simon
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Simon
Top achievements
Rank 1
Share this question
or