[英]everything i put in the options of the Line charts doesnt work
As you can see i have a mixed chart, a bar chart with a line chart.如您所见,我有一个混合图表,一个带有折线图的条形图。 i can change options of the bar chart that works perfectly fine, but when i try to put some options in the line chart it doenst work.
我可以更改条形图的选项,效果很好,但是当我尝试在折线图中放置一些选项时,它不起作用。
i already tried to merge the options and move the options around, nothing seems to work我已经尝试合并选项并移动选项,似乎没有任何效果
HTML: HTML:
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
Javascript: Javascript:
var myChart = document.getElementById("myChart");
function randomData() {
return Math.random();
}
let barChart = new Chart(myChart, {
type: 'bar',
data: {
labels: ['Test1', 'Test2', 'Test3', 'Test4', 'Test5'],
datasets: [
{
type: 'line',
label: ['line data'],
data: [randomData(), randomData(), randomData(), randomData(), randomData()],
options:{
showLine: false,
}
},{
label: ['bar data'],
data: [randomData(), randomData(), randomData(), randomData(), randomData()],
backgroundColor: [
'green',
'red',
'blue',
'purple',
'orange',
],
}],
},
options: {
title: {
display: true,
text: 'Test Chart met random nummers'
},
legend: {
position: 'right',
},
responsive: true,
},
});
I want to be able to change the options of the line chart, for example to show or hide the line or change the curves with bezierCurve.我希望能够更改折线图的选项,例如显示或隐藏线或使用 bezierCurve 更改曲线。
As you can read in the documents about the line chart , showLine
is a dataset
property.正如您在有关折线图的文档中所读到的,
showLine
是一个dataset
属性。 You use it directly in your dataset
, not under the options
property.您直接在
dataset
中使用它,而不是在options
属性下。
datasets: [{
type: 'line',
label: 'Line data',
data: [randomData(), randomData(), randomData(), randomData(), randomData()],
showLine: false
}]
Almost all other options you use in the options
property.您在
options
属性中使用的几乎所有其他选项。 tension
for Bezier curves is one of them.贝塞尔曲线的
tension
就是其中之一。
options: {
elements: {
line: {
tension: 0
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.