Skip to content

griddash #6144

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

Merged
merged 29 commits into from
Mar 23, 2022
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd7e1ed
first go at feature
njwhite Mar 17, 2022
4d6eb7e
add log
njwhite Mar 17, 2022
f41c353
typo
njwhite Mar 17, 2022
b2432b2
update plo-schema diff
njwhite Mar 18, 2022
2180775
fix tests
njwhite Mar 18, 2022
1df0243
fix tests
njwhite Mar 18, 2022
3faa3d2
fix tests
njwhite Mar 18, 2022
64917ba
review comments
njwhite Mar 18, 2022
10e1188
try this
njwhite Mar 19, 2022
445165b
Merge remote-tracking branch 'origin/master' into dev-griddash
njwhite Mar 19, 2022
e2943dd
rename per suggestion
njwhite Mar 20, 2022
d36312f
retrigger circleci
njwhite Mar 20, 2022
fa5bf04
Merge branch 'master' into dev-griddash
archmoj Mar 23, 2022
6f9f4a6
Update src/plots/cartesian/layout_attributes.js
archmoj Mar 23, 2022
3ac8d19
Update src/plots/cartesian/layout_attributes.js
archmoj Mar 23, 2022
d7de560
Update draftlogs/6144_add.md
archmoj Mar 23, 2022
fc28192
Update src/plots/geo/layout_attributes.js
archmoj Mar 23, 2022
253aad7
Update src/plots/geo/layout_attributes.js
archmoj Mar 23, 2022
56baf0b
Update src/traces/carpet/axis_attributes.js
archmoj Mar 23, 2022
d19b0a5
Update src/traces/carpet/axis_attributes.js
archmoj Mar 23, 2022
8e058a8
Update draftlogs/6144_add.md
archmoj Mar 23, 2022
d75e27d
undo gl3d
njwhite Mar 23, 2022
db4912e
more mocks
njwhite Mar 23, 2022
980568a
generate baselines
njwhite Mar 23, 2022
e73ab39
fix tests
njwhite Mar 23, 2022
75f18fd
renaming things
njwhite Mar 23, 2022
8c29110
no gl2d
njwhite Mar 23, 2022
a1b7a86
no gl2d
njwhite Mar 23, 2022
0bafc90
no gl2d
njwhite Mar 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/6144_add.md
Original file line number Diff line number Diff line change
@@ -0,0 +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!
2 changes: 2 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
@@ -2869,6 +2869,7 @@ axes.drawTicks = function(gd, ax, opts) {
* - {boolean} showgrid
* - {string} gridcolor
* - {string} gridwidth
* - {string} griddash
* - {boolean} zeroline
* - {string} type
* - {string} dtick
@@ -2918,6 +2919,7 @@ axes.drawGrid = function(gd, ax, opts) {
grid.attr('transform', opts.transFn)
.attr('d', opts.path)
.call(Color.stroke, ax.gridcolor || '#ddd')
.style('stroke-dasharray', Drawing.dashStyle(ax.griddash, ax.gridwidth))
.style('stroke-width', ax._gw + 'px')
.style('display', null); // visible

1 change: 1 addition & 0 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
@@ -797,6 +797,7 @@ module.exports = {
editType: 'ticks',
description: 'Sets the width (in px) of the grid lines.'
},
griddash: extendFlat({}, dash, {editType: 'ticks'}),
zeroline: {
valType: 'boolean',
editType: 'ticks',
4 changes: 3 additions & 1 deletion src/plots/cartesian/line_grid_defaults.js
Original file line number Diff line number Diff line change
@@ -35,11 +35,13 @@ module.exports = function handleLineGridDefaults(containerIn, containerOut, coer
var gridColorDflt = colorMix(dfltColor, opts.bgColor, opts.blend || lightFraction).toRgbString();
var gridColor = coerce2('gridcolor', gridColorDflt);
var gridWidth = coerce2('gridwidth');
var showGridLines = coerce('showgrid', opts.showGrid || !!gridColor || !!gridWidth);
var gridDash = coerce2('griddash');
var showGridLines = coerce('showgrid', opts.showGrid || !!gridColor || !!gridWidth || !!gridDash);

if(!showGridLines) {
delete containerOut.gridcolor;
delete containerOut.gridwidth;
delete containerOut.griddash;
}

if(!opts.noZeroLine) {
2 changes: 1 addition & 1 deletion src/plots/geo/geo.js
Original file line number Diff line number Diff line change
@@ -367,7 +367,7 @@ proto.updateBaseLayers = function(fullLayout, geoLayout) {
} else if(isAxisLayer(d)) {
path.datum(makeGraticule(d, geoLayout, fullLayout))
.call(Color.stroke, geoLayout[d].gridcolor)
.call(Drawing.dashLine, '', geoLayout[d].gridwidth);
.call(Drawing.dashLine, geoLayout[d].griddash, geoLayout[d].gridwidth);
}

if(isLineLayer(d)) {
4 changes: 3 additions & 1 deletion src/plots/geo/layout_attributes.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

var colorAttrs = require('../../components/color/attributes');
var domainAttrs = require('../domain').attributes;
var dash = require('../../components/drawing/attributes').dash;
var constants = require('./constants');
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var sortObjectKeys = require('../../lib/sort_object_keys');
@@ -50,7 +51,8 @@ var geoAxesAttrs = {
description: [
'Sets the graticule\'s stroke width (in px).'
].join(' ')
}
},
griddash: dash
};

var attrs = module.exports = overrideAll({
1 change: 1 addition & 0 deletions src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ function handleGeoDefaults(geoLayoutIn, geoLayoutOut, coerce, opts) {
if(show) {
coerce(axisName + '.gridcolor');
coerce(axisName + '.gridwidth');
coerce(axisName + '.griddash');
}

// mock axis for autorange computations
3 changes: 2 additions & 1 deletion src/plots/polar/layout_attributes.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,8 @@ var axisLineGridAttr = overrideAll({
linewidth: axesAttrs.linewidth,
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
gridcolor: axesAttrs.gridcolor,
gridwidth: axesAttrs.gridwidth
gridwidth: axesAttrs.gridwidth,
griddash: axesAttrs.griddash

// TODO add spike* attributes down the road

3 changes: 2 additions & 1 deletion src/plots/smith/layout_attributes.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,8 @@ var axisLineGridAttr = overrideAll({
linewidth: axesAttrs.linewidth,
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
gridcolor: axesAttrs.gridcolor,
gridwidth: axesAttrs.gridwidth
gridwidth: axesAttrs.gridwidth,
griddash: axesAttrs.griddash
}, 'plot', 'from-root');

var axisTickAttrs = overrideAll({
1 change: 1 addition & 0 deletions src/plots/ternary/layout_attributes.js
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ var ternaryAxesAttrs = {
showgrid: extendFlat({}, axesAttrs.showgrid, {dflt: true}),
gridcolor: axesAttrs.gridcolor,
gridwidth: axesAttrs.gridwidth,
griddash: axesAttrs.griddash,
layer: axesAttrs.layer,
// range
min: {
5 changes: 5 additions & 0 deletions src/traces/carpet/axis_attributes.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@ var colorAttrs = require('../../components/color/attributes');
var axesAttrs = require('../../plots/cartesian/layout_attributes');
var descriptionWithDates = require('../../plots/cartesian/axis_format_attributes').descriptionWithDates;
var overrideAll = require('../../plot_api/edit_types').overrideAll;
var dash = require('../../components/drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;


module.exports = {
color: {
@@ -359,6 +362,7 @@ module.exports = {
editType: 'calc',
description: 'Sets the width (in px) of the axis line.'
},
griddash: extendFlat({}, dash, {editType: 'calc'}),
showgrid: {
valType: 'boolean',
dflt: true,
@@ -382,6 +386,7 @@ module.exports = {
editType: 'calc',
description: 'Sets the width (in px) of the grid lines.'
},
minorgriddash: extendFlat({}, dash, {editType: 'calc'}),
minorgridcolor: {
valType: 'color',
dflt: colorAttrs.lightLine,
5 changes: 5 additions & 0 deletions src/traces/carpet/axis_defaults.js
Original file line number Diff line number Diff line change
@@ -138,11 +138,13 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)

var gridColor = coerce2('gridcolor', addOpacity(dfltColor, 0.3));
var gridWidth = coerce2('gridwidth');
var gridDash = coerce2('griddash');
var showGrid = coerce('showgrid');

if(!showGrid) {
delete containerOut.gridcolor;
delete containerOut.gridwidth;
delete containerOut.griddash;
}

var startLineColor = coerce2('startlinecolor', dfltColor);
@@ -166,13 +168,16 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options)
if(!showGrid) {
delete containerOut.gridcolor;
delete containerOut.gridwidth;
delete containerOut.griddash;
} else {
coerce('minorgridcount');
coerce('minorgridwidth', gridWidth);
coerce('minorgriddash', gridDash);
coerce('minorgridcolor', addOpacity(gridColor, 0.06));

if(!containerOut.minorgridcount) {
delete containerOut.minorgridwidth;
delete containerOut.minorgriddash;
delete containerOut.minorgridcolor;
}
}
12 changes: 8 additions & 4 deletions src/traces/carpet/calc_gridlines.js
Original file line number Diff line number Diff line change
@@ -225,7 +225,8 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) {
if(j < 0 || j > data.length - 1) continue;
gridlines.push(extendFlat(constructArrayGridline(j), {
color: axis.gridcolor,
width: axis.gridwidth
width: axis.gridwidth,
dash: axis.griddash
}));
}

@@ -256,7 +257,8 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) {
if(v < data[0] || v > data[data.length - 1]) continue;
minorgridlines.push(extendFlat(constructValueGridline(v), {
color: axis.minorgridcolor,
width: axis.minorgridwidth
width: axis.minorgridwidth,
dash: axis.minorgriddash
}));
}
}
@@ -299,7 +301,8 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) {

gridlines.push(extendFlat(constructValueGridline(value), {
color: axis.gridcolor,
width: axis.gridwidth
width: axis.gridwidth,
dash: axis.griddash
}));
}

@@ -311,7 +314,8 @@ module.exports = function calcGridlines(trace, axisLetter, crossAxisLetter) {
if(v < data[0] || v > data[data.length - 1]) continue;
minorgridlines.push(extendFlat(constructValueGridline(v), {
color: axis.minorgridcolor,
width: axis.minorgridwidth
width: axis.minorgridwidth,
dash: axis.minorgriddash
}));
}
}
1 change: 1 addition & 0 deletions src/traces/carpet/plot.js
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ function drawGridLines(xaxis, yaxis, layer, axis, axisLetter, gridlines) {
el.attr('d', path)
.style('stroke-width', gridline.width)
.style('stroke', gridline.color)
.style('stroke-dasharray', Drawing.dashStyle(gridline.dash, gridline.width))
.style('fill', 'none');
});

Binary file added test/image/baselines/z-carpet_grid_dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions test/image/mocks/z-carpet_grid_dash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"data": [
{
"type": "carpet",
"a": [
0,
5e-07,
1e-06
],
"b": [
0,
500000,
1000000
],
"y": [
[
1,
1.32287,
1.73205
],
[
1.32287,
1.58113,
1.93649
],
[
1.73205,
1.93649,
2.23606
]
],
"aaxis": {
"minorgridcount": 3,
"gridcolor": "black",
"minorgridcolor": "red",
"griddash": "dot",
"minorgriddash": "dash"
},
"baxis": {
"minorgridcount": 3,
"gridcolor": "black",
"minorgridcolor": "red",
"griddash": "dash",
"minorgriddash": "dot"
}
}
],
"layout": {
"width": 500,
"height": 500,
"margin": {
"t": 40,
"r": 20,
"b": 40,
"l": 40
},
"dragmode": "pan"
}
}
Loading