Skip to content

Commit d8462eb

Browse files
committed
move 3d annotation coercePosition step from convert to defaults
- as now Axes.coercePosition does not rely on ax._categories for `type: 'category' axes.
1 parent b67657f commit d8462eb

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

src/components/annotations3d/convert.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
var Lib = require('../../lib');
1212
var Axes = require('../../plots/cartesian/axes');
13-
var attributes = require('./attributes');
1413

1514
module.exports = function convert(scene) {
1615
var fullSceneLayout = scene.fullSceneLayout;
@@ -61,25 +60,4 @@ function mockAnnAxes(ann, scene) {
6160
ann._ya.l2p = function() {
6261
return 0.5 * (1 - ann.pdata[1] / ann.pdata[3]) * size.h * (domain.y[1] - domain.y[0]);
6362
};
64-
65-
// or do something more similar to 2d
66-
// where Annotations.supplyLayoutDefaults is called after in Plots.doCalcdata
67-
// if category axes are found.
68-
function coerce(attr, dflt) {
69-
return Lib.coerce(ann, ann, attributes, attr, dflt);
70-
}
71-
72-
function coercePosition(axLetter) {
73-
var axName = axLetter + 'axis';
74-
75-
// mock in such way that getFromId grabs correct 3D axis
76-
var gdMock = { _fullLayout: {} };
77-
gdMock._fullLayout[axName] = fullSceneLayout[axName];
78-
79-
return Axes.coercePosition(ann, gdMock, coerce, axLetter, axLetter, 0.5);
80-
}
81-
82-
coercePosition('x');
83-
coercePosition('y');
84-
coercePosition('z');
8563
}

src/components/annotations3d/defaults.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'use strict';
1010

1111
var Lib = require('../../lib');
12+
var Axes = require('../../plots/cartesian/axes');
1213
var handleArrayContainerDefaults = require('../../plots/array_container_defaults');
1314
var handleAnnotationCommonDefaults = require('../annotations/common_defaults');
1415
var attributes = require('./attributes');
@@ -26,16 +27,25 @@ function handleAnnotationDefaults(annIn, annOut, sceneLayout, opts, itemOpts) {
2627
return Lib.coerce(annIn, annOut, attributes, attr, dflt);
2728
}
2829

30+
function coercePosition(axLetter) {
31+
var axName = axLetter + 'axis';
32+
33+
// mock in such way that getFromId grabs correct 3D axis
34+
var gdMock = { _fullLayout: {} };
35+
gdMock._fullLayout[axName] = sceneLayout[axName];
36+
37+
return Axes.coercePosition(annOut, gdMock, coerce, axLetter, axLetter, 0.5);
38+
}
39+
40+
2941
var visible = coerce('visible', !itemOpts.itemIsNotPlainObject);
3042
if(!visible) return annOut;
3143

3244
handleAnnotationCommonDefaults(annIn, annOut, opts.fullLayout, coerce);
3345

34-
// do not use Axes.coercePosition here
35-
// as ax._categories aren't filled in at this stage
36-
coerce('x');
37-
coerce('y');
38-
coerce('z');
46+
coercePosition('x');
47+
coercePosition('y');
48+
coercePosition('z');
3949

4050
// if you have one coordinate you should all three
4151
Lib.noneOrAll(annIn, annOut, ['x', 'y', 'z']);

0 commit comments

Comments
 (0)