|
8 | 8 | import com.github.mikephil.charting.components.YAxis; |
9 | 9 | import com.github.mikephil.charting.data.BarData; |
10 | 10 | import com.github.mikephil.charting.data.BarEntry; |
| 11 | +import com.github.mikephil.charting.formatter.IAxisValueFormatter; |
11 | 12 | import com.github.mikephil.charting.highlight.BarHighlighter; |
12 | 13 | import com.github.mikephil.charting.highlight.Highlight; |
13 | 14 | import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider; |
@@ -278,6 +279,29 @@ public void setRoundedBarRadius(float mRoundedBarRadius) { |
278 | 279 |
|
279 | 280 | @Override |
280 | 281 | public String getAccessibilityDescription() { |
281 | | - return "This is a bar chart"; |
| 282 | + |
| 283 | + BarData barData = getBarData(); |
| 284 | + |
| 285 | + int entryCount = barData.getEntryCount(); |
| 286 | + |
| 287 | + // Find the min and max index |
| 288 | + IAxisValueFormatter yAxisValueFormatter = getAxisLeft().getValueFormatter(); |
| 289 | + String minVal = yAxisValueFormatter.getFormattedValue(barData.getYMin(), null); |
| 290 | + String maxVal = yAxisValueFormatter.getFormattedValue(barData.getYMax(), null); |
| 291 | + |
| 292 | + // Data range... |
| 293 | + IAxisValueFormatter xAxisValueFormatter = getXAxis().getValueFormatter(); |
| 294 | + String minRange = xAxisValueFormatter.getFormattedValue(barData.getXMin(), null); |
| 295 | + String maxRange = xAxisValueFormatter.getFormattedValue(barData.getXMax(), null); |
| 296 | + |
| 297 | + String entries = entryCount == 1 ? "entry" : "entries"; |
| 298 | + |
| 299 | + // Format the values of min and max; to recite them back |
| 300 | + |
| 301 | + String description = String.format("The bar chart has %d %s. " + |
| 302 | + "The minimum value is %s and maximum value is %s", |
| 303 | + entryCount, entries, minVal, maxVal); |
| 304 | + |
| 305 | + return description; |
282 | 306 | } |
283 | 307 | } |
0 commit comments