8000 Better polar setConvert + a few misc polar touch ups by etpinard · Pull Request #2895 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Better polar setConvert + a few misc polar touch ups #2895

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 18 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
add on-graph 'text' to scatterpolargl
- follow-up from #2737
  • Loading branch information
etpinard committed Aug 10, 2018
commit d3b36151d02219bf122fc7cd813b544ccdd6ac2a
5 changes: 4 additions & 1 deletion
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
thetaunit: scatterPolarAttrs.thetaunit,

text: scatterPolarAttrs.text,
// no hovertext
hovertext: scatterPolarAttrs.hovertext,

line: scatterGlAttrs.line,
connectgaps: scatterGlAttrs.connectgaps,
Expand All @@ -33,6 +33,9 @@ module.exports = {
fill: scatterGlAttrs.fill,
fillcolor: scatterGlAttrs.fillcolor,

textposition: scatterGlAttrs.textposition,
textfont: scatterGlAttrs.textfont,

hoverinfo: scatterPolarAttrs.hoverinfo,
// no hoveron

Expand Down
6 changes: 6 additions & 0 deletions src/traces/scatterpolargl/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var subTypes = require('../scatter/subtypes');
var handleRThetaDefaults = require('../scatterpolar/defaults').handleRThetaDefaults;
var handleMarkerDefaults = require('../scatter/marker_defaults');
var handleLineDefaults = require('../scatter/line_defaults');
var handleTextDefaults = require('../scatter/text_defaults');
var handleFillColorDefaults = require('../scatter/fillcolor_defaults');
var PTS_LINESONLY = require('../scatter/constants').PTS_LINESONLY;

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

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

if(subTypes.hasText(traceOut)) {
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

coerce('fill');
if(traceOut.fill !== 'none') {
handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
Expand Down
4 changes: 4 additions & 0 deletions src/traces/scatterpolargl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function plot(container, subplot, cdata) {
if(options.marker && !scene.scatter2d) scene.scatter2d = true;
if(options.line && !scene.line2d) scene.line2d = true;
if((options.errorX || options.errorY) && !scene.error2d) scene.error2d = true;
if(options.text && !scene.glText) scene.glText = true;

stash.tree = cluster(positions);

Expand All @@ -116,6 +117,9 @@ function plot(container, subplot, cdata) {
scene.markerOptions.push(options.marker);
scene.markerSelectedOptions.push(options.markerSel);
scene.markerUnselectedOptions.push(options.markerUnsel);
scene.textOptions.push(options.text);
scene.textSelectedOptions.push(options.textSel);
scene.textUnselectedOptions.push(options.textUnsel);
scene.count = cdata.length;

// stash scene ref
Expand Down
Binary file added test/image/baselines/glpolar_subplots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions test/image/mocks/glpolar_subplots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"data": [{
"type": "scatterpolargl",
"mode": "markers+lines+text",
"r": [1, 2, 3],
"theta": [0, 45, 180],
"text": ["A0", "B0", "C0"],
"hovertext": ["hover A0", "hover B0", "hover C0"],
"marker": {"symbol": "square", "size": 15},
"textfont": {
"color": ["red", "green", "blue"],
"size": 20
},
"textposition": ["top left", "bottom right", "bottom right"]
}, {
"type": "scatterpolargl",
"mode": "markers+lines+text",
"r": [1, 2, 3],
"theta": [-0, -45, -180],
"text": ["A1", "B1", "C1"],
"hovertext": ["hover A1", "hover B1", "hover C1"],
"marker": {
"symbol": "square",
"size": 15,
"color": [-1, 1, 2],
"showscale": true
},
"textfont": {
"color": "green",
"size": [20, 15, 10]
},
"textposition": "top left",
"subplot": "polar2"
}],

"layout": {
"showlegend": false,
"polar": {
"domain": {
"x": [0, 0.44]
},
"radialaxis": {
"showgrid": false,
"title": "1st subplot",
"titlefont": {
"size": 20,
"color": "blue"
},
"angle": -45
}
},
"polar2": {
"domain": {
"x": [0.56, 1]
},
"radialaxis": {
"range": [0, 4.7],
"showgrid": false,
"title": "2nd subplot",
"titlefont": {
"size": 10,
"color": "orange"
},
"angle": 45
}
}
}
}
0