Skip to content

Commit

Permalink
Show stack label on chart value selected
Browse files Browse the repository at this point in the history
  • Loading branch information
aint committed May 23, 2015
1 parent 8832972 commit 6217b94
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private BarData getData(AccountType accountType) {
array[k] = stack.get(k);
}

values.add(new BarEntry(array, i));
String stackLabels = labels.subList(labels.size() - stack.size(), labels.size()).toString();
values.add(new BarEntry(array, i, stackLabels));

startDate = startDate.plusMonths(1);
}
Expand Down Expand Up @@ -287,6 +288,9 @@ private void setUpSpinner() {
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
mAccountType = (AccountType) ((Spinner) findViewById(R.id.chart_data_spinner)).getSelectedItem();

((TextView) findViewById(R.id.selected_chart_slice)).setText("");
mChart.highlightValues(null);

mChart.setData(getData(mAccountType));

if (!mChartDataPresent) {
Expand Down Expand Up @@ -354,7 +358,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {
if (e == null) return;
BarEntry entry = (BarEntry) e;
String label = mChart.getData().getXVals().get(entry.getXIndex());
String stackLabels = entry.getData().toString();
String label = mChart.getData().getXVals().get(entry.getXIndex()) + ", "
+ stackLabels.substring(1, stackLabels.length() - 1).split(",")[h.getStackIndex()];
double value = entry.getVals()[ h.getStackIndex() == -1 ? 0 : h.getStackIndex() ];
double sum = mTotalPercentageMode ? mChart.getData().getDataSetByIndex(dataSetIndex).getYValueSum() : entry.getVal();
((TextView) findViewById(R.id.selected_chart_slice))
Expand Down

0 comments on commit 6217b94

Please sign in to comment.