簡體   English   中英

如何在折線圖中標記x和y軸

[英]how to label the x and y axis - in a line graph

我正在使用js和chart.js ,我正在嘗試標記我的x和y軸,無論哪個示例我都沒有嘗試,在我的代碼中有幾個示例1.使用labels更改,2,使用label更改axes ..如何命名我的x和y?

var vtx = document.getElementById("nowChart").getContext("2d");

var myChart = new Chart(vtx, {
    type: 'line',
    labels: [{ xLabels: "Days" }, {yLabels:"Ways"} ],
    data: {
        datasets: [{
            label: 'IBM graph',
            data: mydata,
            showLine: true,
            pointBackgroundColor: "#00ff11",
            pointBorderWidth: 1,

        }]
    },
    options: {
        scales: {
            xAxes: [{
                type: 'linear',
                position: 'bottom',
                ticks: {
                    beginAtZero: true
                },
                label:"Days"

            }],
            yAxes: [{
                type: 'linear',
                position: 'left',
                stacked: true,
                ticks: {
                    beginAtZero: true
                },
                label: "Rays"
            }]
        }
    }
});

您的配置看起來不對。 看一下chart.js 折線圖示例 ,看看如何正確執行此操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM