Help!, how to create horizontal scrollable realtime chart
See original GitHub issueHello, i need to create a horizontal scrollable areachart,
for me what is happening
- is the data gets crumbled together and brush component is also not moving.it stays fixed.
- I have set the startIndex and endIndex on brush component.
Thankyou
Code:
const [arr, setArr] = React.useState([
{ X: 0 },
{ X: 0 },
{ X: 0 },
{ X: 5 },
{ X: 5 },
{ X: 5 },
]);
const timeoutRef = React.useRef(null);
const validate = React.useCallback(() => {
setArr((prevState) =>
[...prevState, { X: Math.random() >= 0.5 ? 5 : 0 }].slice(1)
);
}, []);
React.useEffect(() => {
if (timeoutRef.current !== null) {
clearTimeout(timeoutRef.current);
}
const interval = 6000;
const speed = 1000;
for (let i = 0; i < interval; i++) {
timeoutRef.current = setTimeout(() => {
timeoutRef.current = null;
validate();
}, i * speed);
}
}, [validate]);
return (
<div>
<h1>{time}</h1>
<AreaChart
width={730}
height={250}
data={arr}
margin={{ top: 5, right: 30, left: 20, bottom: 5 }}
>
{/* <CartesianGrid strokeDasharray='3 3' /> */}
<YAxis />
<XAxis additive='sum' />
<Tooltip />
<Legend />
<Area
type='monotone'
dataKey='X'
stroke='#8884d8'
isAnimationActive={false}
additive='sum'
/>
<Brush startIndex={0} endIndex={10}>
<AreaChart>
<Area dataKey='X' isAnimationActive={false} />
</AreaChart>
</Brush>
</AreaChart>
</div>
);
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (1 by maintainers)
Top Results From Across the Web
javascript - How can I create a horizontal scrolling Chart.js line ...
I'd like to create a line chart with Chart.Js but have the Y-Axis not move when I scroll. I'm assuming I can use...
Read more >Line (Horizontal Scroll) | chartjs-plugin-streaming - nagix
Chart.js plugin for live streaming data.
Read more >Realtime Chart with Zooming and Scrolling (Qt) - ChartDirector
The chart is zoomable and scrollable and include a track cursor like that in the Zooming and Scrolling with Track Line (1) (Qt)...
Read more >How to make in a chart a horizontal scroll when there are ...
Thanks for contacting Syncfusion support. 1. To horizontally scroll in the SfChart you can enable the scroll bar using the below code snippet....
Read more >Add a horizontal scroll bar for real time data plot
Processing Electronics (Arduino, etc.) ... I am plotting a real-time data plot, I need to scroll across the only x-axis to visualize previous...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The chart add a feature that enables it have a sticky Y-axis and a proper scrollable x-axis (without using the current brush implementation).
hey @valentine-dev I don’t think anyone has touched this in a while - recharts hasn’t had anyone working on it in a bit (I’m just a community member who started contributing), but we’re trying to find contributors and get things moving again. Feel free to make a PR if you feel you could create a fix/enhancement for it. For now, we’re focusing on making it easier for people to contribute. Added some labels so this doesn’t get lost