1

I don't know if it is a regression or if I don't do it right.

I want my chart to get a black border. I found on another stackoverflow question that you need to add empty axes for that.

But I define the zeroLineColor for each of them, and this does nothing. The color is still the default.

Moreover, if I specify the gridLines color, it is that color that is used for the zeroLineColor.

Here is simple example: https://jsfiddle.net/2sLmoc1u/ No black border. Just gray or black with too much alpha

var chart = new Chart(ctx, {
  type: 'line',
  data: {
    //labels: [ 1, 2, 3, 4, 5, 6],
    datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
    }]
  },
  options: {
    responsive: false,
    legend: {
      display: false
    },
    scales: {
      xAxes: [{
        gridLines: {
          zeroLineColor: '#000',
          color: '#999', // the bottom axes is grey instead of black
        },
      }, {
        position: 'top',
        ticks: {
          display: false
        },
        gridLines: {
          zeroLineColor: '#000' // this seems to do nothing
        }
      }],
      yAxes: [{
        ticks: {
          display: false
        },
        gridLines: {
          display: false,
          drawTicks: false,
          zeroLineColor: '#000'
        }
      }, {
        position: 'right',
        ticks: {
          display: false
        },
        gridLines: {
          display: false,
          drawTicks: false,
          zeroLineColor: '#000'
        }
      }],
    }
  }
});

3 Answers 3

0

This is how achieved the color of zero line.

Chart.defaults.scale.gridLines.color = "#FFFFFF"; //white

0

Since the line is horizontal it would seem (believe me, I agree with you) that you need to put the zerLineColor on the xAxes but you need to put it on the yAxes

yAxes: [
  {
    gridLines: {
      zeroLineColor: '#000',
    }
  }
]
-1
datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
      borderColor: "rgba(0, 0, 0, 1)",
    }]

Check with the above given data sets. It can convert the color of line to black.

3
  • what you really want to do ? Commented Jun 17, 2019 at 8:50
  • border color or line color that drawn ?? Commented Jun 17, 2019 at 8:51
  • I said the border of the chart. not the plot
    – solsTiCe
    Commented Jun 17, 2019 at 9:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.