我用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