Skip to content

Commit 37c592e

Browse files
committed
revised cases and using defaults in the function
1 parent cdb0bac commit 37c592e

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"gl-plot2d": "^1.3.1",
8181
"gl-plot3d": "^1.5.10",
8282
"gl-pointcloud2d": "^1.0.1",
83-
"gl-scatter3d": "git://github.com/gl-vis/gl-scatter3d.git#2e325c43a31c33737bc547ed3fad749c0f995250",
83+
"gl-scatter3d": "git://github.com/gl-vis/gl-scatter3d.git#e1d123ef2c7c97a0bce5042b0eade8166cfe21ca",
8484
"gl-select-box": "^1.0.2",
8585
"gl-spikes2d": "^1.0.1",
8686
"gl-streamtube3d": "^1.1.0",

src/traces/scatter3d/attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ var attrs = module.exports = overrideAll({
160160
colorAttributes('marker')
161161
),
162162

163-
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center', arrayOk: true}),
163+
textposition: extendFlat({}, scatterAttrs.textposition, {dflt: 'top center'}),
164164
textfont: {
165165
color: scatterAttrs.textfont.color,
166166
size: scatterAttrs.textfont.size,

src/traces/scatter3d/convert.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,23 @@ function calculateErrorParams(errors) {
135135

136136
function parseAlignmentX(a) {
137137
if(a === null || a === undefined) return 0;
138-
else if(typeof(a) === 'number') return a;
139-
else if(a.indexOf('left') > -1) return -1;
140-
else if(a.indexOf('right') > -1) return 1;
141-
return 0;
138+
139+
return (a.indexOf('left') > -1) ? -1 :
140+
(a.indexOf('right') > -1) ? 1 : 0;
142141
}
143142

144143
function parseAlignmentY(a) {
145144
if(a === null || a === undefined) return 0;
146-
else if(typeof(a) === 'number') return a;
147-
else if(a.indexOf('top') > -1) return -1;
148-
else if(a.indexOf('bottom') > -1) return 1;
149-
return 0;
145+
146+
return (a.indexOf('top') > -1) ? -1 :
147+
(a.indexOf('bottom') > -1) ? 1 : 0;
150148
}
151149

152-
function calculateTextOffset(tp) {
150+
function calculateTextOffset(tp, dflt) {
153151
// Read out text properties
154152

155-
var defaultAlignmentX = 0; // center
156-
var defaultAlignmentY = -1; // top
153+
var defaultAlignmentX = parseAlignmentX(dflt);
154+
var defaultAlignmentY = parseAlignmentY(dflt);
157155

158156
var textOffset = [
159157
defaultAlignmentX,
@@ -268,7 +266,7 @@ function convertPlotlyOptions(scene, data) {
268266
}
269267

270268
if('textposition' in data) {
271-
params.textOffset = calculateTextOffset(data.textposition);
269+
params.textOffset = calculateTextOffset(data.textposition, data.dflt);
272270
params.textColor = formatColor(data.textfont, 1, len);
273271
params.textSize = formatParam(data.textfont.size, len, Lib.identity, 12);
274272
params.textFont = data.textfont.family; // arrayOk === false

0 commit comments

Comments
 (0)