question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

chart fontsize won't set, default too big

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sdetweilcommented, May 12, 2020

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

0reactions
sdetweilcommented, May 12, 2020

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found