Charts: Add moveViewToEnd()

Created on 24 Nov 2015  路  5Comments  路  Source: danielgindi/Charts

Hello,
I am now faced with a problem. No method, except moveViewTo, allows to move on the X axis to go to the last element not centered on the view.

I want to show the last element like this:

|. ------------- . . o|
Where o is the last element.

How I can do this?
Thanks.

duplicate

All 5 comments

seems duplicated to more generic feature moveViewToX, take a look at #450 and #468, and perhaps you can use ChartTransformer, discussed in #226, though it discusses zoom and scale, but there is some useful APIs to manipulate the matrix so you can display I think.

So, For the next people with this problem, you can resolve this issue like this:

    NSInteger count = [self.lineChartView.data.dataSets[0].yVals count];
    ChartDataEntry *entry = self.lineChartView.data.dataSets[0].yVals[count-1];

    [self.lineChartView centerViewToXIndex:count-1 yValue:entry.value axis:AxisDependencyLeft];

This worked for me.
I think it should be a feature...

Did you write centerViewToXIndex? I don't see it right now. It will be great if you could create a PR for this if you think it's helpful to others.

No, centerViewToXIndex is an instance method of BarLineChartViewBase
I'll will se for the PR.

It does not exists, so you actually write it. You could file a PR if you like to!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kwstasna picture kwstasna  路  3Comments

Bharati555 picture Bharati555  路  4Comments

heumn picture heumn  路  3Comments

kirti0525 picture kirti0525  路  3Comments

PrashantKT picture PrashantKT  路  3Comments