Skip to content

Commit

Permalink
isofence style
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaffuri committed Oct 26, 2023
1 parent 42b11f1 commit bc43e69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 11 additions & 3 deletions dist/gridviz.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/styles/isofence.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
men_2_4ind: '#1b9e77', //green
men_5ind: '#d95f02', //orange*/
},
angle: 50,
angle: -50,
heightCol: 'ind',
height: (v, r, s, zf) => 0.99 * r * gviz.sExpRev(v / s.max, -7, 0),
}),
],
{
pixNb: 20,
pixNb: 25,
preprocess: (c) => {
c.ind_0_17 = +c.ind_0_3 + +c.ind_4_5 + +c.ind_6_10 + +c.ind_11_17
c.ind_18_64 = +c.ind_18_24 + +c.ind_25_39 + +c.ind_40_54 + +c.ind_55_64
Expand Down
12 changes: 10 additions & 2 deletions src/style/IsoFenceStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,16 @@ export class IsoFenceStyle extends Style {
//draw in geo coordinates
cg.setCanvasTransform()

//sort sides so that the north east ones are drown first
sides.sort((s1, s2) => (Math.hypot(s2.x, s2.y) - Math.hypot(s1.x, s1.y)))
//sort sides so that the back ones are drawn first. This depends on the angle
if (Math.abs(this.angle) <= 90)
//north east ones are drown first
sides.sort((s1, s2) => (Math.hypot(s2.x, s2.y) - Math.hypot(s1.x, s1.y)))
else if (this.angle > 90)
//north west ones are drown first
sides.sort((s1, s2) => (Math.hypot(s2.x - cg.extGeo.xMax, s2.y) - Math.hypot(s1.x - cg.extGeo.xMax, s1.y)))
else if (this.angle < 90)
//south west ones are drown first
sides.sort((s1, s2) => (Math.hypot(s2.x - cg.extGeo.xMax, s2.y - cg.extGeo.yMax) - Math.hypot(s1.x - cg.extGeo.xMax, s1.y - cg.extGeo.yMax)))

//draw sides
for (let s of sides) {
Expand Down

0 comments on commit bc43e69

Please sign in to comment.