8000 Cartesian dropline support by rpaskowitz · Pull Request #1461 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Cartesian dropline support #1461

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 30 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d9fab15
Cartesian dropline support
rpaskowitz Mar 10, 2017
5d39b53
Removed chart config for showDroplines
rpaskowitz Mar 11, 2017
be47533
Add spikecolor, spikethickness, spikedash and spikemode
rpaskowitz Apr 7, 2017
17d815c
Add cartesian spikeline modebar support
rpaskowitz Apr 7, 2017
162068e
Merge branch 'master' into dropline
rpaskowitz Apr 7, 2017
762b54a
Move dashStyle to Drawing
rpaskowitz Apr 7, 2017
d680bd4
Name back to showspikes
rpaskowitz Apr 7, 2017
2433d4c
Lint, test and implementation fixes
rpaskowitz Apr 7, 2017
75da2fe
add spikeline icon
etpinard Apr 7, 2017
7953488
Fix cartesian check and fine-tune marker placement
rpaskowitz Apr 7, 2017
55b17b2
Merge branch 'master' into dropline
etpinard Apr 10, 2017
b9f6ab1
Refactor dropline to spikeline
rpaskowitz Apr 10, 2017
7fe4363
Merge branch 'dropline' of github.com:rpaskowitz/plotly.js into dropline
rpaskowitz Apr 10, 2017
34a1562
Switch from getBoundingClientRect to offsetLeft and offsetTop.
rpaskowitz Apr 10, 2017
8c7ac76
Move spike setup from axis to layout.
rpaskowitz Apr 10, 2017
6e243de
Fix marker positioning and across rendering for top-side x-axes.
rpaskowitz Apr 11, 2017
c036bf7
Merge branch 'master' into dropline
alexcjohnson Apr 13, 2017
08371c2
short-circuit redraw for spike attribute relayouts
alexcjohnson Apr 14, 2017
69dc781
fix manual-hover logic for event emitting
alexcjohnson Apr 14, 2017
37b77fe
don't make spike markers crisp
alexcjohnson Apr 14, 2017
710d2d6
alter logic for where spikes start and end
alexcjohnson Apr 14, 2017
e509fa7
lint
alexcjohnson Apr 14, 2017
75121d2
:hocho: spikemode: 'none'
alexcjohnson Apr 17, 2017
bd11567
make drawing/attributes.dash - and clean up some dashes that don't fi…
alexcjohnson Apr 17, 2017
3a9aa58
short-circuit spike properties when spikes are off
alexcjohnson Apr 17, 2017
052417b
test hover event response to manual and "real" events
alexcjohnson Apr 17, 2017
a3a0a4f
:hocho: fit
alexcjohnson Apr 17, 2017
f7b467e
fix scattermapbox defaults for omitted options
alexcjohnson Apr 18, 2017
7aa4359
lint
alexcjohnson Apr 18, 2017
5925049
:hocho: :hocho:
alexcjohnson Apr 18, 2017
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
Prev Previous commit
Next Next commit
Removed chart config for showDroplines
Added axis layout option for showspikes
Added background behind droplines
Added axis indicator marker, including on free anchored axes
Always draw dropline to chart limit, including for shared axes - not drawing all the way to free anchored axes
  • Loading branch information
