mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-14 11:01:06 +01:00
a5ae7acc63
- use just one data set, because multiple data sets is not supported by MPAndroidChart (the way we need it) Now there is hardly any space between the bars anymore Also: - allow scaling x and y axis independently via pinch gesture - set fixed y max value (1.0) so that the display is stable and independent of the actual available data - (at least temporarily) display y labels
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.charts;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import com.github.mikephil.charting.components.Legend;
|
|
import com.github.mikephil.charting.data.ChartData;
|
|
import com.github.mikephil.charting.renderer.LegendRenderer;
|
|
import com.github.mikephil.charting.utils.ViewPortHandler;
|
|
|
|
/**
|
|
* A legend renderer that does *not* calculate the labels and colors automatically
|
|
* from the data sets or the data entries.
|
|
*
|
|
* Instead, they have to be provided manually, because otherwise the legend will
|
|
* be empty.
|
|
*/
|
|
public class CustomLegendRenderer extends LegendRenderer {
|
|
public CustomLegendRenderer(ViewPortHandler viewPortHandler, Legend legend) {
|
|
super(viewPortHandler, legend);
|
|
}
|
|
|
|
@Override
|
|
public void computeLegend(ChartData<?> data) {
|
|
// don't call super to avoid computing colors and labels
|
|
// super.computeLegend(data);
|
|
|
|
Typeface tf = mLegend.getTypeface();
|
|
|
|
if (tf != null)
|
|
mLegendLabelPaint.setTypeface(tf);
|
|
|
|
mLegendLabelPaint.setTextSize(mLegend.getTextSize());
|
|
mLegendLabelPaint.setColor(mLegend.getTextColor());
|
|
|
|
// calculate all dimensions of the mLegend
|
|
mLegend.calculateDimensions(mLegendLabelPaint);
|
|
}
|
|
}
|