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 #591 from FormidableLabs/bug/voronoi-container-wit…
Browse files Browse the repository at this point in the history
…h-group

Bug/voronoi container with group
  • Loading branch information
boygirl authored Apr 25, 2018
2 parents fc29f21 + d8e3cd0 commit 2a4c2a2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
69 changes: 69 additions & 0 deletions demo/components/victory-voronoi-container-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,75 @@ class App extends React.Component {
y={(d) => d.x * d.x}
/>

<VictoryChart
height={450}
padding={{ top: 100, bottom: 20, left: 50, right: 50 }}
style={chartStyle}
containerComponent={
<VictoryVoronoiContainer
voronoiBlacklist={["ignore"]}
voronoiDimension="x"
labels={(d) => d.y}
labelComponent={<VictoryTooltip/>}
/>
}
>
<VictoryGroup
data={[
{ x: 1, y: -5 },
{ x: 2, y: 4 },
{ x: 3, y: 2 },
{ x: 4, y: 0 },
{ x: 5, y: 1 },
{ x: 6, y: -3 },
{ x: 7, y: 3 }
]}
>
<VictoryScatter
style={{
data: { fill: "tomato" }
}}
size={(datum, active) => active ? 5 : 3}
/>
<VictoryLine name="ignore" style={{ data: { stroke: "tomato" } }}/>
</VictoryGroup>
<VictoryGroup
data={[
{ x: 1, y: -3 },
{ x: 2, y: 5 },
{ x: 3, y: 3 },
{ x: 4, y: 0 },
{ x: 5, y: -2 },
{ x: 6, y: -2 },
{ x: 7, y: 5 }
]}
>
<VictoryScatter
style={{
data: { fill: "blue" }
}}
size={(datum, active) => active ? 5 : 3}
/>
<VictoryLine name="ignore" style={{ data: { stroke: "blue" } }}/>
</VictoryGroup>
<VictoryGroup
data={[
{ x: 1, y: 5 },
{ x: 2, y: -4 },
{ x: 3, y: -2 },
{ x: 4, y: -3 },
{ x: 5, y: -1 },
{ x: 6, y: 3 },
{ x: 7, y: -3 }
]}
>
<VictoryScatter
size={(datum, active) => active ? 5 : 3}
/>
<VictoryLine name="ignore"/>
</VictoryGroup>
</VictoryChart>

<VictoryChart
height={450}
padding={{ top: 100, bottom: 20, left: 50, right: 50 }}
Expand Down
6 changes: 4 additions & 2 deletions src/components/containers/voronoi-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const VoronoiHelpers = {

const iteratee = (child, childName, parent) => {
const role = child.type && child.type.role;

const childProps = child.props || {};

const blacklist = props.voronoiBlacklist || [];
if (role === "axis" || role === "legend" || role === "label") {
return null;
Expand All @@ -52,8 +54,8 @@ const VoronoiHelpers = {
return null;
} else if (child.type && isFunction(child.type.getData)) {
child = parent ? React.cloneElement(child, parent.props) : child;
const childData = childProps
&& child.type.getData({ ...childProps, domain: props.domain });
const childData = child.props
&& child.type.getData({ ...child.props, domain: props.domain });
return childData ? addMeta(childData, childName, child) : null;
} else {
const childData = getData({ ...childProps, domain: props.domain });
Expand Down

0 comments on commit 2a4c2a2

Please sign in to comment.