score:17
it is indeed possible.
considering you have imported your font (from googlefonts for instance),
you just have to edit the defaultfontfamily
attribute in your chart options like this :
var options = {
// 'raleway' is the name of the fond i imported from googlefonts
defaultfontfamily: chart.defaults.global.defaultfontfamily = "'raleway'"
}
see lolka's answer for more information about the defaultfontfamily
attribute.
a full working example:
chart.defaults.global.defaultfontfamily = "indie flower";
var ctx = document.getelementbyid("mychart");
var mychart = new chart(ctx, {
type: 'bar',
data: {
labels: ["red", "blue", "yellow", "green", "purple", "orange"],
datasets: [{
label: '# of votes',
data: [12, 19, 3, 5, 2, 3],
backgroundcolor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
bordercolor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderwidth: 1
}]
},
options: {
scales: {
yaxes: [{
ticks: {
beginatzero:true
}
}]
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.1.6/chart.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=indie+flower' rel='stylesheet' type='text/css'>
<canvas id="mychart" width="400" height="400"></canvas>
score:1
first result for google chart.js custom font
from documentation:
there are 4 special global settings that can change all of the fonts on the chart. these options are in chart.defaults.global.
...
defaultfontfamily string "'helvetica neue', 'helvetica', 'arial', sans-serif" default font family for all text
Source: stackoverflow.com
Related Query
- Is it possible to add a custom font to chart js?
- Add a custom label to the top or bottom of a stacked bar chart
- How to draw a needle on a custom donut chart and add datapoints to the needle?
- Using chart js version 3, how to add custom data to external tooltip?
- ChartJS add custom tooltip to a stacked bar chart
- How to add custom text inside the bar and how to reduce the step size in y axis in chart js( Bar chart )
- Is it possible to add a javascript chart in a webview in Xamari.Forms
- Is it possible to dynamically add more Y Axes or more X Axes on chart js?
- Is it possible to add more attributes to segement in a Doughnut chart of Chart JS?
- How can I add functionality to Chartjs Doughnut chart custom legend
- how to add multi X axis custom line in chart js
- Is it possible to add image behind doughnut chart with transparency color in ng2chart?
- How to add text inside the doughnut chart using Chart.js?
- Chart JS custom tooltip option?
- How to add an on click event to my Line chart using Chart.js
- chartjs : how to set custom scale in bar chart
- chartjs datalabels change font and color of text displaying inside pie chart
- Add DataSet Bar Chart - Chart.JS
- How to add an offset to a dataset in Chart js
- ChartJS add tooltip to a grouped bar chart
- How to add second Y-axis for Bar and Line chart in Chart.js?
- How to add text in centre of the doughnut chart using Chart.js?
- Is it possible to produce circular (round) shaped radar chart in Chart.js?
- Chart.js v2.6: Add arrows to pie chart output values
- Chart js. How to change font styles for "labels" array?
- How to add datas to chart js from javascript array itself?
- Chart.js - Add gradient to bar chart
- How to add panning to chart in chartjs?
- Add all data in the tooltip of Chart JS
- Can I specify a different font size for each row of text in Chart Title?
More Query from same tag
- How to change chart.js chart's grid color?
- Customize Pie Chart Legend in chart.js
- Chart.js How to synchronize pan and zoom in multiple chats
- Am I missing a chart.js component or helper?
- Dataset legend color is not updating after changing background color of dataset and update (chartJs framework)
- Chart.js Find intersection Point and Draw a Circle
- ChartJS 2.6 - Change color of bar in Bar chart programmatically
- Second tab doesn't show the chart . Can anybody see why?
- chart.js - tooltip callback function ignore hidden datasets when deselecting legend
- Remove only y-axis line from chat drawn using chart.js 1.0.2
- chart.js update is not a function
- Updating chart.js with array index 0 doesn't work
- Creating a real time line chart using chartjs and firebase realtime db
- trouble with making floating bar charts using chart.js
- hide label on doughnut chart of chartjs
- Chart.js with React
- How to Add X axis Padding in chart js Line Graph
- how to highlight stack bar in ChartJS with onclick
- Chart.js - How to place text outside of radar chart
- Remove redundant legends on the chart using generateLabels with ChartJS v3
- Chart.js not showing when i try to format dates
- What kind of graph could I use to achieve this with ChartJS (or similar)?
- show label in tooltip but not in x axis for chartjs line chart
- Default font size doesn't change ChartJS
- 0 line style of Chart.js line chart
- Chartjs and ChartDataLabels does not work in mdb5 pro version 2
- Position tooltip based on mouse position
- How to get dataset from MySQL using Flask?
- How to offset x and y axis grid points and labels using chart.js?
- Two chartjs charts on page throwing data undefined error