Skip to content

Commit

Permalink
Create appearance.js
Browse files Browse the repository at this point in the history
New stackOrder, d3.stackOrderAppearance(), if you name it (I am not sure of my English)

Returns a series order such that the earliest series (index where value > 0 for the first time) is at the bottom. Convenient to make streamgraph look like twisted cord for data entity appears one after another like boxoffice data.
  • Loading branch information
isaomatsunami authored and mbostock committed Jan 23, 2019
1 parent 63d7507 commit 8b17156
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/order/appearance

This file was deleted.

10 changes: 10 additions & 0 deletions src/order/appearance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default function(series) {
var appearanceIndex = series.map(function(d,i){
for(var k = 0, n = d.length;k < n;++k){
if(d[k][1] > 0) break;
}
return [k, i];
});
appearanceIndex.sort(function(a,b){return a[0] - b[0];})
return appearanceIndex.map(function(d){return d[1]});
}

0 comments on commit 8b17156

Please sign in to comment.