Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dissociate border options from grid options #8823

Merged
merged 2 commits into from Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/core.scale.defaults.js
Expand Up @@ -35,8 +35,7 @@ defaults.set('scale', {
offset: false,
borderDash: [],
borderDashOffset: 0.0,
borderColor: (_ctx, options) => options.color,
borderWidth: (_ctx, options) => options.lineWidth
borderWidth: 1
},

// scale title
Expand Down Expand Up @@ -77,6 +76,7 @@ defaults.set('scale', {

defaults.route('scale.ticks', 'color', '', 'color');
defaults.route('scale.grid', 'color', '', 'borderColor');
defaults.route('scale.grid', 'borderColor', '', 'borderColor');
defaults.route('scale.title', 'color', '', 'color');

defaults.describe('scale', {
Expand Down
7 changes: 3 additions & 4 deletions src/core/core.scale.js
Expand Up @@ -1356,7 +1356,7 @@ export default class Scale extends Element {
const grid = me.options.grid;
const ctx = me.ctx;
const chart = me.chart;
const borderOpts = grid.setContext(me.getContext(0));
const borderOpts = grid.setContext(me.getContext());
const axisWidth = grid.drawBorder ? borderOpts.borderWidth : 0;
const items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea));
let i, ilen;
Expand Down Expand Up @@ -1407,8 +1407,7 @@ export default class Scale extends Element {

if (axisWidth) {
// Draw the line at the edge of the axis
const edgeOpts = grid.setContext(me.getContext(me._ticksLength - 1));
const lastLineWidth = edgeOpts.lineWidth;
const lastLineWidth = borderOpts.lineWidth;
const borderValue = me._borderValue;
let x1, x2, y1, y2;

Expand All @@ -1424,7 +1423,7 @@ export default class Scale extends Element {
drawLine(
{x: x1, y: y1},
{x: x2, y: y2},
{width: axisWidth, color: edgeOpts.borderColor});
{width: axisWidth, color: borderOpts.borderColor});
}
}

Expand Down
Expand Up @@ -38,6 +38,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/core.scale/x-axis-position-center.json
Expand Up @@ -24,6 +24,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand All @@ -37,6 +38,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/core.scale/x-axis-position-dynamic.json
Expand Up @@ -26,6 +26,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand All @@ -39,6 +40,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/core.scale/y-axis-position-center.json
Expand Up @@ -24,6 +24,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand All @@ -37,6 +38,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/core.scale/y-axis-position-dynamic.json
Expand Up @@ -24,6 +24,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand All @@ -39,6 +40,7 @@
"max": 100,
"grid": {
"color": "red",
"borderColor": "red",
"drawOnChartArea": false
},
"ticks": {
Expand Down