Skip to content

Introducing 3D annotations #1638

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
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aa58118
replace forEach with for-loop over ['x', 'y']
etpinard Apr 28, 2017
8b8bdea
don't (uselessly) add data-index to ann text+bg & arrow groups
etpinard Apr 28, 2017
1a8f1ed
don't (uselessly) add annotation class to ann text group inner
etpinard Apr 28, 2017
f4b14e6
fine tune annotation arrow selector
etpinard Apr 28, 2017
4dc16e4
use ax.?2? while composing convert methods
etpinard Apr 28, 2017
8e6ab7d
split annotation drawOne into drawRaw
etpinard Apr 28, 2017
c5f6eb2
introduce 3D annotations
etpinard Apr 28, 2017
b7ab656
don't try to edit x,y,z positions for 3D annotations
etpinard Apr 28, 2017
fbdcee8
Merge branch 'master' into gl3d-annotations
etpinard May 9, 2017
981b1a1
Merge branch 'master' into gl3d-annotations
etpinard May 16, 2017
94b940d
rename anchor -> anchor3 so that it doesn't conflict w/ for-loop block
etpinard May 16, 2017
8ac2551
Merge branch 'master' into gl3d-annotations
etpinard May 24, 2017
ababc49
Revert "don't (uselessly) add annotation class to ann text group inner"
etpinard May 24, 2017
7cfba36
fix 3d annotations on type: 'category' axes
etpinard May 24, 2017
8f9e370
make sure to clear 3d annotations when parent scene gets removed
etpinard May 24, 2017
1bbabad
implement autorange logic for annotations
etpinard May 24, 2017
9520943
first pass 3d annotations jasmine tests
etpinard May 24, 2017
f61cd4d
first pass 3d annotation image test support
etpinard May 24, 2017
8cb10c1
try to make test that update the scene camera more robust
etpinard May 25, 2017
a31549d
replace 'annotation' class for 'annotation-text' for annation text nodes
etpinard May 25, 2017
bd9c867
mv 3d annotations code out of plots/gl3d into component/annotations3d
etpinard May 25, 2017
21c8cc6
add common annotations defaults modules
etpinard May 25, 2017
adfc305
declare `ax` and `ay` as `valType: number` for annotation3d
etpinard May 25, 2017
c084da0
rename _scene ref to scene id in annotation container _sceneId
etpinard May 25, 2017
ef985cf
put 'captureevents' under common annotation defaults
etpinard May 25, 2017
0b4214f
Merge branch 'master' into gl3d-annotations
etpinard May 25, 2017
8b8a088
pass subplotId as arg to Annotations.drawRaw
etpinard May 26, 2017
1d5606a
include subplotId in clickannotation event data
etpinard May 26, 2017
46ab63d
rm subplotId key from clickannotations event data when falsy
etpinard May 26, 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
52 changes: 4 additions & 48 deletions src/components/annotations/annotation_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
'use strict';

var Lib = require('../../lib');
var Color = require('../color');
var Axes = require('../../plots/cartesian/axes');

var handleAnnotationCommonDefaults = require('./common_defaults');
var attributes = require('./attributes');


Expand All @@ -29,26 +28,9 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op

if(!(visible || clickToShow)) return annOut;

coerce('opacity');
var bgColor = coerce('bgcolor');

var borderColor = coerce('bordercolor'),
borderOpacity = Color.opacity(borderColor);

coerce('borderpad');

var borderWidth = coerce('borderwidth');
var showArrow = coerce('showarrow');

coerce('text', showArrow ? ' ' : 'new text');
coerce('textangle');
Lib.coerceFont(coerce, 'font', fullLayout.font);

coerce('width');
coerce('align');
handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce);

var h = coerce('height');
if(h) coerce('valign');
var showArrow = annOut.showarrow;

// positioning
var axLetters = ['x', 'y'],
Expand Down Expand Up @@ -90,14 +72,8 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
// if you have one coordinate you should have both
Lib.noneOrAll(annIn, annOut, ['x', 'y']);

// if you have one part of arrow length you should have both
if(showArrow) {
coerce('arrowcolor', borderOpacity ? annOut.bordercolor : Color.defaultLine);
coerce('arrowhead');
coerce('arrowsize');
coerce('arrowwidth', ((borderOpacity && borderWidth) || 1) * 2);
coerce('standoff');

// if you have one part of arrow length you should have both
Lib.noneOrAll(annIn, annOut, ['ax', 'ay']);
}

Expand All @@ -111,25 +87,5 @@ module.exports = function handleAnnotationDefaults(annIn, annOut, fullLayout, op
annOut._yclick = (yClick === undefined) ? annOut.y : yClick;
}

var hoverText = coerce('hovertext');
var globalHoverLabel = fullLayout.hoverlabel || {};

if(hoverText) {
var hoverBG = coerce('hoverlabel.bgcolor', globalHoverLabel.bgcolor ||
(Color.opacity(bgColor) ? Color.rgb(bgColor) : Color.defaultLine)
);

var hoverBorder = coerce('hoverlabel.bordercolor', globalHoverLabel.bordercolor ||
Color.contrast(hoverBG)
);

Lib.coerceFont(coerce, 'hoverlabel.font', {
family: globalHoverLabel.font.family,
size: globalHoverLabel.font.size,
color: globalHoverLabel.font.color || hoverBorder
});
}
coerce('captureevents', !!hoverText);

return annOut;
};
66 changes: 66 additions & 0 deletions src/components/annotations/common_defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright 2012-2017, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

var Lib = require('../../lib');
var Color = require('../color');

// defaults common to 'annotations' and 'annotations3d'
module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayout, coerce) {
coerce('opacity');
var bgColor = coerce('bgcolor');

var borderColor = coerce('bordercolor');
var borderOpacity = Color.opacity(borderColor);

coerce('borderpad');

var borderWidth = coerce('borderwidth');
var showArrow = coerce('showarrow');

coerce('text', showArrow ? ' ' : 'new text');
coerce('textangle');
Lib.coerceFont(coerce, 'font', fullLayout.font);

coerce('width');
coerce('align');

var h = coerce('height');
if(h) coerce('valign');

if(showArrow) {
coerce('arrowcolor', borderOpacity ? annOut.bordercolor : Color.defaultLine);
coerce('arrowhead');
coerce('arrowsize');
coerce('arrowwidth', ((borderOpacity && borderWidth) || 1) * 2);
coerce('standoff');

}

var hoverText = coerce('hovertext');
var globalHoverLabel = fullLayout.hoverlabel || {};

if(hoverText) {
var hoverBG = coerce('hoverlabel.bgcolor', globalHoverLabel.bgcolor ||
(Color.opacity(bgColor) ? Color.rgb(bgColor) : Color.defaultLine)
);

var hoverBorder = coerce('hoverlabel.bordercolor', globalHoverLabel.bordercolor ||
Color.contrast(hoverBG)
);

Lib.coerceFont(coerce, 'hoverlabel.font', {
family: globalHoverLabel.font.family,
size: globalHoverLabel.font.size,
color: globalHoverLabel.font.color || hoverBorder
});
}

coerce('captureevents', !!hoverText);
};
Loading