Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #539 from FormidableLabs/bug/bubble-plot-z
Browse files Browse the repository at this point in the history
prevent error in bubble plots with single z value
  • Loading branch information
boygirl authored Nov 15, 2017
2 parents 4d1d5c8 + a6c3a7e commit cb96f99
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/victory-scatter/helper-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,18 @@ export default {

getBubbleSize(datum, props) {
const { data, z, maxBubbleSize, minBubbleSize } = props;
const zData = data.map((point) => point[z]);
const zMin = Math.min(...zData);
const zMax = Math.max(...zData);
const getMaxRadius = () => {
const minPadding = Math.min(...values(Helpers.getPadding(props)));
return Math.max(minPadding, 5); // eslint-disable-line no-magic-numbers
};
const zData = data.map((point) => point[z]);
const zMin = Math.min(...zData);
const zMax = Math.max(...zData);
const maxRadius = maxBubbleSize || getMaxRadius();
const minRadius = minBubbleSize || maxRadius * 0.1; // eslint-disable-line no-magic-numbers
if (zMax === zMin) {
return Math.max(minRadius, 1);
}
const maxArea = Math.PI * Math.pow(maxRadius, 2);
const minArea = Math.PI * Math.pow(minRadius, 2);
const pointArea = ((datum[z] - zMin) / (zMax - zMin)) * maxArea;
Expand Down

0 comments on commit cb96f99

Please sign in to comment.