Новый Chartjs не отображает значение ноль - PullRequest
0 голосов
/ 25 октября 2018

У меня есть график с полностью нулевой датой, я хотел бы, чтобы он отображал бары, когда значение было равно нулю. То, что я сделал ниже, не работает ...

Примечание: это графиксо всеми значениями в нуле, но будут графики с положительными и отрицательными значениями и нулем, он должен отображать полосу, но со значением ноль (если значение равно нулю)

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

...