我用Chart.js创建了一些图表,它们在我的网站上[http://projetoplenario.com/proposicoes.html]。我试图在我的网站的其他html页面插入相同的图表,但它不起作用。为什么我的圆环图不是用Chart.js创建的?
例如,我们考虑第一个proposicoes.html图表。它被命名为“reformaTrabalhistaChart”。在reformaTrabalhista.html [http://projetoplenario.com/reformaTrabalhista.html]也有代码来插入图表。
但是,我不知道为什么,它不能在reformaTrabalhista.html上工作,并且对proposicoes.html起作用。
如何在reformaTrabalhista.html上插入相同的图表?
<div class="boxChart">
<a href="reformaTrabalhista.html">
<canvas id="reformaTrabalhistaChart"></canvas>
</a>
</div>
<div class="boxChart">
<canvas id="reformaTrabalhistaChart"></canvas>
</div>
var reformaTrabalhistaChart;
var data = [
{
value: 50,
color: "green"
}, {
value: 26,
color: "red"
}, {
value: 1,
color: "orange"
}, {
value: 1,
color: "purple"
}, {
value: 3,
color: "gray"
}
];
var options = {
animation: true,
animationEasing: 'easeInOutQuart',
animationSteps: 80
};
//Get the context of the canvas element we want to select
var ctx = document.getElementById("reformaTrabalhistaChart")
.getContext("2d");
reformaTrabalhistaChart = new Chart(ctx).Doughnut(data, options);
你的代码在哪里? – hurricane
我刚才包括在内 – agccaesar