use of com.github.mikephil.charting.data.ChartData in project Gadgetbridge by Freeyourgadget.
the class LiveActivityFragment method addEntries.
private void addEntries(int timestamp) {
mTotalStepsChart.setSingleEntryYValue(mSteps.getTotalSteps());
YAxis stepsPerMinuteCurrentYAxis = mStepsPerMinuteCurrentChart.getAxisLeft();
int maxStepsPerMinute = mSteps.getMaxStepsPerMinute();
// int extraRoom = maxStepsPerMinute/5;
// buggy in MPAndroidChart? Disable.
// stepsPerMinuteCurrentYAxis.setAxisMaxValue(Math.max(MIN_STEPS_PER_MINUTE, maxStepsPerMinute + extraRoom));
LimitLine target = new LimitLine(maxStepsPerMinute);
stepsPerMinuteCurrentYAxis.removeAllLimitLines();
stepsPerMinuteCurrentYAxis.addLimitLine(target);
int stepsPerMinute = mSteps.getStepsPerMinute(true);
mStepsPerMinuteCurrentChart.setSingleEntryYValue(stepsPerMinute);
if (!addHistoryDataSet(false)) {
return;
}
ChartData data = mStepsPerMinuteHistoryChart.getData();
if (stepsPerMinute < 0) {
stepsPerMinute = 0;
}
mHistorySet.addEntry(new Entry(timestamp, stepsPerMinute));
int hr = getCurrentHeartRate();
if (hr < 0) {
hr = 0;
}
mHeartRateSet.addEntry(new Entry(timestamp, hr));
}
use of com.github.mikephil.charting.data.ChartData in project MPAndroidChart by PhilJay.
the class CombinedChartRenderer method drawHighlighted.
@Override
public void drawHighlighted(Canvas c, Highlight[] indices) {
Chart chart = mChart.get();
if (chart == null)
return;
for (DataRenderer renderer : mRenderers) {
ChartData data = null;
if (renderer instanceof BarChartRenderer)
data = ((BarChartRenderer) renderer).mChart.getBarData();
else if (renderer instanceof LineChartRenderer)
data = ((LineChartRenderer) renderer).mChart.getLineData();
else if (renderer instanceof CandleStickChartRenderer)
data = ((CandleStickChartRenderer) renderer).mChart.getCandleData();
else if (renderer instanceof ScatterChartRenderer)
data = ((ScatterChartRenderer) renderer).mChart.getScatterData();
else if (renderer instanceof BubbleChartRenderer)
data = ((BubbleChartRenderer) renderer).mChart.getBubbleData();
int dataIndex = data == null ? -1 : ((CombinedData) chart.getData()).getAllData().indexOf(data);
mHighlightBuffer.clear();
for (Highlight h : indices) {
if (h.getDataIndex() == dataIndex || h.getDataIndex() == -1)
mHighlightBuffer.add(h);
}
renderer.drawHighlighted(c, mHighlightBuffer.toArray(new Highlight[mHighlightBuffer.size()]));
}
}
use of com.github.mikephil.charting.data.ChartData in project MPAndroidChart by PhilJay.
the class CombinedHighlighter method getHighlightsAtXValue.
@Override
protected List<Highlight> getHighlightsAtXValue(float xVal, float x, float y) {
mHighlightBuffer.clear();
List<BarLineScatterCandleBubbleData> dataObjects = mChart.getCombinedData().getAllData();
for (int i = 0; i < dataObjects.size(); i++) {
ChartData dataObject = dataObjects.get(i);
// in case of BarData, let the BarHighlighter take over
if (barHighlighter != null && dataObject instanceof BarData) {
Highlight high = barHighlighter.getHighlight(x, y);
if (high != null) {
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
} else {
for (int j = 0, dataSetCount = dataObject.getDataSetCount(); j < dataSetCount; j++) {
IDataSet dataSet = dataObjects.get(i).getDataSetByIndex(j);
// don't include datasets that cannot be highlighted
if (!dataSet.isHighlightEnabled())
continue;
List<Highlight> highs = buildHighlights(dataSet, j, xVal, DataSet.Rounding.CLOSEST);
for (Highlight high : highs) {
high.setDataIndex(i);
mHighlightBuffer.add(high);
}
}
}
}
return mHighlightBuffer;
}
Aggregations