I am creating my control panel and liked to create a chart to show data from my table but is giving me this error. Uncaught ReferenceError: Chart is not defined I do not know much about javascript. If anyone could help me grateful.
Html
<div class="box-body no-padding">
<canvas id="canvas" height="450" width="610"></canvas>
</div><!-- /.box-body -->
My script
<script>
var PieChart = [
{
value: 40,
color:"#fcc79e"
},
{
value : 30,
color : "#beefd2"
},
{
value : 90,
color : "#ffddfb"
}
];
var myPieChart = new Chart(document.getElementById("canvas").getContext("2d")).Pie(PieChart);
</script>
I am creating my control panel and liked to create a chart to show data from my table but is giving me this error. Uncaught ReferenceError: Chart is not defined I do not know much about javascript. If anyone could help me grateful.
Html
<div class="box-body no-padding">
<canvas id="canvas" height="450" width="610"></canvas>
</div><!-- /.box-body -->
My script
<script>
var PieChart = [
{
value: 40,
color:"#fcc79e"
},
{
value : 30,
color : "#beefd2"
},
{
value : 90,
color : "#ffddfb"
}
];
var myPieChart = new Chart(document.getElementById("canvas").getContext("2d")).Pie(PieChart);
</script>
Share
Improve this question
edited Dec 16, 2015 at 0:32
Karl
5,47311 gold badges46 silver badges71 bronze badges
asked Dec 15, 2015 at 19:09
Jose CerejoJose Cerejo
2311 gold badge5 silver badges19 bronze badges
4
- 1 check this stackoverflow./questions/29785623/… – Farhan Commented Dec 15, 2015 at 19:11
- I tried with that plete code that works and gives me this error on the last line new Chart(rice).Line(riceData); – Jose Cerejo Commented Dec 15, 2015 at 19:16
- try code i have posted in answer – Farhan Commented Dec 15, 2015 at 19:16
- I tried with your code jsfiddle/mahmalsami/jqcthmyo – Jose Cerejo Commented Dec 15, 2015 at 19:19
1 Answer
Reset to default 1Update your library. I have test this and working.
<div class="box-body no-padding">
<canvas id="canvas" height="450" width="610"></canvas>
</div>
<script src="https://raw.githubusercontent./nnnick/Chart.js/master/Chart.min.js" ></script>
<script>
var PieChart = [
{
value: 40,
color:"#fcc79e"
},
{
value : 30,
color : "#beefd2"
},
{
value : 90,
color : "#ffddfb"
}
];
var myPieChart = new Chart(document.getElementById("canvas").getContext("2d")).Pie(PieChart);
</script>