-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Scatterpolargl fixes #3098
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
Scatterpolargl fixes #3098
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4b6cf3d
make sure old scenes on polar subplot are destroyed
etpinard e66b508
bring scatterpolargl axis expansion on-par with scatterpolar
etpinard f79c64c
no need to set 'stash.count'
etpinard 8c94a08
use correct variable names
etpinard 25fb7dc
compute scatterpolargl style opts during calc
etpinard cab319d
add another svg <-> gl test
etpinard 4382fc7
Merge branch 'master' into scatterpolargl-2-scatterpolar
etpinard 7c0526a
aj-proof '++' expressions
etpinard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,47 +13,63 @@ var isNumeric = require('fast-isnumeric'); | |
|
||
var ScatterGl = require('../scattergl'); | ||
var calcColorscales = require('../scatter/colorscale_calc'); | ||
var calcMarkerSize = require('../scatter/calc').calcMarkerSize; | ||
var convert = require('../scattergl/convert'); | ||
|
||
var Lib = require('../../lib'); | ||
var Axes = require('../../plots/cartesian/axes'); | ||
var makeHoverPointText = require('../scatterpolar/hover').makeHoverPointText; | ||
var subTypes = require('../scatter/subtypes'); | ||
|
||
var TOO_MANY_POINTS = require('../scattergl/constants').TOO_MANY_POINTS; | ||
|
||
function calc(container, trace) { | ||
var layout = container._fullLayout; | ||
function calc(gd, trace) { | ||
var fullLayout = gd._fullLayout; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ha yeah, that's certainly clearer! 🍰 |
||
var subplotId = trace.subplot; | ||
var radialAxis = layout[subplotId].radialaxis; | ||
var angularAxis = layout[subplotId].angularaxis; | ||
var radialAxis = fullLayout[subplotId].radialaxis; | ||
var angularAxis = fullLayout[subplotId].angularaxis; | ||
var rArray = radialAxis.makeCalcdata(trace, 'r'); | ||
var thetaArray = angularAxis.makeCalcdata(trace, 'theta'); | ||
var len = trace._length; | ||
var stash = {}; | ||
|
||
if(trace._length < rArray.length) rArray = rArray.slice(0, trace._length); | ||
if(trace._length < thetaArray.length) thetaArray = thetaArray.slice(0, trace._length); | ||
|
||
calcColorscales(trace); | ||
if(len < rArray.length) rArray = rArray.slice(0, len); | ||
if(len < thetaArray.length) thetaArray = thetaArray.slice(0, len); | ||
|
||
stash.r = rArray; | ||
stash.theta = thetaArray; | ||
|
||
trace._extremes.x = Axes.findExtremes(radialAxis, rArray, {tozero: true}); | ||
calcColorscales(trace); | ||
|
||
// only compute 'style' options in calc, as position options | ||
// depend on the radial range and must be set in plot | ||
var opts = stash.opts = convert.style(gd, trace); | ||
|
||
// For graphs with very large number of points and array marker.size, | ||
// use average marker size instead to speed things up. | ||
var ppad = len < TOO_MANY_POINTS ? | ||
calcMarkerSize(trace, len) : | ||
2 * (opts.marker.sizeAvg || Math.max(opts.marker.size, 3)); | ||
trace._extremes.x = Axes.findExtremes(radialAxis, rArray, {ppad: ppad}); | ||
|
||
return [{x: false, y: false, t: stash, trace: trace}]; | ||
} | ||
|
||
function plot(container, subplot, cdata) { | ||
function plot(gd, subplot, cdata) { | ||
if(!cdata.length) return; | ||
|
||
var radialAxis = subplot.radialAxis; | ||
var angularAxis = subplot.angularAxis; | ||
var scene = ScatterGl.sceneUpdate(gd, subplot); | ||
|
||
var scene = ScatterGl.sceneUpdate(container, subplot); | ||
|
||
cdata.forEach(function(cdscatter, traceIndex) { | ||
cdata.forEach(function(cdscatter) { | ||
if(!cdscatter || !cdscatter[0] || !cdscatter[0].trace) return; | ||
var cd = cdscatter[0]; | ||
var trace = cd.trace; | ||
var stash = cd.t; | ||
var len = trace._length; | ||
var rArray = stash.r; | ||
var thetaArray = stash.theta; | ||
var opts = stash.opts; | ||
var i; | ||
|
||
var subRArray = rArray.slice(); | ||
|
@@ -67,12 +83,11 @@ function plot(container, subplot, cdata) { | |
} | ||
} | ||
|
||
var count = rArray.length; | ||
var positions = new Array(count * 2); | ||
var x = Array(count); | ||
var y = Array(count); | ||
var positions = new Array(len * 2); | ||
var x = Array(len); | ||
var y = Array(len); | ||
|
||
for(i = 0; i < count; i++) { | ||
for(i = 0; i < len; i++) { | ||
var r = subRArray[i]; | ||
var xx, yy; | ||
|
||
|
@@ -88,54 +103,69 @@ function plot(container, subplot, cdata) { | |
y[i] = positions[i * 2 + 1] = yy; | ||
} | ||
|
||
var options = ScatterGl.sceneOptions(container, subplot, trace, positions); | ||
|
||
// set flags to create scene renderers | ||
if(options.fill && !scene.fill2d) scene.fill2d = true; | ||
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); | ||
|
||
// FIXME: see scattergl.js#109 | ||
if(options.marker && count >= TOO_MANY_POINTS) { | ||
options.marker.cluster = stash.tree; | ||
if(opts.marker && len >= TOO_MANY_POINTS) { | ||
opts.marker.cluster = stash.tree; | ||
} | ||
|
||
// bring positions to selected/unselected options | ||
if(subTypes.hasMarkers(trace)) { | ||
options.markerSel.positions = options.markerUnsel.positions = options.marker.positions; | ||
if(opts.marker) { | ||
opts.markerSel.positions = opts.markerUnsel.positions = opts.marker.positions = positions; | ||
} | ||
|
||
// save scene options batch | ||
scene.lineOptions.push(options.line); | ||
scene.errorXOptions.push(options.errorX); | ||
scene.errorYOptions.push(options.errorY); | ||
scene.fillOptions.push(options.fill); | ||
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 | ||
stash._scene = scene; | ||
stash.index = traceIndex; | ||
if(opts.line && positions.length > 1) { | ||
Lib.extendFlat( | ||
opts.line, | ||
convert.linePositions(gd, trace, positions) | ||
); | ||
} | ||
|
||
if(opts.text) { | ||
Lib.extendFlat( | ||
opts.text, | ||
{positions: positions}, | ||
convert.textPosition(gd, trace, opts.text, opts.marker) | ||
); | ||
Lib.extendFlat( | ||
opts.textSel, | ||
{positions: positions}, | ||
convert.textPosition(gd, trace, opts.text, opts.markerSel) | ||
); | ||
Lib.extendFlat( | ||
opts.textUnsel, | ||
{positions: positions}, | ||
convert.textPosition(gd, trace, opts.text, opts.markerUnsel) | ||
); | ||
} | ||
|
||
if(opts.fill && !scene.fill2d) scene.fill2d = true; | ||
if(opts.marker && !scene.scatter2d) scene.scatter2d = true; | ||
if(opts.line && !scene.line2d) scene.line2d = true; | ||
if(opts.text && !scene.glText) scene.glText = true; | ||
|
||
scene.lineOptions.push(opts.line); | ||
scene.fillOptions.push(opts.fill); | ||
scene.markerOptions.push(opts.marker); | ||
scene.markerSelectedOptions.push(opts.markerSel); | ||
scene.markerUnselectedOptions.push(opts.markerUnsel); | ||
scene.textOptions.push(opts.text); | ||
scene.textSelectedOptions.push(opts.textSel); | ||
scene.textUnselectedOptions.push(opts.textUnsel); | ||
|
||
stash.x = x; | ||
stash.y = y; | ||
stash.rawx = x; | ||
stash.rawy = y; | ||
stash.r = rArray; | ||
stash.theta = thetaArray; | ||
stash.positions = positions; | ||
stash.count = count; | ||
stash._scene = scene; | ||
stash.index = scene.count; | ||
scene.count++; | ||
}); | ||
|
||
return ScatterGl.plot(container, subplot, cdata); | ||
return ScatterGl.plot(gd, subplot, cdata); | ||
} | ||
|
||
function hoverPoints(pointData, xval, yval, hovermode) { | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.