Home Forums StockChart Support limit the number of indexLabel displayed Reply To: limit the number of indexLabel displayed

#35899

@ben551445,

It is possible to display the indexLabel on the last dataPoint by finding the index of the last dataPoint in the current viewport Range as shown in this code-snippet below,

for(var i = 0; i < stockChart.charts[0].data[0].dataPoints.length; i++) {
   if(stockChart.charts[0].data[0].dataPoints[i].x > stockChart.charts[0].axisX[0].viewportMinimum && stockChart.charts[0].data[0].dataPoints[i].x < stockChart.charts[0].axisX[0].viewportMaximum) {
      lastDataPointIndex = i;
      noOfDataPoints++; 
   }       
}

Kindly take a look at this updated JSFiddle for an example on the same.


Adithya Menon
Team CanvasJS