新Chartjs不显示零值

时间:2018-10-25 17:39:23

标签: chart.js chartjs-2.6.0

我有一个日期完全为零的图表,我希望它显示值为零时的条形。.我在下面所做的不起作用...

注意:这是一个所有值均为零的图形,但是会有带有正负值和零的图形,它应显示条形但值为零(如果值为零,则为零)

addInitialOptions(){
    // General Configuration
    this.graphInstance.options.legend.display = false;
    // Configuration of the Axes-Y (Vertical)
    this.graphInstance.options.scales.yAxes[0].ticks.fontColor      = 'white';
    this.graphInstance.options.scales.yAxes[0].ticks.min = 0;
    this.graphInstance.options.scales.yAxes[0].ticks.max = 13;
    this.graphInstance.options.scales.yAxes[0].ticks.stepSize = 1;
    this.graphInstance.options.scales.yAxes[0].ticks.beginAtZero    = true;
    this.graphInstance.options.scales.yAxes[0].display              = false;
    this.graphInstance.options.scales.yAxes[0].gridLines.display    = false;
    this.graphInstance.options.scales.yAxes[0].gridLines.drawBorder = false;

    // Configuration of the Axes-X (Horizontal)
    this.graphInstance.options.scales.xAxes[0].ticks.fontColor      = 'white';
    this.graphInstance.options.scales.xAxes[0].ticks.min = 0;
    this.graphInstance.options.scales.xAxes[0].ticks.max = 13;
    this.graphInstance.options.scales.xAxes[0].ticks.stepSize = 1;
    this.graphInstance.options.scales.xAxes[0].ticks.beginAtZero    = true;
    this.graphInstance.options.scales.xAxes[0].display              = true;
    this.graphInstance.options.scales.xAxes[0].gridLines.display    = false;
    this.graphInstance.options.scales.xAxes[0].gridLines.drawBorder = false;
}

addInitialData(){
    this.graphInstance.data = {
        labels: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov'],
        datasets: [{
            label:           'INICIO',
            data:            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            backgroundColor: this.bgColor,
            borderColor:     this.borderColor,
            borderWidth:     1
        }]
    };
}

enter image description here

0 个答案:

没有答案