Skip to content

Implement options to draw minor ticks and grid lines in Cartesian subplots #6166

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 60 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6bc7e13
add minor tick and grid options to cartesian subplot
archmoj Apr 7, 2022
08c61f7
supply deafults for minor ticks and grids
archmoj Apr 7, 2022
eaa8e71
draw minor ticks and grid lines
archmoj Apr 7, 2022
64576fc
minor image test 11
archmoj Apr 7, 2022
58958ff
minor image test 14
archmoj Apr 7, 2022
9843e07
minor image test 15
archmoj Apr 7, 2022
28f8eb0
minor image test 17
archmoj Apr 7, 2022
02eb3df
minor image test 19
archmoj Apr 7, 2022
f784fe6
minor image test 24
archmoj Apr 7, 2022
1dfe510
minor image test 28
archmoj Apr 7, 2022
716aa38
minor image test 32
archmoj Apr 7, 2022
18cd4e5
minor image test date_axes_period2
archmoj Apr 7, 2022
ca57f7e
minor image test h-colorbar01
archmoj Apr 7, 2022
0fdee8c
minor image test h-colorbar02
archmoj Apr 7, 2022
08a0f4a
minor image h-colorbar_airfoil
archmoj Apr 7, 2022
6c312f4
minor image heatmap_xyz-dates-and-categories
archmoj Apr 7, 2022
141fada
minor image legend_horizontal_autowrap
archmoj Apr 7, 2022
0165875
minor image ticklabelposition-0
archmoj Apr 7, 2022
58fa977
minor image ticklabelposition-1
archmoj Apr 7, 2022
8763300
minor image ticklabelposition-2
archmoj Apr 7, 2022
b3528e6
minor image ticklabelposition-5
archmoj Apr 7, 2022
dbed549
minor image mirror-all-vs-allticks
archmoj Apr 7, 2022
3377704
use identical roundingSet for minor ticks
archmoj Apr 14, 2022
f82733c
use auto minor.dtick in date_axes_period2
archmoj Apr 14, 2022
7b3e7be
revisit the process of generating minor values
archmoj Apr 20, 2022
2ca3881
base minor default styles in respect to styles set for major ticks an…
archmoj Apr 20, 2022
c6b7231
refactor and add comment about mock 32 not dropping minor ticks and m…
archmoj Apr 20, 2022
7598ddd
attempt fixing minor and major overlaps
archmoj Apr 20, 2022
fd312fd
do not use almost equal instead eliminate problematic digits
archmoj Apr 20, 2022
4a535fc
fixup auto minor when having major tickvals
archmoj Apr 21, 2022
31f86eb
improve tests
archmoj Apr 21, 2022
0d070b7
inherit minor tickwidth and gridwidth from major styles
archmoj Apr 22, 2022
d8e7d05
revise mixing ratio between bgcolor and minor.gridcolor
archmoj Apr 22, 2022
04c2364
clear redundant ifs
archmoj Apr 22, 2022
0affe38
improve handling of minor case
archmoj Apr 22, 2022
8a1472f
no need to call autoTickRound for minor ticks
archmoj Apr 22, 2022
db7534b
use prepMinorTicks method
archmoj Apr 22, 2022
03254ab
revise minor auto ticks
archmoj Apr 22, 2022
c4c4c5c
handle log
archmoj Apr 25, 2022
51813f9
match minor.tick0 with main tick0
archmoj Apr 25, 2022
7afdb78
reduce crispRound calls for minor
archmoj Apr 25, 2022
cd96c12
draw minor grid lines behide major grid lines
archmoj Apr 25, 2022
3cb2910
align minor ticks
archmoj Apr 25, 2022
4d72fa5
apply minor.nticks
archmoj Apr 25, 2022
bae4f11
use defined minor.ntick to divide delta without rounding
archmoj Apr 26, 2022
1cec0bc
do not try to round dtick when having minor.nticks
archmoj Apr 26, 2022
524a330
rename id > majorId
archmoj Apr 26, 2022
126ce26
ensure minor dtick get round months
archmoj Apr 26, 2022
1db3524
add various jasmine tests
archmoj Apr 27, 2022
66c9d87
delete minor when no minor ticks or gridlines
archmoj Apr 28, 2022
27e1320
clear minor hack
archmoj Apr 29, 2022
b81617d
minor autotick algo mirrors major based on nticks
alexcjohnson Apr 29, 2022
9c1514a
tweaks to minor nticks algorithm after feedback from @archmoj
alexcjohnson Apr 30, 2022
25d2fe8
update minor baselines
archmoj May 2, 2022
26d4998
update schema
archmoj May 2, 2022
80933c4
adjust jasmine tests
archmoj May 2, 2022
c57f2c8
revert changes in axes.autoTicks
archmoj May 2, 2022
64a211b
clear unused keys on axes
archmoj May 2, 2022
94ff74d
disallow automatic D2 minor when major is > 1 order of mag
alexcjohnson May 2, 2022
69c09c1
update ticklabelposition-2 baseline
archmoj May 2, 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
667 changes: 483 additions & 184 deletions src/plots/cartesian/axes.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var isNumeric = require('fast-isnumeric');

