chart fontsize won't set, default too big
See original GitHub issueI have a a couple apps using the same library and same coding technique
one works as expected, the other comes out with this large font
https://www.dropbox.com/s/y7xjl5is7inynt6/Screenshot at 2020-05-11 08-56-43.png?dl=0
i can’t figure out why
2 datasets, 130 entries each
I added setting the global fontsize, no change, right before creating the chart
Chart.defaults.global.defaultFontSize=8
the chartOptions are pretty straight forward
var chartOptions= {
title:{
display: true, // this works
text: self.config.chart_title, // this works
},
legend: {
position:'bottom', // this works
textAlign: 'right', // this works
labels:{ boxWidth:10} // this works
},
tooltips: { // this works
enabled: true,
displayColors: true,
position: 'nearest',
intersect: false,
},
responsive: false,
elements: {
point: {
radius: 0
},
line: {
tension: 0, // disables bezier curves
}
},
scales: {
xAxes: [{
id: 'dates',
type: 'time',
distribution: 'linear',
scaleLabel: {
display: true, // this works
labelString: self.config.xAxisLabel, // this works
},
gridLines: {
display: false,
zeroLineColor: '#ffcc33'
},
time: {
unit: 'day',
parser: 'YYYY-MM-DD' // dates are shown on X axes correctly
},
ticks: {
display: true, // this works
maxRotation:90, // this works
minRotation:90, // this works
source: 'labels', // this works
maxTicksLimit: (self.ticklabel.length/2)+3, //10, //self.our_data[this_country].length, // this works
autoSkip: true, // this works
fontSize: 10 // this does NOT work
},
}
],
yAxes: [
{
display: true,
scaleLabel: {
display: true, // this works
labelString: self.config.yAxisLabel, // this works
},
gridLines: {
display: false,
},
ticks: {
beginAtZero: true, // this works
source: 'data', // this works
min: self.config.ranges.min, // 500 (numbers range from 1500-1650 currently
suggestedMax: self.config.ranges.max, //2000
stepSize: self.config.ranges.stepSize, // 200
fontSize: 10 // this does NOT work
},
},
]
},
}
the code for each dataset
__$ds.push({
xAxisID: 'dates',
data: self.chartdata[metal], // < ----- data for this dataset
fill: false, // just line
borderColor: self.config.line_colors[metal], // propser color shown
backgroundColor: self.config.line_colors[metal], // proper color shown
label: metal, // this shows on chart
showInLegend: true, // shows in legend
})
using 2.5.0, but 2.9.3 acts the same way
sample of data
{"gold":[{"x":"2020-01-01","y":1560},{"x":"2020-01-02","y":1560},{"x":"2020-01-03","y":1560},{"x":"2020-01-04","y":1560},{"x":"2020-01-05","y":1560},{"x":"2020-01-06","y":1560},{"x":"2020-01-07","y":1560},{"x":"2020-01-08","y":1560},{"x":"2020-01-09","y":1560},{"x":"2020-01-10","y":1560},{"x":"2020-01-11","y":1560},{"x":"2020-01-12","y":1560},{"x":"2020-01-13","y":1560},{"x":"2020-01-14","y":1560},{"x":"2020-01-15","y":1560},{"x":"2020-01-16","y":1560},{"x":"2020-01-17","y":1560},{"x":"2020-01-18","y":1560},{"x":"2020-01-19","y":1560},{"x":"2020-01-20","y":1560},{"x":"2020-01-21","y":1560},{"x":"2020-01-22","y":1560},{"x":"2020-01-23","y":1560},{"x":"2020-01-24","y":1560},{"x":"2020-01-25","y":1560},{"x":"2020-01-26","y":1560},{"x":"2020-01-27","y":1560},{
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Change the chart text font - Microsoft Support
Right click the chart title and click Font. Right-click menu shown when clicking a chart title. Click the Font tab, and enter the...
Read more >How to change default font size in R chart - Stack Overflow
I am trying to change the font size of the species, the title and the legend to no avail on the heat map...
Read more >FAQ-152 How to keep the font size from changing ... - OriginLab
Fix font size when layer size changes This is because the default Scale Elements setting on Size tab at the Layer level in...
Read more >large font size on volume on DOM - Support Board - Sierra Chart
The trick is that you have to set the font size >= 5 according to the link from Engineering above. Very counterintuitive but...
Read more >Fixing Your Font Size! - The Wonder of Tech »
To select the minimum default font size, click on Tools/Options in Windows, or Preferences on a Mac, then Content. In the Fonts &...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i’ll close this now, as not a chartjs issue… rather user error or canvas, whatever. thanks so much for your time and thought provoking commentary
i had set the size of the canvas, and the parent containing div, and its parent containing div… so the size info was available (400x400)