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

griddash #6144

Merged
merged 29 commits into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from 15 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 match `gridwith` and `gridcolor` [[6144](https://github.com/plotly/plotly.js/pull/6144)]
2 changes: 2 additions & 0 deletions src/plots/cartesian/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,7 @@ axes.drawTicks = function(gd, ax, opts) {
* - {boolean} showgrid
* - {string} gridcolor
* - {string} gridwidth
* - {string} griddash
* - {boolean} zeroline
* - {string} type
* - {string} dtick
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion src/plots/cartesian/line_grid_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/plots/geo/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion src/plots/geo/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

var attrs = module.exports = overrideAll({
Expand Down
1 change: 1 addition & 0 deletions src/plots/geo/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/plots/gl2d/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Axes2DOptions(scene) {
[0, 0, 0, 0.5]
];
this.gridLineWidth = [1, 1];
this.gridLineDash = ['', ''];

this.zeroLineEnable = [true, true];
this.zeroLineWidth = [1, 1];
Expand Down Expand Up @@ -162,6 +163,7 @@ proto.merge = function(options) {
this.gridLineEnable[i] = ax.showgrid;
this.gridLineColor[i] = str2RGBArray(ax.gridcolor);
this.gridLineWidth[i] = ax.gridwidth;
this.gridLineDash[i] = ax.griddash;

this.zeroLineEnable[i] = ax.zeroline;
this.zeroLineColor[i] = str2RGBArray(ax.zerolinecolor);
Expand Down
1 change: 1 addition & 0 deletions src/plots/gl3d/layout/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ module.exports = overrideAll({
gridcolor: extendFlat({}, axesAttrs.gridcolor, // shouldn't this be on-par with 2D?
{dflt: 'rgb(204, 204, 204)'}),
gridwidth: axesAttrs.gridwidth,
griddash: axesAttrs.griddash,
zeroline: axesAttrs.zeroline,
zerolinecolor: axesAttrs.zerolinecolor,
zerolinewidth: axesAttrs.zerolinewidth,
Expand Down
2 changes: 2 additions & 0 deletions src/plots/gl3d/layout/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function AxesOptions() {

this.gridEnable = [ true, true, true ];
this.gridWidth = [ 1, 1, 1 ];
this.gridDash = [ '', '', '' ];
this.gridColor = [ [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1] ];

this.zeroEnable = [ true, true, true ];
Expand Down Expand Up @@ -93,6 +94,7 @@ proto.merge = function(fullLayout, sceneLayout) {
if('showgrid' in axes) opts.gridEnable[i] = axes.showgrid;
if('gridcolor' in axes) opts.gridColor[i] = str2RgbaArray(axes.gridcolor);
if('gridwidth' in axes) opts.gridWidth[i] = axes.gridwidth;
if('griddash' in axes) opts.gridDash[i] = axes.griddash;

// Remove zeroline if axis type is log
// otherwise the zeroline is incorrectly drawn at 1 on log axes
Expand Down
3 changes: 2 additions & 1 deletion src/plots/polar/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/plots/smith/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions src/plots/ternary/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
5 changes: 5 additions & 0 deletions src/traces/carpet/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -359,6 +362,7 @@ module.exports = {
editType: 'calc',
description: 'Sets the width (in px) of the axis line.'
},
griddash: extendFlat({}, dash, {dflt: '', editType: 'none'}),
showgrid: {
valType: 'boolean',
dflt: true,
Expand All @@ -382,6 +386,7 @@ module.exports = {
editType: 'calc',
description: 'Sets the width (in px) of the grid lines.'
},
minorgriddash: extendFlat({}, dash, {dflt: '', editType: 'none'}),
minorgridcolor: {
valType: 'color',
dflt: colorAttrs.lightLine,
Expand Down
5 changes: 5 additions & 0 deletions src/traces/carpet/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/traces/carpet/calc_gridlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
}

Expand Down Expand Up @@ -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
}));
}
}
Expand Down Expand Up @@ -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
}));
}

Expand All @@ -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
}));
}
}
Expand Down
Binary file added test/image/baselines/zz-line_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.
39 changes: 39 additions & 0 deletions test/image/mocks/zz-line_grid_dash.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"data": [
{
"y": [
-5,
-1,
1
],
"x": [
-1,
0,
1
]
}
],
"layout": {
"xaxis": {
"griddash": "longdashdot",
"type": "linear",
"range": [
-1.122244488977956,
1.122244488977956
],
"autorange": true
},
"yaxis": {
"griddash": "dashdot",
"type": "linear",
"range": [
-5.439490445859873,
1.4394904458598727
],
"autorange": true
},
"height": 450,
"width": 1000,
"autosize": true
}
}
Loading