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

x scale proportional to time. #140

Closed
renatomserra opened this issue Jun 3, 2023 · 20 comments
Closed

x scale proportional to time. #140

renatomserra opened this issue Jun 3, 2023 · 20 comments

Comments

@renatomserra
Copy link

Hellow,

Is there any way to make the distance between two points respect the scale of time between them? Right now points are evenly split across the x axis in the graph

@cam-shaw
Copy link
Contributor

cam-shaw commented Jun 30, 2023

@RenatoSerra22 On line chart yes this is possible by setting the xDomain prop on the LineChart.Provider.
For the xDomain value, provide an array with 2 numbers, the lowest timestamp and highest timestamp in your data.

Let's say I had this data

const dataToShow = [
  { timestamp: 1661904060, value: 1 },
  { timestamp: 1661925060, value: 1.3 },
  { timestamp: 1661926260, value: 2 },
];

and we put it into our provider...

<LineChart.Provider
// other props
data={dataToShow}
 xDomain={[dataToShow[0], dataToShow[dataToShow.length -1]}>
// rest of code
</LineChart.Provider>

It will give you the desired result.

Here is an example (not with the above data) of the difference supplying an xDomain makes.

No xDomain
IMG_0446
Has xDomain
IMG_0447

@renatomserra
Copy link
Author

beautifuuuuuuul thanks so much @cam-shaw !

@rodrigof1307
Copy link

I was about to post this exact same question. This prop of the provider should be on the Component APIs section of the docs

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 1, 2023

I was about to post this exact same question. This prop of the provider should be on the Component APIs section of the docs

You're 100% correct, and this is my bad. When I added the feature in a PR I forgot to update the docs with it. I'll take a look during the week at adding some documentation.

@renatomserra
Copy link
Author

renatomserra commented Jul 4, 2023

@cam-shaw the gradient doesnt seem to respect the domain tho :)

Screenshot 2023-07-04 at 13 18 56

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 4, 2023

Iiinteresting... Had a look and I think I know how to solve the gradient issue.. Looks fairly simple to resolve, the gradient just needs to also respect the xDomain if provided.
No promises yet but give me some time and I'll try this week to have a play and I'll get something up for the maintainers to review.

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

@cam-shaw For some reason I am getting a malformed path data error when putting the xDomain the same as the example that you gave, not sure what I am doing wrong

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

Nevermind I figured it out, the timestamps were formatted differently then the data that was being shown, I did find a weird reaction when putting the xdomain, the dot seems to be hanging off the screen
Simulator Screen Shot - Iphone 14 pro 16 2 - 2023-07-05 at 15 18 54

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 5, 2023

@ChaseK30 If you're able to, would be great if you can give this PR a test. I have fixed up the x position for the dot - would be great to know if it resolves your issues.

#144

Let me know if you have any issues integrating it into your project.

  1. Clone the PR
  2. Change package.json of PR version to 2.3.0-local.0 to avoid any package conflicts
  3. yarn prepare && yarn pack - This will output a path to the terminal similar to success Wrote tarball to "/Users/.../react-native-wagmi-charts-v2.3.0-local.0.tgz
  4. In your personal project, run yarn install pathToTarball

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

checking now!

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

@cam-shaw there are no build commands

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 5, 2023

@ChaseK30 sorry, yarn prepare instead of yarn build. Have updated my comment above.

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

Sorry for the delay running into a ton of dependency issues

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 5, 2023

@ChaseK30 no worries at all. Could be good to document on the PR if the dependency issues are specific to the PR. I'd imagine the maintainers could throw that into the release notes.

Perhaps we can move this conversation there.

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

Screenshot 2023-07-05 at 6 22 17 PM

Gettin a ton of these errors trying to run it at all

@cam-shaw
Copy link
Contributor

cam-shaw commented Jul 5, 2023

@ChaseK30 those are unfortunately/fortunately (depending on how you look at it 😅 ) unrelated to the PR.
Double check your @react/types and react native types are correct for the React version you're using.

Perhaps even go as far as deleting the node_modules directory and installing dependencies again. Bit hard to debug from here unfortunately.

Were you already on react-native-wagmi-charts 2.3.0?

@ChaseK30
Copy link

ChaseK30 commented Jul 5, 2023

in my personal project yes, but i am getting all these errors running a yarn install && yarn prepare && yarn pack before getting it into my personal project
@cam-shaw

@renatomserra
Copy link
Author

just saw the PR thank you @cam-shaw for being so quick with it!

@renatomserra
Copy link
Author

Found another issue :D when dragging over the line, the labels dont show the correct timestamp/value

@cam-shaw
Copy link
Contributor

@RenatoSerra22 are you able to provide some sample data for me to test with? I believe I have fixed this in the PR as well.

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

No branches or pull requests

4 participants