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.

Overlay in a LineChart - get the exact y position when using a double

See original GitHub issue

I’m displaying a LineChart with curve type set to curveMonotoneX inside a ScrollView, I want to animate an overlay when the user is scrolling the ScrollView, I’m calculating the percentage of an item, then I send the double value to the x function.

E.g. index 14 becomes 14.23, when I send it to the x function I get the exact position within the chart.

This works fine, but whenever I send in the double to the y function I get some weird return value, does the y function support doubles?

simulator screen shot - iphone x - 2018-07-02 at 16 05 03

As you can see in the screenshot the overlay is misplaced, for some reason it has the wrong y position, (see the yellow arrow), it should actually be located where the green arrow is pointing.

Here’s the code I’m using

    private readonly Tooltip = ({ x, y }) => {
        const { indexOfActiveDataPoint } = this.state; /* e.g 14.23 */

        const xA = x(indexOfActiveDataPoint) - (75 / 2);
        const yA = y(this.state.data[Math.floor(indexOfActiveDataPoint)].current ? this.state.data[Math.floor(indexOfActiveDataPoint)].current._value : this.state.data[Math.floor(indexOfActiveDataPoint)]);

        console.log(xA, yA);

        return (
            <G
                x={xA}
                key={"tooltip"}
            >
                <G x={75 / 2}>
                    <Circle
                        onPressOut={() => console.log("tooltip clicked")}
                        cy={yA}
                        r={5}
                        strokeWidth={1}
                        fill={"rgba(255,255,255,0.5)"}
                    />
                </G>
            </G>
        );
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
JesperLeklandcommented, Jul 2, 2018

Also in order to correctly troubleshoot I need a complete, small example. This example provides me with very little to go on (code wise). Great screenshot though

0reactions
usrbowecommented, Nov 16, 2019

Closing due:

  • stale
  • no activity
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to overlay the x and y axis on top of line chart using ...
1 Answer 1 ... You can setPosition(YAxisLabelPosition pos): Sets the position where the axis-labels should be drawn. Either INSIDE_CHART or ...
Read more >
A Complete Guide to Area Charts | Tutorial by Chartio
Area charts combine the line chart and bar chart for more specific purposes. Use this guide to learn the best times and ways...
Read more >
Excel Chart: Fill Area under the XY Chart and ... - YouTube
In this tutorial, I have explained how to fill the area under the XY Chart and between XY Chart with simple steps.
Read more >
Shade the Area Between Two Lines - Excel Line Chart
We then tidy up the chart by replacing the Legend with an alternative way of differentiating the two lines. Find more great free...
Read more >
Line chart options | Looker - Google Cloud
Charts with the Series Positioning option set to Grouped or Overlay can have multiple y-axes. Any Stacked or Stacked Percentage charts will have...
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