Forum Replies Created by Rietveld

Viewing 1 post (of 1 total)
  • in reply to: A variable for dataPoints #15767

    Hi, i have the almost the same question.
    The following code is working:

    <script type="text/javascript">
    							  window.onload = function () {
    								var data = [
    									{ Name: "Open System", Total: os },
    									{ Name: "Rationeel", Total: r },
    									{ Name: "Intern Proces", Total: ip },
    									{ Name: "Human Relations", Total: hr }
    									];
    
    								var dps=[];
    								$.each(data, function (i, item) {
    									dps.push({label: item.Name, y: item.Total });
    									//alert(dps[0]);
    								});
    								
    								var chart = new CanvasJS.Chart("chartContainer",
    								{        
    								  data: [
    								  {
    									type: "column",
    									dataPoints: dps
    								  }
    								  ],
    								  title:{
    									text: "De vier kwadranten"
    								  },
    								  axisY:{			  
    									stripLines:[
    									{                
    										value:4
    									}
    									]                    
    								}, 
    								});
    								
    								chart.render();
    							  }
    							  </script>

    Only the variables for Total aren’t working.
    The variables are in my code like this:

    var os = "<?php echo $os; ?>";
    					var r = "<?php echo $r; ?>";
    					var ip = "<?php echo $ip; ?>";
    					var hr = "<?php echo $hr; ?>";

    Can you solve my problem? I want the php-variables in the chart.
    The php tot js variable lines are working, so the problem is in the code of the chart.

Viewing 1 post (of 1 total)