Home forums Report Bugs where do I make mistakes? Reply To: where do I make mistakes?

#19908

altayolcay
Member

I found the coding error. I still can not produce a solution. Maybe you can help? Error in the following encoding:

createPareto();	
function createPareto(){
	var dps = [];
	var yValue, yTotal = 0, yPercent = 0;

	for(var i = 0; i < chart.data[0].dataPoints.length; i++)
      {
		yTotal += chart.data[0].dataPoints[i].y; 
  }
  
	for(var i = 0; i < chart.data[0].dataPoints.length; i++){
		yValue = chart.data[0].dataPoints[i].y;
		yPercent += (yValue /yTotal  * 100);
		dps.push({label: chart.data[0].dataPoints[i].label, y: yPercent});
	}
	
	chart.addTo("data",{type:"line", yValueFormatString: "0.##\"%\"", dataPoints: dps});
	chart.data[1].set("axisYType", "secondary", false);
	chart.axisY[0].set("maximum", yTotal);
	chart.axisY2[0].set("maximum", 100);
}