Skip to content

Commit 66f7fda

Browse files
authored
Merge pull request #2737 from plotly/textgl
Enable text for scattergl trace
2 parents 07fa382 + 235f1ac commit 66f7fda

24 files changed

+1157
-66
lines changed

package-lock.json

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

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"gl-select-box": "^1.0.2",
8484
"gl-spikes2d": "^1.0.1",
8585
"gl-surface3d": "^1.3.5",
86+
"gl-text": "^1.1.5",
8687
"glslify": "^6.1.1",
8788
"has-hover": "^1.0.1",
8889
"has-passive-events": "^1.0.0",

src/components/drawing/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,9 @@ drawing.tryColorscale = function(marker, prefix) {
611611
return Lib.identity;
612612
};
613613

614-
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1};
614+
var TEXTOFFSETSIGN = {
615+
start: 1, end: -1, middle: 0, bottom: 1, top: -1
616+
};
615617

616618
function textPointPosition(s, textPosition, fontSize, markerRadius) {
617619
var group = d3.select(s.node().parentNode);
@@ -631,7 +633,7 @@ function textPointPosition(s, textPosition, fontSize, markerRadius) {
631633
var numLines = (svgTextUtils.lineCount(s) - 1) * LINE_SPACING + 1;
632634
var dx = TEXTOFFSETSIGN[h] * r;
633635
var dy = fontSize * 0.75 + TEXTOFFSETSIGN[v] * r +
634-
(TEXTOFFSETSIGN[v] - 1) * numLines * fontSize / 2;
636+
(TEXTOFFSETSIGN[v] - 1) * numLines * fontSize / 2;
635637

636638
// fix the overall text group position
637639
s.attr('text-anchor', h);

src/traces/scattergl/attributes.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ var attrs = module.exports = overrideAll({
3737
'this trace\'s (x,y) coordinates.'
3838
].join(' ')
3939
}),
40+
hovertext: scatterAttrs.hovertext,
41+
42+
textposition: scatterAttrs.textposition,
43+
textfont: scatterAttrs.textfont,
44+
4045
mode: {
4146
valType: 'flaglist',
42-
flags: ['lines', 'markers'],
47+
flags: ['lines', 'markers', 'text'],
4348
extras: ['none'],
4449
role: 'info',
4550
description: [
@@ -77,10 +82,12 @@ var attrs = module.exports = overrideAll({
7782
hoveron: scatterAttrs.hoveron,
7883

7984
selected: {
80-
marker: scatterAttrs.selected.marker
85+
marker: scatterAttrs.selected.marker,
86+
textfont: scatterAttrs.selected.textfont
8187
},
8288
unselected: {
83-
marker: scatterAttrs.unselected.marker
89+
marker: scatterAttrs.unselected.marker,
90+
textfont: scatterAttrs.unselected.textfont
8491
},
8592

8693
opacity: plotAttrs.opacity

0 commit comments

Comments
 (0)