jjoe64 / GraphView

Android Graph Library for creating zoomable and scrollable line and bar graphs.
https://github.com/jjoe64/GraphView/wiki
Other
2.76k stars 811 forks source link

"Large" dataset not being displayed #624

Open marosseleng opened 5 years ago

marosseleng commented 5 years ago

I have "large" dataset containing pairs of values, that go like [0;1], [1;2], [2;3], etc, up until [19;20]. I am using ViewModel to load those for me and then, I am observing LiveData. The code I have:

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
    val view = inflater.inflate(R.layout.fragment_measurement_detail, container, false)
    pointsSeries = PointsGraphSeries(
        arrayOf()
    )
    view.findViewById<GraphView>(R.id.graph).addSeries(pointsSeries)
    return view
}

where pointsSeries is a class property, then in onActivityCreated I observe the viewModel:

    viewModel.graphValues.observe(this, Observer {
        // `it` is Pair<Double, Double>, eg. values [0;1], [1;2], ...
        pointsSeries.resetData(it.map { (fst, snd) ->
            DataPoint(fst, snd)
        }.toTypedArray())
    })

When I use the code like this, I get this output: shot1 (as you can see, I have only 9 points plotted).

However, when I fill series in onCreateView (manually with those 20 pairs), all of them are plotted: shot2

I even set viewport's scalable and scrollable to false but nothing worked.

Is this the correct behavior? Am I missing something? GraphView version 4.2.2

Thanks

marosseleng commented 5 years ago

Hello? Anybody here?