| `drawOnChartArea` | `boolean` | `true` | If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn.
| `drawTicks` | `boolean` | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
| `tickMarkLength` | `number` | `10` | Length in pixels that the grid lines will draw into the axis area.
-| `zeroLineWidth` | `number` | `1` | Stroke width of the grid line for the first index (index 0).
-| `zeroLineColor` | `Color` | `'rgba(0, 0, 0, 0.25)'` | Stroke color of the grid line for the first index (index 0).
-| `zeroLineBorderDash` | `number[]` | `[]` | Length and spacing of dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
-| `zeroLineBorderDashOffset` | `number` | `0.0` | Offset for line dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
| `offsetGridLines` | `boolean` | `false` | If true, grid lines will be shifted to be between labels. This is set to `true` for a bar chart by default.
| `z` | `number` | `0` | z-index of gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
### Customizability
* `custom` attribute of elements was removed. Please use scriptable options
+* The `zeroLine*` options of axes were removed.
### Options
drawOnChartArea: true,
drawTicks: true,
tickMarkLength: 10,
- zeroLineWidth: 1,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
offsetGridLines: false,
borderDash: [],
borderDashOffset: 0.0
}
var Scale = Element.extend({
-
- zeroLineIndex: 0,
-
/**
* Parse a supported input value to internal representation.
* @param {*} raw
return alignPixel(chart, pixel, axisWidth);
};
var borderValue, i, tick, lineValue, alignedLineValue;
- var tx1, ty1, tx2, ty2, x1, y1, x2, y2, lineWidth, lineColor, borderDash, borderDashOffset;
+ var tx1, ty1, tx2, ty2, x1, y1, x2, y2;
if (position === 'top') {
borderValue = alignBorderValue(me.bottom);
for (i = 0; i < ticksLength; ++i) {
tick = ticks[i] || {};
- if (i === me.zeroLineIndex && options.offset === offsetGridLines) {
- // Draw the first index specially
- lineWidth = gridLines.zeroLineWidth;
- lineColor = gridLines.zeroLineColor;
- borderDash = gridLines.zeroLineBorderDash || [];
- borderDashOffset = gridLines.zeroLineBorderDashOffset || 0.0;
- } else {
- lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
- lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
- borderDash = gridLines.borderDash || [];
- borderDashOffset = gridLines.borderDashOffset || 0.0;
- }
+ const lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
+ const lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
+ const borderDash = gridLines.borderDash || [];
+ const borderDashOffset = gridLines.borderDashOffset || 0.0;
lineValue = getPixelForGridLine(me, tick._index || i, offsetGridLines);
generateTickLabels: function(ticks) {
var me = this;
me._tickValues = ticks.map(t => t.value);
- me.zeroLineIndex = me._tickValues.indexOf(0);
-
Scale.prototype.generateTickLabels.call(me, ticks);
},
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
- "color": "rgba(0, 0, 0, 1)",
- "zeroLineColor": "rgba(0, 0, 0, 1)"
+ "color": "rgba(0, 0, 0, 1)"
}
}, {
"type": "category",
"gridLines":{
"drawOnChartArea": false,
"drawBorder": false,
- "color": "rgba(0, 0, 0, 1)",
- "zeroLineColor": "rgba(0, 0, 0, 1)"
+ "color": "rgba(0, 0, 0, 1)"
}
}],
"yAxes": [{
lineWidth: 1,
offsetGridLines: false,
display: true,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineWidth: 1,
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
borderDash: [],
borderDashOffset: 0.0
},
lineWidth: 1,
offsetGridLines: false,
display: true,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineWidth: 1,
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
borderDash: [],
borderDashOffset: 0.0
},
lineWidth: 1,
offsetGridLines: false,
display: true,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineWidth: 1,
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
borderDash: [],
borderDashOffset: 0.0
},
lineWidth: 1,
offsetGridLines: false,
display: true,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineWidth: 1,
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
borderDash: [],
borderDashOffset: 0.0
},
lineWidth: 1,
offsetGridLines: false,
display: true,
- zeroLineColor: 'rgba(0,0,0,0.25)',
- zeroLineWidth: 1,
- zeroLineBorderDash: [],
- zeroLineBorderDashOffset: 0.0,
borderDash: [],
borderDashOffset: 0.0
},