Chartjs 2-categorical

时间:2018-01-15 14:18:00

标签: charts chart.js react-chartjs chartjs-2.6.0

我使用带有React的Chartjs 2成功绘制了一堆数据点,其类别为Y轴,但是想用它们的类别标签标记它们。他们目前正在展示" undefined"作为工具提示值:

enter image description here

这是我现在所做的(不工作):

labels: this.state.graphData.eventWeekArray,
datasets: [
     {
            label: title,
            labels: data,
            fill: false,
            lineTension: 0.1,
            borderColor: colorArray()[counter],
            borderCapStyle: 'butt',
            borderJoinStyle: 'miter',
            pointBorderColor: 'rgba(75,192,192,1)',
            pointBackgroundColor: '#fff',
            pointBorderWidth: 1,
            pointHoverRadius: 6,
            pointHoverBackgroundColor: 'rgba(75,192,192,1)',
            pointHoverBorderColor: 'rgba(220,220,220,1)',
            pointHoverBorderWidth: 3,
            pointRadius: 1,
            pointHitRadius: 1,
            showLine: true,
            steppedLine: true,
            spanGaps: true,
            data: data,
            year: dataYear,
            measurement: 'state'
        }
]

使用选项和scaleLabel不起作用:

const options = {
        legend: {
            display: true
        },
        scales: {
            xAxes: [
                {
                    scaleLabel: {
                        display: true,
                        labelString: 'Weeks'
                    },
                    ticks: {
                        autoSkip: true,
                        autoSkipPadding: 20
                    }
                }
            ],
            yAxes: [
                {
                    type: 'category',
                    labels: this.state.eventLabelArray
                },
                {
                    type: 'linear',
                    labels: this.state.brixLabelArray
                }
            ]
        }
    };

0 个答案:

没有答案