use of com.github.mikephil.charting.interfaces.datasets.IPieDataSet in project MPAndroidChart by PhilJay.
the class PieHighlighter method getClosestHighlight.
@Override
protected Highlight getClosestHighlight(int index, float x, float y) {
IPieDataSet set = mChart.getData().getDataSet();
final Entry entry = set.getEntryForIndex(index);
return new Highlight(index, entry.getY(), x, y, 0, set.getAxisDependency());
}
use of com.github.mikephil.charting.interfaces.datasets.IPieDataSet in project MPAndroidChart by PhilJay.
the class PieChart method calcAngles.
/**
* calculates the needed angles for the chart slices
*/
private void calcAngles() {
int entryCount = mData.getEntryCount();
if (mDrawAngles.length != entryCount) {
mDrawAngles = new float[entryCount];
} else {
for (int i = 0; i < entryCount; i++) {
mDrawAngles[i] = 0;
}
}
if (mAbsoluteAngles.length != entryCount) {
mAbsoluteAngles = new float[entryCount];
} else {
for (int i = 0; i < entryCount; i++) {
mAbsoluteAngles[i] = 0;
}
}
float yValueSum = mData.getYValueSum();
List<IPieDataSet> dataSets = mData.getDataSets();
int cnt = 0;
for (int i = 0; i < mData.getDataSetCount(); i++) {
IPieDataSet set = dataSets.get(i);
for (int j = 0; j < set.getEntryCount(); j++) {
mDrawAngles[cnt] = calcAngle(Math.abs(set.getEntryForIndex(j).getY()), yValueSum);
if (cnt == 0) {
mAbsoluteAngles[cnt] = mDrawAngles[cnt];
} else {
mAbsoluteAngles[cnt] = mAbsoluteAngles[cnt - 1] + mDrawAngles[cnt];
}
cnt++;
}
}
}
Aggregations