简体   繁体   English

我放在折线图选项中的所有内容都不起作用

[英]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.

相关问题 如何将其置于实时状态?我已经把(async:True)但它不起作用 - How do I put this on Real-Time? I already put (async: True) but it doesnt work 我无法对数组中的数字进行排序(尝试了此处编写的所有内容,stil无法正常工作) - I can't sort numbers in an array (tried everything that was written here, stil doesnt work) 将2个折线图放入一个Google图表 - Put 2 line charts to one Google Chart 将选项输出到选择的小 javascript 不起作用 - small javascript to output options to a select doesnt work 为什么 discord 机器人可以使用默认表情符号,而当我放置自定义表情符号时不起作用? - Why discord bot works with default emojis and when i put custom emojis doesnt work? Charts.js 缩放 yaxes ticks min max 不起作用 - Charts.js scales yaxes ticks min max doesnt work 使折线图y轴起作用? - Making line charts y-axis work? 我试图为学校开一张彩票,但是当我不得不画数字时,它不起作用(第59行) - Im trying to make a lottoticket for school, but when i have to draw the numbers it doesnt work(line 59) Cosmos DB 中的 MaxItemCount 提要选项属性不起作用 - MaxItemCount feed options property in Cosmos DB doesnt work Google图表向图表添加选项 - Google Charts adding options to the charts
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM