Skip to content

Commit d3b3615

Browse files
committed
add on-graph 'text' to scatterpolargl
- follow-up from #2737
1 parent dae3ccd commit d3b3615

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

Diff for: src/traces/scatterpolargl/attributes.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = {
2222
thetaunit: scatterPolarAttrs.thetaunit,
2323

2424
text: scatterPolarAttrs.text,
25-
// no hovertext
25+
hovertext: scatterPolarAttrs.hovertext,
2626

2727
line: scatterGlAttrs.line,
2828
connectgaps: scatterGlAttrs.connectgaps,
@@ -33,6 +33,9 @@ module.exports = {
3333
fill: scatterGlAttrs.fill,
3434
fillcolor: scatterGlAttrs.fillcolor,
3535

36+
textposition: scatterGlAttrs.textposition,
37+
textfont: scatterGlAttrs.textfont,
38+
3639
hoverinfo: scatterPolarAttrs.hoverinfo,
3740
// no hoveron
3841

Diff for: src/traces/scatterpolargl/defaults.js

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var subTypes = require('../scatter/subtypes');
1414
var handleRThetaDefaults = require('../scatterpolar/defaults').handleRThetaDefaults;
1515
var handleMarkerDefaults = require('../scatter/marker_defaults');
1616
var handleLineDefaults = require('../scatter/line_defaults');
17+
var handleTextDefaults = require('../scatter/text_defaults');
1718
var handleFillColorDefaults = require('../scatter/fillcolor_defaults');
1819
var PTS_LINESONLY = require('../scatter/constants').PTS_LINESONLY;
1920

@@ -33,6 +34,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
3334
coerce('thetaunit');
3435
coerce('mode', len < PTS_LINESONLY ? 'lines+markers' : 'lines');
3536
coerce('text');
37+
coerce('hovertext');
3638

3739
if(subTypes.hasLines(traceOut)) {
3840
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
@@ -43,6 +45,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4345
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce);
4446
}
4547

48+
if(subTypes.hasText(traceOut)) {
49+
handleTextDefaults(traceIn, traceOut, layout, coerce);
50+
}
51+
4652
coerce('fill');
4753
if(traceOut.fill !== 'none') {
4854
handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);

Diff for: src/traces/scatterpolargl/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ function plot(container, subplot, cdata) {
9595
if(options.marker && !scene.scatter2d) scene.scatter2d = true;
9696
if(options.line && !scene.line2d) scene.line2d = true;
9797
if((options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;
98+
if(options.text && !scene.glText) scene.glText = true;
9899

99100
stash.tree = cluster(positions);
100101

@@ -116,6 +117,9 @@ function plot(container, subplot, cdata) {
116117
scene.markerOptions.push(options.marker);
117118
scene.markerSelectedOptions.push(options.markerSel);
118119
scene.markerUnselectedOptions.push(options.markerUnsel);
120+
scene.textOptions.push(options.text);
121+
scene.textSelectedOptions.push(options.textSel);
122+
scene.textUnselectedOptions.push(options.textUnsel);
119123
scene.count = cdata.length;
120124

121125
// stash scene ref

Diff for: test/image/baselines/glpolar_subplots.png

46.4 KB
Loading

Diff for: test/image/mocks/glpolar_subplots.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"data": [{
3+
"type": "scatterpolargl",
4+
"mode": "markers+lines+text",
5+
"r": [1, 2, 3],
6+
"theta": [0, 45, 180],
7+
"text": ["A0", "B0", "C0"],
8+
"hovertext": ["hover A0", "hover B0", "hover C0"],
9+
"marker": {"symbol": "square", "size": 15},
10+
"textfont": {
11+
"color": ["red", "green", "blue"],
12+
"size": 20
13+
},
14+
"textposition": ["top left", "bottom right", "bottom right"]
15+
}, {
16+
"type": "scatterpolargl",
17+
"mode": "markers+lines+text",
18+
"r": [1, 2, 3],
19+
"theta": [-0, -45, -180],
20+
"text": ["A1", "B1", "C1"],
21+
"hovertext": ["hover A1", "hover B1", "hover C1"],
22+
"marker": {
23+
"symbol": "square",
24+
"size": 15,
25+
"color": [-1, 1, 2],
26+
"showscale": true
27+
},
28+
"textfont": {
29+
"color": "green",
30+
"size": [20, 15, 10]
31+
},
32+
"textposition": "top left",
33+
"subplot": "polar2"
34+
}],
35+
36+
"layout": {
37+
"showlegend": false,
38+
"polar": {
39+
"domain": {
40+
"x": [0, 0.44]
41+
},
42+
"radialaxis": {
43+
"showgrid": false,
44+
"title": "1st subplot",
45+
"titlefont": {
46+
"size": 20,
47+
"color": "blue"
48+
},
49+
"angle": -45
50+
}
51+
},
52+
"polar2": {
53+
"domain": {
54+
"x": [0.56, 1]
55+
},
56+
"radialaxis": {
57+
"range": [0, 4.7],
58+
"showgrid": false,
59+
"title": "2nd subplot",
60+
"titlefont": {
61+
"size": 10,
62+
"color": "orange"
63+
},
64+
"angle": 45
65+
}
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)