Closed clemwo closed 1 month ago
Hi @clemwo , The voronoiBlacklist prop is used to specify a list of components to ignore when calculating a shared voronoi diagram. Here is the link for the same https://commerce.nearform.com/open-source/victory/docs/victory-voronoi-container#voronoiblacklist .
Using this, the below code example works in your use case.
<VictoryChart
containerComponent={
<VictoryVoronoiContainer
labels={({ datum }) => getLabel(datum)}
voronoiBlacklist={["ignore"]}
/>
}
>
<VictoryAxis />
<VictoryAxis dependentAxis />
<VictoryGroup>
<VictoryLine data={secondLine} style={{ data: { stroke: "red" } }} />
<VictoryLine data={firstLine} style={{ data: { stroke: "blue" } }} />
</VictoryGroup>
<VictoryLine
name="ignore"
x={() => 5}
style={{ data: { strokeWidth: 0.5 } }}
/>
</VictoryChart>
@clemwo Explaination to the use case of using VictoryVoronoiContainer as a prop in VictoryGroup :
As per https://commerce.nearform.com/open-source/victory/docs/victory-voronoi-container to use containerComponent
prop, the React component has to be standalone or top level element. In the above code example, that I shared, VictoryChart is a standalone element and containerComponent
can be used.
Below is a code example for Victory Group using containerComponent
.
<VictoryGroup
containerComponent={
<VictoryVoronoiContainer
labels={({ datum }) => datum.x} />
}
>
<VictoryLine
data={[
{ x: 1, y: 3 },
{ x: 2, y: 4 },
{ x: 3, y: 3 },
{ x: 4, y: 1 },
{ x: 5, y: 2 },
{ x: 6, y: 3 },
{ x: 7, y: 3 },
]}
style={{ data: { stroke: "red" } }} />
<VictoryLine
data={[
{ x: 1, y: 2 },
{ x: 2, y: 4.32332 },
{ x: 3, y: 3.87543 },
{ x: 4, y: 1.1251 },
{ x: 5, y: 2.123241 },
{ x: 6, y: 3.5231 },
{ x: 7, y: 3 },
]} style={{ data: { stroke: "blue" } }} />
</VictoryGroup>
VictoryGroup doesn't have axes here and it won't work for your code scenario . But it works when used as standalone component. Hope this resolves your issue. Please re-open the ticket if the response is unsatisfactory.
Is there an existing issue for this?
Code of Conduct
Victory version
37.0.2
Code Sandbox link
https://codesandbox.io/p/sandbox/victory-v35-0-3-works-forked-qzs33q?file=%2Fsrc%2FApp.js
Bug report
Steps to reproduce
Actual behavior
Environment