Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Chart.js 多轴折线图_Chart.js - Fatal编程技术网

Chart.js 多轴折线图

Chart.js 多轴折线图,chart.js,Chart.js,我在使用y1量表获取数据集2(分数)时遇到问题,它似乎对第一个数据集使用了量表。错误在哪里?我认为使用两个y尺度应该可以解决两个完全不同的数据集的问题,但我只从“完成的”数据集中获得值,所以我假设“分数”的数据在那里,但远远高于尺度 const CHART = document.getElementById("statChart"); let statChart = new Chart(CHART, { type: 'line', data: {

我在使用y1量表获取数据集2(分数)时遇到问题,它似乎对第一个数据集使用了量表。错误在哪里?我认为使用两个y尺度应该可以解决两个完全不同的数据集的问题,但我只从“完成的”数据集中获得值,所以我假设“分数”的数据在那里,但远远高于尺度

const CHART = document.getElementById("statChart");

let statChart = new Chart(CHART, {
    type: 'line',

    data: {
        labels: ["1", "2", "3", "4", "5", "6", "7"],
        datasets: [
            {
                type: 'line',
                label: "Completed",
                yAxesID: 'y',
                fill: false,
                lineTension: 0.1,
                backgroundColor: "rgba(75, 192, 192, 0.4)",
                borderColor: "rgba(75, 192, 192, 1)",
                borderCapStyle: 'butt',
                borderDash: [],
                borderDashOffset: 0.0,
                borderJoinStyle: 'miter',
                pointBorderColor: "rgba(75,192,192,1)",
                pointBackgroundColor: "#fff",
                pointBorderWidth: 1,
                pointHoverRadius: 5,
                pointHitRadius: 10,
                data: [65, 59, 80, 81, 56, 55, 40]
            },
            {
                type: 'line',
                label: "Score",
                yAxesID: 'y1',
                fill: false,
                lineTension: 0.1,
                backgroundColor: "rgba(75, 192, 192, 0.4)",
                borderColor: "rgba(75, 192, 192, 1)",
                borderCapStyle: 'butt',
                borderDash: [],
                borderDashOffset: 0.0,
                borderJoinStyle: 'miter',
                pointBorderColor: "rgba(75,192,192,1)",
                pointBackgroundColor: "#fff",
                pointBorderWidth: 1,
                pointHoverRadius: 5,
                pointHitRadius: 10,
                data: [8500, 8900, 8000, 8100, 5600, 5500, 4900]
            }
        ]},


    options: {
    responsive: true,
    interaction: {
      mode: 'index',
      intersect: false,
    },
    plugins:{
    title: {
      display: true,
      text: 'Your Result'
    },
    tooltips: {
      mode: 'nearest',
      intersect: true,
    },},

    scales: {
      y: {
        type: 'linear',
        display: true,
        position: 'left',
        min: 0,
        max: 100
      },
      y1: {
        type: 'linear',
        display: true,
        position: 'right',
        min: 0,
        max: 10000,
        // grid line settings
        grid: {
          drawOnChartArea: false, // only want the grid lines for one axis to show up
        }
      }
    }
  }
});

您有一个输入错误,
yAxesID
应该是
yAxisID
,如果您更改它,它将正常工作,如下面的示例所示:

const CHART=document.getElementById(“statChart”);
让statChart=新图表(图表{
键入:“行”,
数据:{
标签:[“1”、“2”、“3”、“4”、“5”、“6”、“7”],
数据集:[{
键入:“行”,
标签:“已完成”,
yAxisID:'y',
填充:假,
线张力:0.1,
背景色:“rgba(751921920.4)”,
边框颜色:“rgba(75192192,1)”,
borderCapStyle:“butt”,
borderDash:[],
borderDashOffset:0.0,
borderJoinStyle:'斜接',
pointBorderColor:“rgba(75192192,1)”,
pointBackgroundColor:#fff“,
点边界宽度:1,
点半径:5,
点半径:10,
数据:[65,59,80,81,56,55,40]
},
{
键入:“行”,
标签:“得分”,
yAxisID:'y1',
填充:假,
线张力:0.1,
背景色:“rgba(751921920.4)”,
边框颜色:“rgba(75192192,1)”,
borderCapStyle:“butt”,
borderDash:[],
borderDashOffset:0.0,
borderJoinStyle:'斜接',
pointBorderColor:“rgba(75192192,1)”,
pointBackgroundColor:#fff“,
点边界宽度:1,
点半径:5,
点半径:10,
数据:[8500890080008100560055004900]
}
]
},
选项:{
回答:是的,
互动:{
模式:“索引”,
交集:错,
},
插件:{
标题:{
显示:对,
文本:“您的结果”
},
工具提示:{
模式:“最近的”,
是的,
},
},
比例:{
y:{
类型:'线性',
显示:对,
位置:'左',
分:0,,
最高:100
},
y1:{
类型:'线性',
显示:对,
位置:'右',
分:0,,
最高:10000,
//网格线设置
网格:{
drawOnChartArea:false,//只希望显示一个轴的网格线
}
}
}
}
});

Ohhh。打字错误。它总是一个拼写错误:)就像一个符咒。谢谢你的回答!