margelo / react-native-graph

📈 Beautiful, high-performance Graphs and Charts for React Native built with Skia
https://margelo.io
MIT License
2.04k stars 115 forks source link

Readme is not clear #64

Open ismailonur opened 1 year ago

ismailonur commented 1 year ago

1-) Where does usePriceHistory come from? 2-) Is priceHistory an array or an object? What value should it contain? Thank you

Wilmela commented 1 year ago

Same here.

shawnob2123 commented 1 year ago

Agreed. Show imports and possibly a better use case

hiphilli commented 1 year ago

Unsure how to use priceHistory too. Very unclear in the docs.

papidb commented 1 year ago

Hey @Montchy can I pick this up?

IAmCoder commented 6 months ago

I found some examples here: https://github.com/margelo/react-native-graph/blob/main/example/src/data/GraphData.ts

function weightedRandom(mean: number, variance: number): number {
  var distribution = gaussian(mean, variance)
  // Take a random sample using inverse transform sampling method.
  return distribution.ppf(Math.random())
}

export function generateRandomGraphData(length: number): GraphPoint[] {
  return Array<number>(length)
    .fill(0)
    .map((_, index) => ({
      date: new Date(
        new Date(2000, 0, 1).getTime() + 1000 * 60 * 60 * 24 * index
      ),
      value: weightedRandom(10, Math.pow(index + 1, 2)),
    }))
}

export function generateSinusGraphData(length: number): GraphPoint[] {
  return Array<number>(length)
    .fill(0)
    .map((_, index) => ({
      date: new Date(index),
      value: Math.sin(index),
    }))
}