javascript - Changing fontFamily on ChartJS bar chart -
i've partially implemented chartjs in project, can't figure out how change font that's displayed on x , y axes of bar chart.
i've read chartjs documentation, searched examples on github, etc. i'm not sure i'm doing wrong, rest assured knowing solution involve line of code , startlingly stupid oversight on part.
this code draws chart want, default font:
var barchartlanguage = chart.bar(mycanvas, { data: datalanguages, options: options, defaults: defaults });
i tried changing font in defaults
without success:
var defaults = { global: { // example font defaultfontfamily: "'raleway'" } };
and tried changing on axis options
:
var options = { animation: { duration: 2000 }, scales: { yaxes: [{ display: true, ticks: { suggestedmin: 0, // minimum 0, unless there lower value. // or // beginatzero: true, // minimum value 0. suggestedmax: 10 }, gridlines: { display: false }, pointlabels: { fontfamily: "'raleway'" } }], xaxes: [{ gridlines: { display: false } }], }, };
add ticks.fontfamily xaxes this:
xaxes: [{ gridlines: { display: false }, ticks: { fontfamily: "verdana", } }],
documentation: http://www.chartjs.org/docs/#scales
example on jsfiddle: http://jsfiddle.net/4aslpwd5/
Comments
Post a Comment