Replies: 1 comment
-
Hi @alicewuu 👋 You can easily access the import React, { useContext } from "react";
import { DataContext, LineSeries, XYChart, ... } from "@visx/xychart";
function MyChart() {
return (
<XYChart {...props}>
<LineSeries {...lineProps} />
<CustomSeries />
</XYChart>
);
}
function CustomSeries() {
const { xScale, yScale, ... } = useContext(DataContext);
// use scales with `SplitLinePath`, note they may be `null` on first render
} I think that's probably all you need to overlay a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I am trying to scale the SplitLinePath to align with a LineSeries from the XYChart, I found that LineSeries is scaled with the getScaledValueFactory and am trying to imitate that behavior with SplitLinePath. I have tried
<g transform="translate(0)"> <SplitLinePath sampleRate={1} styles={...} segments={segments} x={d => scaleLinear({ range: [0, chartWidth], domain: [0, data.length], })(d.x) } y={d => scaleLinear({ range: [chartHeight, 0], domain: [ 0, Math.max(data.map(d => d.y || 1)), ], })(d.y) } segmentation={'x'} /> </g>
but it does not look quite right
Here is my LineSeries code for reference:
<XYChart theme={customTheme} height={chartHeight} width={chartWidth} xScale={{ type: 'linear' }} yScale={{ type: 'linear' }} margin={{ top: chartMargin, left: chartMargin, bottom: chartMargin, right: chartMargin, }} > <LineSeries dataKey="LineSeries" data={d} {...accessors} strokeWidth={2} /> </XYChart>
Beta Was this translation helpful? Give feedback.
All reactions