Jarvis
Jarvis

Reputation: 345

Android graphs: get x axis label on bar chart click

I'm using Chart engine for drawing graphs in my app. Graphs are displaying good, but in onClick of bar chart i need to display the CLICKED bar X AXIS label as toast. so How can i retrieve x axis label? i've tried

SeriesSelection seriesSelection = mChartView.getCurrentSeriesAndPoint();

but here there's nothing related to x axis label..

Upvotes: 1

Views: 1410

Answers (2)

Dan D.
Dan D.

Reputation: 32391

Starting from your piece of code where you obtained a SeriesSelection object, you can then get the closest X axis value using:

double x = seriesSelection.getXValue();

and then in order to get the custom label you can do:

String label = renderer.getXTextLabel(x);

Upvotes: 1

mob_web_dev
mob_web_dev

Reputation: 2362

You can get the answer here How do I draw a graph on Android without using any external API?

Upvotes: 0

Related Questions