From cac91e1ed20f98ebbb0d292d3483ac4f82c1bafa Mon Sep 17 00:00:00 2001 From: Luca Falasco Date: Thu, 4 Oct 2018 10:45:48 +0200 Subject: [PATCH] add scale type --- packages/vx-scale/src/scales/band.js | 1 + packages/vx-scale/src/scales/linear.js | 1 + packages/vx-scale/src/scales/log.js | 1 + packages/vx-scale/src/scales/ordinal.js | 1 + packages/vx-scale/src/scales/point.js | 1 + packages/vx-scale/src/scales/power.js | 1 + packages/vx-scale/src/scales/quantile.js | 1 + packages/vx-scale/src/scales/quantize.js | 1 + packages/vx-scale/src/scales/threshold.js | 1 + packages/vx-scale/src/scales/time.js | 1 + packages/vx-scale/src/scales/utc.js | 1 + 11 files changed, 11 insertions(+) diff --git a/packages/vx-scale/src/scales/band.js b/packages/vx-scale/src/scales/band.js index b4dc50c57..9842938a8 100644 --- a/packages/vx-scale/src/scales/band.js +++ b/packages/vx-scale/src/scales/band.js @@ -11,6 +11,7 @@ export default ({ tickFormat }) => { const scale = scaleBand(); + scale.type = 'band'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/linear.js b/packages/vx-scale/src/scales/linear.js index 530377846..f7a24aa73 100644 --- a/packages/vx-scale/src/scales/linear.js +++ b/packages/vx-scale/src/scales/linear.js @@ -2,6 +2,7 @@ import { scaleLinear } from 'd3-scale'; export default ({ range, rangeRound, domain, nice = false, clamp = false }) => { const scale = scaleLinear(); + scale.type = 'linear'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/log.js b/packages/vx-scale/src/scales/log.js index 500a182a3..02cdaad23 100644 --- a/packages/vx-scale/src/scales/log.js +++ b/packages/vx-scale/src/scales/log.js @@ -2,6 +2,7 @@ import { scaleLog } from 'd3-scale'; export default ({ range, rangeRound, domain, base, nice = false, clamp = false }) => { const scale = scaleLog(); + scale.type = 'log'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/ordinal.js b/packages/vx-scale/src/scales/ordinal.js index 07a398efb..bd1b513c1 100644 --- a/packages/vx-scale/src/scales/ordinal.js +++ b/packages/vx-scale/src/scales/ordinal.js @@ -2,6 +2,7 @@ import { scaleOrdinal } from 'd3-scale'; export default ({ range, domain, unknown }) => { const scale = scaleOrdinal(); + scale.type = 'ordinal'; if (range) scale.range(range); if (domain) scale.domain(domain); diff --git a/packages/vx-scale/src/scales/point.js b/packages/vx-scale/src/scales/point.js index e9a0bf876..b31b385c9 100644 --- a/packages/vx-scale/src/scales/point.js +++ b/packages/vx-scale/src/scales/point.js @@ -2,6 +2,7 @@ import { scalePoint } from 'd3-scale'; export default ({ range, rangeRound, domain, padding, align, nice = false }) => { const scale = scalePoint(); + scale.type = 'point'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/power.js b/packages/vx-scale/src/scales/power.js index 1739931ef..ea7bf17f6 100644 --- a/packages/vx-scale/src/scales/power.js +++ b/packages/vx-scale/src/scales/power.js @@ -2,6 +2,7 @@ import { scalePow } from 'd3-scale'; export default ({ range, rangeRound, domain, exponent, nice = false, clamp = false }) => { const scale = scalePow(); + scale.type = 'power'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/quantile.js b/packages/vx-scale/src/scales/quantile.js index f38d020d1..01a2482d7 100644 --- a/packages/vx-scale/src/scales/quantile.js +++ b/packages/vx-scale/src/scales/quantile.js @@ -2,6 +2,7 @@ import { scaleQuantile } from 'd3-scale'; export default ({ range, domain }) => { const scale = scaleQuantile(); + scale.type = 'quantile'; if (range) scale.range(range); if (domain) scale.domain(domain); diff --git a/packages/vx-scale/src/scales/quantize.js b/packages/vx-scale/src/scales/quantize.js index 7ba0e6073..3ae478443 100644 --- a/packages/vx-scale/src/scales/quantize.js +++ b/packages/vx-scale/src/scales/quantize.js @@ -2,6 +2,7 @@ import { scaleQuantize } from 'd3-scale'; export default ({ range, domain, ticks, tickFormat, nice = false }) => { const scale = scaleQuantize(); + scale.type = 'quantize'; if (range) scale.range(range); if (domain) scale.domain(domain); diff --git a/packages/vx-scale/src/scales/threshold.js b/packages/vx-scale/src/scales/threshold.js index e55bddf2b..117dd4f60 100644 --- a/packages/vx-scale/src/scales/threshold.js +++ b/packages/vx-scale/src/scales/threshold.js @@ -2,6 +2,7 @@ import { scaleThreshold } from 'd3-scale'; export default ({ range, domain }) => { const scale = scaleThreshold(); + scale.type = 'threshold'; if (range) scale.range(range); if (domain) scale.domain(domain); diff --git a/packages/vx-scale/src/scales/time.js b/packages/vx-scale/src/scales/time.js index a4d936b99..330f1b1bf 100644 --- a/packages/vx-scale/src/scales/time.js +++ b/packages/vx-scale/src/scales/time.js @@ -2,6 +2,7 @@ import { scaleTime } from 'd3-scale'; export default ({ range, rangeRound, domain, nice = false, clamp = false }) => { const scale = scaleTime(); + scale.type = 'time'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound); diff --git a/packages/vx-scale/src/scales/utc.js b/packages/vx-scale/src/scales/utc.js index 2556f0297..4a4f8427b 100644 --- a/packages/vx-scale/src/scales/utc.js +++ b/packages/vx-scale/src/scales/utc.js @@ -2,6 +2,7 @@ import { scaleUtc } from 'd3-scale'; export default ({ range, rangeRound, domain, nice = false, clamp = false }) => { const scale = scaleUtc(); + scale.type = 'utc'; if (range) scale.range(range); if (rangeRound) scale.rangeRound(rangeRound);