[英]Responsive Layout Issues - ONLY present on iPad. Unsure how to resolve
[英]Curve color is dark grey instead of red on iPad. How to solve this?
我想在下面繪制這種曲線,但不適用於Ipad。 顏色顯示為灰色。
是ChartJS的錯誤,還是我們可以做些什么?
當類型的值為“線”時出現此問題。
當類型的值為“ bar”時,它可在Ipad上使用。
您是否有解決此問題的方法?
var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'line', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3], backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ], borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } });
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.bundle.min.js"></script> <div class="chart-container" style="position: relative; margin-top:30px; height:60vh; width:90vh"> <canvas id="myChart"></canvas>
問題來自backgroundColor和borderColor中的列表。
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: 'rgba(255, 159, 64, 0.2)',
borderColor: 'rgba(255,99,132,1)',
borderWidth: 1
}
確實,對於等於bar的種類,我們可以為每個標簽使用一種顏色。
對於“行”而言,似乎我們不能只包含一個值的列表。
曲線下只能有一種顏色,邊框只能有一種顏色。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.