어떤 이유로 인해 동일한 페이지에서 여러 chart.js 차트를로드하는 방법을 알 수 없습니다. 하나는 제대로로드 할 수 있지만, 더 추가하면로드되지 않습니다. 내가 뭘 잘못하고 있는지에 대한 어떤 생각?여러 chart.js 차트를 동일한 페이지에로드하려고 시도합니다
<div class="game-cards col-lg-5">
<div class="chart-container">
<canvas id="myChart" width="500" height="500"></canvas>
</div>
<div class="right-info">
<h4>Iowa State vs Iowa</h4>
<h5 id="time-channel">11:00 AM - Channel Goes here</h5>
<div class="total-points-live">
<h5>Total Points Bet</h5>
<h5 id="point-total">20,000</h5>
<p class="bet-button">Click To Place Bet</p>
</div>
</div>
<div>
<input class="bet-input" type="text" name="betAmount" placeholder="Wager Amount">
</div>
</div>
<div class="game-cards col-lg-5">
<div class="chart-container">
<canvas id="myChart" width="500" height="500"></canvas>
</div>
<div class="right-info">
<h4>Iowa State vs Iowa</h4>
<h5 id="time-channel">11:00 AM - Channel Goes here</h5>
<div class="total-points-live">
<h5>Total Points Bet</h5>
<h5 id="point-total">20,000</h5>
<p class="bet-button">Click To Place Bet</p>
</div>
</div>
<div>
<input class="bet-input" type="text" name="betAmount" placeholder="Wager Amount">
</div>
</div>
이 당신은 클래스와 ID를 전환하거나 고유 한 사용자 ID를
어쩌면 초 처음에 id="myChart"
및 id="myChart2"
를 사용할 수 있도록하는 데 필요한 자바 스크립트
window.onload = function() {
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ["Iowa", "Iowa State"],
datasets: [{
backgroundColor: [
"#CC0000",
"#F1BE48",
],
data: [2000, 9000]
}]
},
options: {
responsive: true
, maintainAspectRatio: false
}
});
}
예, 감사합니다. 왠지 내 머리가 어젯밤에 작동하지 않았기 때문에 간단한 대답에 감사드립니다. – Branduo
걱정하지 않아도됩니다. :) – Deano