diff --git a/demo/components/victory-area-demo.js b/demo/components/victory-area-demo.js
index 0f65a747..542a2842 100644
--- a/demo/components/victory-area-demo.js
+++ b/demo/components/victory-area-demo.js
@@ -98,12 +98,24 @@ export default class App extends React.Component {
return (
+
+
+
+
+
+
+
-
);
}
diff --git a/demo/components/victory-bar-demo.js b/demo/components/victory-bar-demo.js
index d0931261..b4984a04 100644
--- a/demo/components/victory-bar-demo.js
+++ b/demo/components/victory-bar-demo.js
@@ -79,7 +79,7 @@ export default class App extends React.Component {
getBarTransitionData() {
const bars = random(6, 10);
return range(bars).map((bar) => {
- return {x: bar, y: random(2, 10)};
+ return {x: bar + 1, y: random(2, 10)};
});
}
@@ -87,7 +87,7 @@ export default class App extends React.Component {
const bars = random(3, 5);
return range(4).map(() => {
return range(bars).map((bar) => {
- return {x: bar, y: random(2, 10)};
+ return {x: bar + 1, y: random(2, 10)};
});
});
}
@@ -101,7 +101,7 @@ export default class App extends React.Component {
multiTransitionData: this.getMultiTransitionData(),
numericBarData: this.getNumericBarData()
});
- }, 2000);
+ }, 10000);
}
componentWillUnmount() {
@@ -114,6 +114,38 @@ export default class App extends React.Component {
return (
VictoryBar
+
+
+
+
+
+
+
-
+
+
+
+
@@ -192,17 +246,16 @@ export default class App extends React.Component {
})}
-
-
- {this.state.multiTransitionData.map((data, index) => {
- return ;
- })}
-
+
+
+ {this.state.multiTransitionData.map((data, index) => {
+ return ;
+ })}
+
+
+
+
0 ? Math.min(...domain.y) : 0;
+ const defaultMin = Scale.getScaleType(props, "y") === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
+
+ const minY = Math.min(...domain.y) > 0 ? Math.min(...domain.y) : defaultMin;
return data.map((datum) => {
const y1 = datum.yOffset ? datum.yOffset + datum.y : datum.y;
const y0 = datum.yOffset || minY;
diff --git a/src/components/victory-axis/helper-methods.js b/src/components/victory-axis/helper-methods.js
index 4cc578d0..352410ff 100644
--- a/src/components/victory-axis/helper-methods.js
+++ b/src/components/victory-axis/helper-methods.js
@@ -26,7 +26,8 @@ export default {
} else if (props.tickValues) {
domain = Domain.getDomainFromTickValues(props);
}
- return domain ? Domain.padDomain(domain, props, inherentAxis) : undefined;
+ const paddedDomain = Domain.padDomain(domain, props, inherentAxis);
+ return domain ? Domain.cleanDomain(paddedDomain, props, inherentAxis) : undefined;
},
// exposed for use by VictoryChart
diff --git a/src/components/victory-bar/helper-methods.js b/src/components/victory-bar/helper-methods.js
index fa846ec6..64a3f120 100644
--- a/src/components/victory-bar/helper-methods.js
+++ b/src/components/victory-bar/helper-methods.js
@@ -25,9 +25,12 @@ export default {
},
getBarPosition(props, datum, scale) {
+ const currentAxis = props.horizontal ? "x" : "y";
+ const defaultMin = Scale.getScaleType(props, currentAxis) === "log" ?
+ 1 / Number.MAX_SAFE_INTEGER : 0;
const yOffset = datum.yOffset || 0;
const xOffset = datum.xOffset || 0;
- const y0 = yOffset;
+ const y0 = yOffset || defaultMin;
const y = datum.y + yOffset;
const x = datum.x + xOffset;
const formatValue = (value, axis) => {
diff --git a/src/components/victory-candlestick/helper-methods.js b/src/components/victory-candlestick/helper-methods.js
index 1acc618f..e74ebb42 100644
--- a/src/components/victory-candlestick/helper-methods.js
+++ b/src/components/victory-candlestick/helper-methods.js
@@ -110,7 +110,7 @@ export default {
}
domain = [min, max];
}
- return Domain.padDomain(domain, props, axis);
+ return Domain.cleanDomain(Domain.padDomain(domain, props, axis), props);
},
isTransparent(attr) {
diff --git a/src/components/victory-chart/victory-chart.js b/src/components/victory-chart/victory-chart.js
index 333f5793..46720a45 100644
--- a/src/components/victory-chart/victory-chart.js
+++ b/src/components/victory-chart/victory-chart.js
@@ -249,7 +249,7 @@ export default class VictoryChart extends React.Component {
}
getAxisProps(child, props, calculatedProps) {
- const {domain, scale} = calculatedProps;
+ const { domain, scale } = calculatedProps;
const axis = child.type.getAxis(child.props);
const axisOffset = ChartHelpers.getAxisOffset(props, calculatedProps);
const tickValues = ChartHelpers.getTicks(calculatedProps, axis, child);
diff --git a/src/components/victory-errorbar/helper-methods.js b/src/components/victory-errorbar/helper-methods.js
index eb7f4b40..c20cad6a 100644
--- a/src/components/victory-errorbar/helper-methods.js
+++ b/src/components/victory-errorbar/helper-methods.js
@@ -149,7 +149,7 @@ export default {
}
const dataset = this.getErrorData(props);
const domain = this.getDomainFromData(props, axis, dataset);
- return Domain.padDomain(domain, props, axis);
+ return Domain.cleanDomain(Domain.padDomain(domain, props, axis), props);
},
getDomainFromData(props, axis, dataset) {
diff --git a/src/helpers/domain.js b/src/helpers/domain.js
index b3f4eeb2..4c3e3790 100644
--- a/src/helpers/domain.js
+++ b/src/helpers/domain.js
@@ -1,6 +1,7 @@
import { flatten, includes, isPlainObject } from "lodash";
import Data from "./data";
import Axis from "./axis";
+import Scale from "./scale";
import { Helpers, Collection } from "victory-core";
export default {
@@ -15,13 +16,35 @@ export default {
}
const dataset = Data.getData(props);
const domain = this.getDomainFromData(props, axis, dataset);
- return this.padDomain(domain, props, axis);
+ return this.cleanDomain(this.padDomain(domain, props, axis), props, axis);
+ },
+
+ cleanDomain(domain, props, axis) {
+ // Some scale types break when certain data is supplies. This method will
+ // remove data points that break scales. So far this method only removes
+ // zeroes for log scales
+ // TODO other cases?
+ const scaleType = Scale.getScaleType(props, axis);
+
+ if (scaleType !== "log") {
+ return domain;
+ }
+
+ const rules = (dom) => {
+ const almostZero = dom[0] < 0 || dom[1] < 0 ? -1 / Number.MAX_SAFE_INTEGER
+ : 1 / Number.MAX_SAFE_INTEGER;
+ const domainOne = dom[0] === 0 ? almostZero : dom[0];
+ const domainTwo = dom[1] === 0 ? almostZero : dom[1];
+ return [domainOne, domainTwo];
+ };
+
+ return rules(domain);
},
getDomainWithZero(props, axis) {
const propsDomain = this.getDomainFromProps(props, axis);
if (propsDomain) {
- return this.padDomain(propsDomain, props, axis);
+ return this.cleanDomain(this.padDomain(propsDomain, props, axis), props, axis);
}
const { horizontal } = props;
const ensureZero = (domain) => {
@@ -33,11 +56,11 @@ export default {
};
const categoryDomain = this.getDomainFromCategories(props, axis);
if (categoryDomain) {
- return this.padDomain(ensureZero(categoryDomain), props, axis);
+ return this.cleanDomain(this.padDomain(ensureZero(categoryDomain), props, axis), props, axis);
}
const dataset = Data.getData(props);
const domain = ensureZero(this.getDomainFromData(props, axis, dataset));
- return this.padDomain(domain, props, axis);
+ return this.cleanDomain(this.padDomain(domain, props, axis), props, axis);
},
getDomainFromProps(props, axis) {
diff --git a/src/helpers/wrapper.js b/src/helpers/wrapper.js
index 1446056a..08e9203a 100644
--- a/src/helpers/wrapper.js
+++ b/src/helpers/wrapper.js
@@ -18,7 +18,9 @@ export default {
return propsDomain;
}
childComponents = childComponents || React.Children.toArray(props.children);
- return this.getDomainFromChildren(props, axis, childComponents);
+ return Domain.cleanDomain(this.getDomainFromChildren(props, axis, childComponents),
+ props,
+ axis);
},
setAnimationState(nextProps) {