Home Forums Chart Support Possible to show fewer datapoints on mobile? Reply To: Possible to show fewer datapoints on mobile?

#42375

@elitriona,

Showing fewer datapoints based on the screen size of the device is not available as an inbuilt feature as of now. However, you can achieve the same with a few lines of code. Please check the code snippet below.

var screenWidth = jQuery(window).width();
var dpsCount = 6;            //no. of datapoints to be displayed on phone
var dps = [];

if(screenWidth <= 768 ) {
  for(var i = 0; i < dpsCount; i++) {
     dps.push(chart.options.data[0].dataPoints[i]);
  }
  chart.options.data[0].dataPoints = dps;
  chart.render();
} 

Please check this JSFiddle for a working example.


Thangaraj Raman
Team CanvasJS