Home Forums Chart Support What if, all y : data is 0 ? Reply To: What if, all y : data is 0 ?

#18584

@sanjoy,

I did this to achieve my functionality..

function showDefaultText(chart, text){
	 var dataPoints = chart.options.data[0].dataPoints;
   var isEmpty = !(dataPoints && dataPoints.length > 0);
   
   if(!isEmpty){
   	for(var i = 0; i < dataPoints.length; i++){
      isEmpty = !dataPoints[i].y;
      dataPoints[i].indexLabel = '';
    	if(!isEmpty)
        break;
    }
   }
  
   if(!chart.options.subtitles)
   	chart.options.subtitles = [];
   if(isEmpty)
   	chart.options.subtitles.push({
     text : text,
     verticalAlign : 'center',
   });
   else
   	chart.options.subtitles = [];
 }

Let me know if there is better way of doing it.

nik.sol