react-d3-brush
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -41,16 +41,3 @@ 'use strict'; | ||
value: function mkXDomain() { | ||
var _props = this.props; | ||
var data = _props.data; | ||
var x = _props.x; | ||
var xScale = _props.xScale; | ||
if (xScale === 'ordinal') { | ||
return this.setXDomain = data.map(function (d) { | ||
return x(d); | ||
}); | ||
} else { | ||
return this.setXDomain = d3.extent(data, function (d) { | ||
return x(d); | ||
}); | ||
} | ||
return this.setXDomain = (0, _reactD3Core.xDomainCount)(this.props); | ||
} | ||
@@ -60,44 +47,3 @@ }, { | ||
value: function mkYDomain(stack) { | ||
var _props2 = this.props; | ||
var data = _props2.data; | ||
var chartSeries = _props2.chartSeries; | ||
var y = _props2.y; | ||
if (stack) { | ||
// stack | ||
var max = 0; | ||
var min = 0; | ||
data.forEach(function (d) { | ||
var totalTop = 0; | ||
var totalBottom = 0; | ||
chartSeries.forEach(function (sd) { | ||
var field = sd.field; | ||
if (d[field] > 0) { | ||
totalTop += y(d[field]); | ||
} else if (d[field] < 0) { | ||
totalBottom += y(d[field]); | ||
} | ||
}); | ||
if (totalTop > max) max = totalTop; | ||
if (totalBottom < min) min = totalBottom; | ||
}); | ||
return this.setYDomain = [min, max]; | ||
} else { | ||
// not stack, single | ||
var domainArr = chartSeries.map(function (d) { | ||
var field = d.field; | ||
var extent = d3.extent(data, function (dt) { | ||
return y(dt[field]); | ||
}); | ||
return extent; | ||
}); | ||
return this.setYDomain = d3.extent([].concat.apply([], domainArr)); | ||
} | ||
return this.setYDomain = (0, _reactD3Core.yDomainCount)(this.props, stack); | ||
} | ||
@@ -107,11 +53,11 @@ }, { | ||
value: function setDomain(axis, val) { | ||
var _props3 = this.props; | ||
var xScale = _props3.xScale; | ||
var xRange = _props3.xRange; | ||
var xDomain = _props3.xDomain; | ||
var xRangeRoundBands = _props3.xRangeRoundBands; | ||
var yScale = _props3.yScale; | ||
var yRange = _props3.yRange; | ||
var yDomain = _props3.yDomain; | ||
var yRangeRoundBands = _props3.yRangeRoundBands; | ||
var _props = this.props; | ||
var xScale = _props.xScale; | ||
var xRange = _props.xRange; | ||
var xDomain = _props.xDomain; | ||
var xRangeRoundBands = _props.xRangeRoundBands; | ||
var yScale = _props.yScale; | ||
var yRange = _props.yRange; | ||
var yDomain = _props.yDomain; | ||
var yRangeRoundBands = _props.yRangeRoundBands; | ||
@@ -118,0 +64,0 @@ if (axis === 'x') { |
{ | ||
"name": "react-d3-brush", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "react-d3 brush implementation", | ||
@@ -43,5 +43,5 @@ "main": "./lib/index", | ||
"react-d3-basic": "^0.9.0", | ||
"react-d3-core": "^0.5.4", | ||
"react-d3-core": "^0.7.0", | ||
"react-dom": "^0.14.0" | ||
} | ||
} |
@@ -10,3 +10,5 @@ "use sctrict" | ||
import { | ||
scale as scale | ||
scale, | ||
xDomainCount, | ||
yDomainCount | ||
} from 'react-d3-core'; | ||
@@ -26,57 +28,7 @@ | ||
mkXDomain() { | ||
const { | ||
data, | ||
x, | ||
xScale | ||
} = this.props; | ||
if(xScale === 'ordinal') { | ||
return this.setXDomain = data.map((d) => { return x(d); }); | ||
}else { | ||
return this.setXDomain = d3.extent(data, (d) => { return x(d); }); | ||
} | ||
return this.setXDomain = xDomainCount(this.props); | ||
} | ||
mkYDomain(stack) { | ||
const { | ||
data, | ||
chartSeries, | ||
y | ||
} = this.props; | ||
if(stack) { | ||
// stack | ||
var max = 0; | ||
var min = 0; | ||
data.forEach((d) => { | ||
var totalTop = 0; | ||
var totalBottom = 0; | ||
chartSeries.forEach((sd) => { | ||
var field = sd.field; | ||
if(d[field] > 0) { | ||
totalTop += y(d[field]); | ||
}else if (d[field] < 0) { | ||
totalBottom += y(d[field]); | ||
} | ||
}) | ||
if(totalTop > max) max = totalTop; | ||
if(totalBottom < min) min = totalBottom; | ||
}) | ||
return this.setYDomain = [min, max]; | ||
}else { | ||
// not stack, single | ||
var domainArr = chartSeries.map((d) => { | ||
var field = d.field; | ||
var extent = d3.extent(data, (dt) => { return y(dt[field]); }); | ||
return extent; | ||
}) | ||
return this.setYDomain = d3.extent([].concat.apply([], domainArr)); | ||
} | ||
return this.setYDomain = yDomainCount(this.props, stack); | ||
} | ||
@@ -83,0 +35,0 @@ |
66154
1410
+ Addedreact-d3-core@0.7.2(transitive)
Updatedreact-d3-core@^0.7.0