Skip to content

Commit 8db1646

Browse files
authored
Merge pull request #6144 from njwhite/dev-griddash
`griddash`
2 parents 45a1d0f + 0bafc90 commit 8db1646

19 files changed

+547
-9
lines changed

draftlogs/6144_add.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add `griddash` axis property to cartesian, polar, smith, ternary and geo subplots and add `griddash` and `minorgriddash` to `carpet` trace [[6144](https://github.com/plotly/plotly.js/pull/6144)], with thanks to @njwhite for the contribution!

src/plots/cartesian/axes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,7 @@ axes.drawTicks = function(gd, ax, opts) {
28692869
* - {boolean} showgrid
28702870
* - {string} gridcolor
28712871
* - {string} gridwidth
2872+
* - {string} griddash
28722873
* - {boolean} zeroline
28732874
* - {string} type
28742875
* - {string} dtick
@@ -2918,6 +2919,7 @@ axes.drawGrid = function(gd, ax, opts) {
29182919
grid.attr('transform', opts.transFn)
29192920
.attr('d', opts.path)
29202921
.call(Color.stroke, ax.gridcolor || '#ddd')
2922+
.style('stroke-dasharray', Drawing.dashStyle(ax.griddash, ax.gridwidth))
29212923
.style('stroke-width', ax._gw + 'px')
29222924
.style('display', null); // visible
29232925

src/plots/cartesian/layout_attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ module.exports = {
797797
editType: 'ticks',
798798
description: 'Sets the width (in px) of the grid lines.'
799799
},
800+
griddash: extendFlat({}, dash, {editType: 'ticks'}),
800801
zeroline: {
801802
valType: 'boolean',
802803
editType: 'ticks',

src/plots/cartesian/line_grid_defaults.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer
3535
var gridColorDflt = colorMix(dfltColor, opts.bgColor, opts.blend || lightFraction).toRgbString();
3636
var gridColor = coerce2('gridcolor', gridColorDflt);
3737
var gridWidth = coerce2('gridwidth');
38-
var showGridLines = coerce('showgrid', opts.showGrid || !!gridColor || !!gridWidth);
38+
var gridDash = coerce2('griddash');
39+
var showGridLines = coerce('showgrid', opts.showGrid || !!gridColor || !!gridWidth || !!gridDash);
3940

4041
if(!showGridLines) {
4142
delete containerOut.gridcolor;
4243
delete containerOut.gridwidth;
44+
delete containerOut.griddash;
4345
}
4446

4547
if(!opts.noZeroLine) {

src/plots/geo/geo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ proto.updateBaseLayers = function(fullLayout, geoLayout) {
367367
} else if(isAxisLayer(d)) {
368368
path.datum(makeGraticule(d, geoLayout, fullLayout))
369369
.call(Color.stroke, geoLayout[d].gridcolor)
370-
.call(Drawing.dashLine, '', geoLayout[d].gridwidth);
370+
.call(Drawing.dashLine, geoLayout[d].griddash, geoLayout[d].gridwidth);
371371
}
372372

373373
if(isLineLayer(d)) {

src/plots/geo/layout_attributes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var colorAttrs = require('../../components/color/attributes');
44
var domainAttrs = require('../domain').attributes;
5+
var dash = require('../../components/drawing/attributes').dash;
56
var constants = require('./constants');
67
var overrideAll = require('../../plot_api/edit_types').overrideAll;
78
var sortObjectKeys = require('../../lib/sort_object_keys');
@@ -50,7 +51,8 @@ var geoAxesAttrs = {
5051
description: [
5152
'Sets the graticule\'s stroke width (in px).'
5253
].join(' ')
53-
}
54+
},
55+
griddash: dash
5456
};
5557

5658
var attrs = module.exports = overrideAll({

src/plots/geo/layout_defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
8787
if(show) {
8888
coerce(axisName + '.gridcolor');
8989
coerce(axisName + '.gridwidth');
90+
coerce(axisName + '.griddash');
9091
}
9192

9293
// mock axis for autorange computations

src/plots/polar/layout_attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ var axisLineGridAttr = overrideAll({
1313
linewidth: axesAttrs.linewidth,
1414
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
1515
gridcolor: axesAttrs.gridcolor,
16-
gridwidth: axesAttrs.gridwidth
16+
gridwidth: axesAttrs.gridwidth,
17+
griddash: axesAttrs.griddash
1718

1819
// TODO add spike* attributes down the road
1920

src/plots/smith/layout_attributes.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ var axisLineGridAttr = overrideAll({
1313
linewidth: axesAttrs.linewidth,
1414
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
1515
gridcolor: axesAttrs.gridcolor,
16-
gridwidth: axesAttrs.gridwidth
16+
gridwidth: axesAttrs.gridwidth,
17+
griddash: axesAttrs.griddash
1718
}, 'plot', 'from-root');
1819

1920
var axisTickAttrs = overrideAll({

src/plots/ternary/layout_attributes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var ternaryAxesAttrs = {
4747
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
4848
gridcolor: axesAttrs.gridcolor,
4949
gridwidth: axesAttrs.gridwidth,
50+
griddash: axesAttrs.griddash,
5051
layer: axesAttrs.layer,
5152
// range
5253
min: {

0 commit comments

Comments
 (0)