var Registry = require('../../registry');
var Lib = require('../../lib');
var Template = require('../../plot_api/plot_template');

var handleArrayContainerDefaults = require('../array_container_defaults');

Expand Down Expand Up @@ -121,16 +122,45 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
color: dfltFontColor
});

// major ticks
handleTickValueDefaults(containerIn, containerOut, coerce, axType);

var hasMinor = options.hasMinor;
if(hasMinor) {
// minor ticks
Template.newContainer(containerOut, 'minor');
handleTickValueDefaults(containerIn, containerOut, coerce, axType, { isMinor: true });
}

handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);

// major and minor ticks
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
if(hasMinor) {
var keepIsMinor = options.isMinor;
options.isMinor = true;
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
options.isMinor = keepIsMinor;
}

handleLineGridDefaults(containerIn, containerOut, coerce, {
dfltColor: dfltColor,
bgColor: options.bgColor,
showGrid: options.showGrid,
hasMinor: hasMinor,
attributes: layoutAttributes
});

// delete minor when no minor ticks or gridlines
if(
hasMinor &&
!containerOut.minor.ticks &&
!containerOut.minor.showgrid
) {
delete containerOut.minor;
}

// mirror
if(containerOut.showline || containerOut.ticks) coerce('mirror');

if(options.automargin) coerce('automargin');
Expand Down
8 changes: 8 additions & 0 deletions src/plots/cartesian/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ function makeSubplotLayer(gd, plotinfo) {
plotinfo.shapelayer = ensureSingle(backLayer, 'g', 'shapelayer');
plotinfo.imagelayer = ensureSingle(backLayer, 'g', 'imagelayer');

plotinfo.minorGridlayer = ensureSingle(plotgroup, 'g', 'minor-gridlayer');
plotinfo.gridlayer = ensureSingle(plotgroup, 'g', 'gridlayer');
plotinfo.zerolinelayer = ensureSingle(plotgroup, 'g', 'zerolinelayer');

Expand Down Expand Up @@ -500,6 +501,7 @@ function makeSubplotLayer(gd, plotinfo) {
// their other components to the corresponding
// extra groups of their main plots.

plotinfo.minorGridlayer = mainplotinfo.minorGridlayer;
plotinfo.gridlayer = mainplotinfo.gridlayer;
plotinfo.zerolinelayer = mainplotinfo.zerolinelayer;

Expand All @@ -525,6 +527,12 @@ function makeSubplotLayer(gd, plotinfo) {
// common attributes for all subplots, overlays or not

if(!hasOnlyLargeSploms) {
ensureSingleAndAddDatum(plotinfo.minorGridlayer, 'g', plotinfo.xaxis._id);
ensureSingleAndAddDatum(plotinfo.minorGridlayer, 'g', plotinfo.yaxis._id);
plotinfo.minorGridlayer.selectAll('g')
.map(function(d) { return d[0]; })
.sort(axisIds.idSort);

ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.xaxis._id);
ensureSingleAndAddDatum(plotinfo.gridlayer, 'g', plotinfo.yaxis._id);
plotinfo.gridlayer.selectAll('g')
Expand Down
Loading