rpaskowitz committed Mar 11, 2017
commit 5d39b53367b13c7439 8000 6c4f71cc39185a1c0b30aa
1 change: 1 addition & 0 deletions src/components/dragelement/unhover.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ unhover.raw = function unhoverRaw(gd, evt) {

fullLayout._hoverlayer.selectAll('g').remove();
fullLayout._hoverlayer.selectAll('line').remove();
fullLayout._hoverlayer.selectAll('circle').remove();
gd._hoverdata = undefined;

if(evt.target && oldhoverdata) {
Expand Down
3 changes: 0 additions & 3 deletions src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ module.exports = {
// new users see some hints about interactivity
showTips: true,

// display droplines on cartesian graphs
showDroplines: false,

// enable axis pan/zoom drag handles
showAxisDragHandles: true,

Expand Down
2 changes: 2 additions & 0 deletions src/plots/cartesian/axis_defaults.js
8000
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
coerce('range');
containerOut.cleanRange();

coerce('showspikes');

handleTickValueDefaults(containerIn, containerOut, coerce, axType);
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
Expand Down
118 changes: 91 additions & 27 deletions src/plots/cartesian/graph_interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ function hover(gd, evt, subplot) {

gd._hoverdata = newhoverdata;

if(gd._context.showDroplines && hoverChanged(gd, evt, oldhoverdata)) {
if(hoverChanged(gd, evt, oldhoverdata)) {
var droplineOpts = {
hovermode: hovermode,
container: fullLayout._hoverlayer,
Expand Down Expand Up @@ -829,38 +829,102 @@ fx.loneUnhover = function(containerOrSelection) {

selection.selectAll('g.hovertext').remove();
selection.selectAll('line.dropline').remove();
selection.selectAll('circle.dropline').remove();
};

function createDroplines(hoverData, opts) {
var hovermode = opts.hovermode,
container = opts.container;

container = opts.container,
outerContainer = opts.outerContainer;
if(hovermode !== 'closest') return;
var c0 = hoverData[0];
var x = (c0.x0 + c0.x1) / 2;
var y = (c0.y0 + c0.y1) / 2;
var xOffset = c0.xa._offset;
var yOffset = c0.ya._offset;
var c0 = hoverData[0],
x = (c0.x0 + c0.x1) / 2,
y = (c0.y0 + c0.y1) / 2,
xOffset = c0.xa._offset,
yOffset = c0.ya._offset,
xPoint = xOffset + x,
yPoint = yOffset + y,
xSide = c0.xa.side,
ySide = c0.ya.side,
xLength = c0.xa._length,
yLength = c0.ya._length,
xEdge = c0.ya._boundingBox.left + (ySide === 'left' ? c0.ya._boundingBox.width : 0),
yEdge = c0.xa._boundingBox.top + (xSide === 'top' ? c0.xa._boundingBox.height : 0),
outerBBox = outerContainer.node().getBoundingClientRect(),
xFreeBase = xOffset + (ySide === 'right' ? xLength : 0),
yFreeBase = yOffset + (xSide === 'top' ? yLength : 0),
xAnchoredBase = xEdge - outerBBox.left,
yAnchoredBase = yEdge - outerBBox.top,
xBase = c0.ya.anchor === 'free' ? xFreeBase : xAnchoredBase,
yBase = c0.xa.anchor === 'free' ? yFreeBase : yAnchoredBase,
color = c0.color;

// Remove old dropline items
container.selectAll('line.dropline').remove();
container.append('line')
.attr('x1', xOffset + (c0.ya.side === 'right' ? c0.xa._length : 0))
.attr('x2', xOffset + x)
.attr('y1', yOffset + y)
.attr('y2', yOffset + y)
.attr('stroke-width', 3)
.attr('stroke', c0.color)
.attr('stroke-dasharray', '5,5')
.attr('class', 'dropline');

container.append('line')
.attr('x1', xOffset + x)
.attr('x2', xOffset + x)
.attr('y1', yOffset + y)
.attr('y2', yOffset + c0.ya._length)
.attr('stroke-width', 3)
.attr('stroke', c0.color)
.attr('stroke-dasharray', '5,5')
.attr('class', 'dropline');
container.selectAll('circle.dropline').remove();


if(c0.ya.showspikes) {
// Background horizontal Line (to y-axis)
container.append('line')
.attr('x1', xBase)
.attr('x2', xPoint)
.attr('y1', yPoint)
.attr('y2', yPoint)
.attr('stroke-width', 5)
.attr('stroke', '#fff')
.attr('class', 'dropline');

// Foreground horizontal line (to y-axis)
container.append('line')
.attr('x1', xBase)
.attr('x2', xPoint)
.attr('y1', yPoint)
.attr('y2', yPoint)
.attr('stroke-width', 3)
.attr('stroke', color)
.attr('stroke-dasharray', '5,5')
.attr('class', 'dropline');

// Y axis marker
container.append('circle')
.attr('cx', xBase)
.attr('cy', yPoint)
.attr('r', 3)
.attr('fill', color)
.attr('class', 'dropline');
}

if(c0.xa.showspikes) {
// Background vertical line (to x-axis)
container.append('line')
.attr('x1', xPoint)
.attr('x2', xPoint)
.attr('y1', yPoint)
.attr('y2', yBase)
.attr('stroke-width', 5)
.attr('stroke', '#fff')
.attr('class', 'dropline');

// Foreground vertical line (to x-axis)
container.append('line')
.attr('x1', xPoint)
.attr('x2', xPoint)
.attr('y1', yPoint)
.attr('y2', yBase)
.attr('stroke-width', 3)
.attr('stroke', color)
.attr('stroke-dasharray', '5,5')
.attr('class', 'dropline');

// X axis marker
container.append('circle')
.attr('cx', xPoint)
.attr('cy', yBase)
.attr('r', 3)
.attr('fill', color)
.attr('class', 'dropline');
}
}

function createHoverText(hoverData, opts) {
Expand Down
9 changes: 9 additions & 0 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ module.exports = {
role: 'style',
description: 'Determines whether or not the tick labels are drawn.'
},
showspikes: {
valType: 'boolean',
dflt: false,
role: 'style',
description: [
'Determines whether or not spikes (aka droplines) are drawn for this axis.',
'Note: This only takes affect when hovermode = closest'
].join(' ')
},
tickfont: extendFlat({}, fontAttrs, {
description: 'Sets the tick font.'
}),
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
0