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

Enable borderDash option in the grid as scriptable #10519

Merged
merged 1 commit into from Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/axes/styling.md
Expand Up @@ -10,7 +10,7 @@ Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines
| ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
| `borderColor` | [`Color`](../general/colors.md) | | | `Chart.defaults.borderColor` | The color of the border line.
| `borderWidth` | `number` | | | `1` | The width of the border line.
| `borderDash` | `number[]` | | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
| `borderDash` | `number[]` | Yes | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
| `borderDashOffset` | `number` | Yes | | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
| `circular` | `boolean` | | | `false` | If true, gridlines are circular (on radar chart only).
| `color` | [`Color`](../general/colors.md) | Yes | Yes | `Chart.defaults.borderColor` | The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line, and so on.
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.scale.js
Expand Up @@ -1085,7 +1085,7 @@ export default class Scale extends Element {

const lineWidth = optsAtIndex.lineWidth;
const lineColor = optsAtIndex.color;
const borderDash = grid.borderDash || [];
const borderDash = optsAtIndex.borderDash || [];
const borderDashOffset = optsAtIndex.borderDashOffset;

const tickWidth = optsAtIndex.tickWidth;
Expand Down
35 changes: 35 additions & 0 deletions test/fixtures/core.scale/grid/scriptable-borderDash.js
@@ -0,0 +1,35 @@
module.exports = {
config: {
type: 'scatter',
options: {
scales: {
x: {
position: {y: 0},
min: -10,
max: 10,
grid: {
borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
color: 'lightGray',
lineWidth: 3,
},
ticks: {
display: false
},
},
y: {
position: {x: 0},
min: -10,
max: 10,
grid: {
borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
color: 'lightGray',
lineWidth: 3,
},
ticks: {
display: false
},
}
}
}
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion types/index.esm.d.ts
Expand Up @@ -2857,7 +2857,7 @@ export interface GridLineOptions {
/**
* @default []
*/
borderDash: number[];
borderDash: Scriptable<number[], ScriptableScaleContext>;
/**
* @default 0
*/
Expand Down