From 8b17156da8de3282c0fa08bfe36814aa3cb176f6 Mon Sep 17 00:00:00 2001 From: Isao Matsunami Date: Wed, 14 Jun 2017 01:48:33 +0900 Subject: [PATCH] Create appearance.js 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. --- src/order/appearance | 10 ---------- src/order/appearance.js | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 src/order/appearance create mode 100644 src/order/appearance.js diff --git a/src/order/appearance b/src/order/appearance deleted file mode 100644 index a25a247..0000000 --- a/src/order/appearance +++ /dev/null @@ -1,10 +0,0 @@ -function stackOrderAppearance(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]}); -} diff --git a/src/order/appearance.js b/src/order/appearance.js new file mode 100644 index 0000000..fb1f3d9 --- /dev/null +++ b/src/order/appearance.js @@ -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]}); +}