Home Forums Chart Support Multiple canvasjs charts in MVC partial views Reply To: Multiple canvasjs charts in MVC partial views

#20791

i have the same problem.
this my partial view

<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
    <script>        
        window.onload = function () {           
var chart= new CanvasJS.Chart("chart", {
    theme: "light1", // "light1", "light2", "dark1", "dark2"
    exportEnabled: true,
	animationEnabled: true,
	title: {
		text: "Analisis de Daños"
	},
	subtitles: [{
		text: "Vandrservices"
	}],
	data: [{
        type: "pie",
		startAngle: 180,
		toolTipContent: "<b>{label}</b>: {y}%",
		showInLegend: "true",
		legendText: "{label}",
		indexLabel: "{label} - {y}%",
        dataPoints: @Html.Raw(ViewBag.DataPoints)
	}]
});
            chart.render();           
}
    </script>


<div id="chart" style="height: 300px; width: 100%;"></div>

and i used in a a index page to create many chart, but only show the last one, i am working with mvc.