Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set max or min y value #20

Closed
nandorojo opened this issue Oct 27, 2021 · 11 comments · Fixed by #21
Closed

Set max or min y value #20

nandorojo opened this issue Oct 27, 2021 · 11 comments · Fixed by #21

Comments

@nandorojo
Copy link
Contributor

nandorojo commented Oct 27, 2021

I am showing a single day's trading value. For 1d, it's useful to compare to day to tomorrow's close price.

This is what happens for Robinhood vs my app:

Robinhood Wagmi
Screenshot 2021-10-27 at 5 30 54 PM IMG_A55CAE8C3303-1

The HOOD stock went down 10% since yesterday. However, based on the Wagmi chart, there isn't much visual representation of this. Robinhood, on the other hand, makes this pretty clear, by showing a large white gap above the chart.

Is there a way to dynamically set the range for the Y values? I envision something like this:

<LineChart.Path 
  yRange={{ max, min }} // these can both be optional overrides
/>
@nandorojo
Copy link
Contributor Author

@jxom I'm happy to implement this myself, I think I just need some pointers about how to get around the getArea and getPath function. Any shot you have some off-hand suggestions for how to do this?

@jxom
Copy link
Contributor

jxom commented Oct 27, 2021

@nandorojo – yoo!

I think this could be as simple as overriding the domain in getPath and getArea.

@jxom
Copy link
Contributor

jxom commented Oct 27, 2021

I guess the API could look like:

<LineChart.Provider data={data}>
  <LineChart yDomain={{ min, max }}>
    <LineChart.Path />
  <LineChart>
</LineChart.Provider>

@nandorojo
Copy link
Contributor Author

Okay let me try that

@nandorojo
Copy link
Contributor Author

nandorojo commented Oct 28, 2021

Should I call it range instead of domain, since domain typically means X axis?

Update I see that this probably doesn't make sense.

@jxom
Copy link
Contributor

jxom commented Oct 28, 2021

Yeah, it's kinda weird coz d3-scale uses domain interchangeably w/ x & y axis. It seems that d3-scale uses range as a scalar based on the x/y domain.

@jxom
Copy link
Contributor

jxom commented Oct 28, 2021

But if range makes more sense from a high-level DX perspective, I am happy to use that.

@nandorojo
Copy link
Contributor Author

Right...maybe we put yRange as the prop, but use yDomain internally 🧐

@nandorojo
Copy link
Contributor Author

RPReplay_Final1635380567.MP4

This is looking good to me

@nandorojo
Copy link
Contributor Author

I'll push for you to test to make sure I got this right...but I think it's right. I can test it in my app too with real data (hard to know with mock)

@nandorojo
Copy link
Contributor Author

Stuck to yRange, felt a bit clearer. Opened a PR at #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants