react-native-chart-kit icon indicating copy to clipboard operation
react-native-chart-kit copied to clipboard

Line Chart Scroll

Open adamwhiles opened this issue 5 years ago • 18 comments

Is there a way to add a scroll to the line chart and limit the number of data point shown on the initial "page"?

adamwhiles avatar Dec 17 '19 15:12 adamwhiles

There is no scroll, but you can limit data points by passing fewer data points in the props

Hermanya avatar Dec 17 '19 18:12 Hermanya

Thanks... yea, i did that as a workaround. Any future possibility to scroll?

adamwhiles avatar Dec 17 '19 18:12 adamwhiles

Not unless someone submits a PR 😉

Hermanya avatar Dec 17 '19 21:12 Hermanya

Hi there, any updates on that? I would love to have it

azuxx avatar Oct 14 '20 14:10 azuxx

Hi, any update available ? Because I would like to have a longer curve with more data to see a good evolution and not just a rough average.

kdcaine avatar Nov 27 '20 10:11 kdcaine

Its working fine follow this link [https://github.com/indiespirit/react-native-chart-kit/blob/cb2d31e86fe40133cbf2a19f1453571998b8fe57/App.js#L244]

SohaibIbneAli avatar Dec 16 '20 11:12 SohaibIbneAli

Hi, is there a way to spread out the data points and scroll to the last point of the chart? photo6258021737346214722 (1) something like this

I have 100 points and with the current settings i cannot see any labels(they all mashed out). am i missing something? Please help.

lokewk avatar Dec 17 '20 14:12 lokewk

horizontal scroll is really needed for this library

bmitioglov avatar Jan 29 '21 00:01 bmitioglov

Finally figured this out after hours of searching...

suulola avatar Feb 02 '21 13:02 suulola

Finally figured this out after hours of searching...

Did you add horizontal scroll?

bmitioglov avatar Feb 02 '21 18:02 bmitioglov

Yes - my use case is a scrollable horizontal chart

suulola avatar Feb 03 '21 17:02 suulola

Here is my implementation

<ScrollView horizontal={true} contentOffset={{ x: 10000, y: 0 }} // i needed the scrolling to start from the end not the start showsHorizontalScrollIndicator={false} // to hide scroll bar > <LineChart data={data} width={900} height={250} xLabelsOffset={10} chartConfig={chartConfig} withHorizontalLines={false} withVerticalLines={false} withHorizontalLabels={false} withInnerLines={false} withOuterLines={false} style={{ paddingRight: 20, // to remove white spaces at the start of the chart }} bezier /> </ScrollView>

suulola avatar Feb 03 '21 17:02 suulola

Is there a way to get the horizontal scroll bar in line chart with dynamic data

Is there a way to get the horizontal scroll bar in line chart with dynamic data

@SangeethaSridharanOfficial maybe you can use like below image my chart data image

aangindra avatar Oct 31 '21 07:10 aangindra

It would be really nice if we could fix the yAxis and scroll the data dynamically along the x Axis!

guicastrol avatar Feb 24 '22 01:02 guicastrol

Is there any way to keep the yAxis labels visible at all times while scrolling?

MaxMalinsky avatar Jul 21 '22 17:07 MaxMalinsky

have any some update for it? I have to do some trick for it and still wait some update from this lib.

Juman8 avatar Feb 22 '23 04:02 Juman8

Hello! I just come up with an alternate solution where you don't need any PR. No need to update the library. First of all, put your LineChart inside a scroll view like below. If you have large data just increase the width of the chart. You'll be able to scroll. That's it.

<ScrollView horizontal>
            <LineChart
              data={{
                labels: [
                  "January",
                  "February",
                  "March",
                  "April",
                  "May",
                  "June",
                ],
                datasets: [
                  {
                    data: [
                      Math.random() * 100,
                      Math.random() * 100,
                      Math.random() * 100,
                      Math.random() * 100,
                      Math.random() * 100,
                      Math.random() * 100,
                    ],
                  },
                ],
              }}
              width={1000} // from react-native
              height={220}
              //yAxisLabel="$"
              //yAxisSuffix="k"
              //yAxisInterval={1} // optional, defaults to 1
              chartConfig={{
                backgroundColor: "#ffff",
                backgroundGradientFrom: "#ffff",
                backgroundGradientTo: "#ffff",
                decimalPlaces: 2, // optional, defaults to 2dp
                color: (opacity = 1) => `rgba(46, 204, 113  , ${opacity})`,
                labelColor: (opacity = 1) => `rgba(28, 40, 51 , ${opacity})`,
                style: {
                  borderRadius: 16,
                },
                propsForDots: {
                  r: "6",
                  strokeWidth: "2",
                  stroke: "#2ECC71",
                },
              }}
              bezier
              style={{
                marginVertical: 8,
                borderRadius: 16,
              }}
            />
          </ScrollView>

zainulabideen-dev avatar Jul 13 '23 08:07 zainulabideen-dev