question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help!, how to create horizontal scrollable realtime chart

See original GitHub issue

Hello, i need to create a horizontal scrollable areachart,

for me what is happening

  1. is the data gets crumbled together and brush component is also not moving.it stays fixed.
  2. 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:open
  • Created 2 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
thareshjosecommented, Aug 22, 2022

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).

0reactions
ckifercommented, Dec 13, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found