8000 Polar polygon grids by etpinard · Pull Request #2739 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Polar polygon grids #2739

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 20 commits into from
Jun 26, 2018
Merged
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
split out angular part of polar.isPtWithinSector into own fn
- which speeds up the category angular tick filter,
  and will help with polygon grids
  • Loading branch information
etpinard committed Jun 15, 2018
commit 33b05eb882df3250f3615394d5bfdd9a8e242a93
43 changes: 22 additions & 21 deletions src/plots/polar/polar.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,7 @@ proto.updateAngularAxis = function(fullLayout, polarLayout) {
angularLayout._categories.length;

ax.range = [0, period];

ax._tickFilter = function(d) {
return _this.isPtWithinSector({
r: _this.radialAxis.range[1],
rad: ax.c2rad(d.x)
});
};
ax._tickFilter = function(d) { return isAngleInSector(c2rad(d), sector); };
}

setScale(ax, angularLayout, fullLayout);
Expand Down Expand Up @@ -1003,17 +997,15 @@ proto.updateAngularDrag = function(fullLayout, polarLayout) {

proto.isPtWithinSector = function(d) {
var sector = this.sector;

if(!isAngleInSector(d.rad, sector)) {
return false;
}

var radialAxis = this.radialAxis;
var radialRange = radialAxis.range;
var r = radialAxis.c2r(d.r);

var s0 = wrap360(sector[0]);
var s1 = wrap360(sector[1]);
if(s0 > s1) s1 += 360;

var deg = wrap360(rad2deg(d.rad));
var nextTurnDeg = deg + 360;

var r0, r1;
if(radialRange[1] >= radialRange[0]) {
r0 = radialRange[0];
Expand All @@ -1023,13 +1015,8 @@ proto.isPtWithinSector = function(d) {
r1 = radialRange[0];
}

return (
(r >= r0 && r <= r1) &&
(isFullCircle(sector) ||
(deg >= s0 && deg <= s1) ||
(nextTurnDeg >= s0 && nextTurnDeg <= s1)
)
);

return r >= r0 && r <= r1;
};

proto.fillViewInitialKey = function(key, val) {
Expand Down Expand Up @@ -1110,6 +1097,20 @@ function computeSectorBBox(sector) {
return [x0, y0, x1, y1];
}

function isAngleInSector(rad, sector) {
if(isFullCircle(sector)) return true;

var s0 = wrap360(sector[0]);
var s1 = wrap360(sector[1]);
if(s0 > s1) s1 += 360;

var deg = wrap360(rad2deg(rad));
var nextTurnDeg = deg + 360;

return (deg >= s0 && deg <= s1) ||
(nextTurnDeg >= s0 && nextTurnDeg <= s1);
}

function pathSector(r, sector) {
if(isFullCircle(sector)) {
return Drawing.symbolFuncs[0](r);
Expand Down
0