mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[android] Use a library maintain to draw charts
Signed-off-by: Jean-Baptiste <jeanbaptiste.charron@outlook.fr>
This commit is contained in:
committed by
jeanbaptisteC
parent
292875c3bd
commit
2ef4eb62ba
@@ -355,7 +355,7 @@ dependencies {
|
|||||||
// Fix for app/organicmaps/util/FileUploadWorker.java:14: error: cannot access ListenableFuture
|
// Fix for app/organicmaps/util/FileUploadWorker.java:14: error: cannot access ListenableFuture
|
||||||
// https://github.com/organicmaps/organicmaps/issues/6106
|
// https://github.com/organicmaps/organicmaps/issues/6106
|
||||||
implementation libs.google.guava
|
implementation libs.google.guava
|
||||||
implementation libs.devnullorthrow.mpandroidchart
|
implementation libs.appdevnext.androidchart
|
||||||
implementation libs.jcip.annotations
|
implementation libs.jcip.annotations
|
||||||
|
|
||||||
// Test Dependencies
|
// Test Dependencies
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.github.mikephil.charting.components.YAxis;
|
|||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
import com.github.mikephil.charting.data.LineDataSet;
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||||
import com.github.mikephil.charting.highlight.Highlight;
|
import com.github.mikephil.charting.highlight.Highlight;
|
||||||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||||
import com.google.android.material.textview.MaterialTextView;
|
import com.google.android.material.textview.MaterialTextView;
|
||||||
@@ -119,7 +119,7 @@ public class ChartController implements OnChartValueSelectedListener
|
|||||||
x.setPosition(XAxis.XAxisPosition.BOTTOM);
|
x.setPosition(XAxis.XAxisPosition.BOTTOM);
|
||||||
x.setAxisLineColor(ThemeUtils.getColor(mContext, androidx.appcompat.R.attr.dividerHorizontal));
|
x.setAxisLineColor(ThemeUtils.getColor(mContext, androidx.appcompat.R.attr.dividerHorizontal));
|
||||||
x.setAxisLineWidth(mContext.getResources().getDimensionPixelSize(R.dimen.divider_height));
|
x.setAxisLineWidth(mContext.getResources().getDimensionPixelSize(R.dimen.divider_height));
|
||||||
ValueFormatter xAxisFormatter = new AxisValueFormatter(mChart);
|
IAxisValueFormatter xAxisFormatter = new AxisValueFormatter(mChart);
|
||||||
x.setValueFormatter(xAxisFormatter);
|
x.setValueFormatter(xAxisFormatter);
|
||||||
|
|
||||||
YAxis y = mChart.getAxisLeft();
|
YAxis y = mChart.getAxisLeft();
|
||||||
|
|||||||
@@ -3,22 +3,23 @@ package app.organicmaps.widget.placepage;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import app.organicmaps.sdk.util.StringUtils;
|
import app.organicmaps.sdk.util.StringUtils;
|
||||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||||
import com.github.mikephil.charting.formatter.DefaultValueFormatter;
|
import androidx.annotation.Nullable;
|
||||||
|
import com.github.mikephil.charting.components.AxisBase;
|
||||||
|
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||||
|
|
||||||
public class AxisValueFormatter extends DefaultValueFormatter
|
public class AxisValueFormatter implements IAxisValueFormatter
|
||||||
{
|
{
|
||||||
private static final int DEF_DIGITS = 1;
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final BarLineChartBase mChart;
|
private final BarLineChartBase mChart;
|
||||||
|
|
||||||
public AxisValueFormatter(@NonNull BarLineChartBase chart)
|
public AxisValueFormatter(@NonNull BarLineChartBase chart)
|
||||||
{
|
{
|
||||||
super(DEF_DIGITS);
|
super();
|
||||||
mChart = chart;
|
mChart = chart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFormattedValue(float value)
|
public String getFormattedValue(float value, @Nullable AxisBase axisBase)
|
||||||
{
|
{
|
||||||
return StringUtils.nativeFormatDistance(value).toString(mChart.getContext());
|
return StringUtils.nativeFormatDistance(value).toString(mChart.getContext());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ androidx-work-runtime = { module = "androidx.work:work-runtime", version = "2.10
|
|||||||
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version = "2.9.2" }
|
androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version = "2.9.2" }
|
||||||
android-material = { module = "com.google.android.material:material", version = "1.12.0" }
|
android-material = { module = "com.google.android.material:material", version = "1.12.0" }
|
||||||
google-guava = { module = "com.google.guava:guava", version = "33.4.8-android" }
|
google-guava = { module = "com.google.guava:guava", version = "33.4.8-android" }
|
||||||
devnullorthrow-mpandroidchart = { module = "com.github.devnullorthrow:MPAndroidChart", version = "3.2.0-alpha" }
|
appdevnext-androidchart = { module = "com.github.AppDevNext:AndroidChart", version = "3.1.0.30" }
|
||||||
jcip-annotations = { module = "net.jcip:jcip-annotations", version = "1.0" }
|
jcip-annotations = { module = "net.jcip:jcip-annotations", version = "1.0" }
|
||||||
androidx-test-junit = { module = "androidx.test.ext:junit", version = "1.2.1" }
|
androidx-test-junit = { module = "androidx.test.ext:junit", version = "1.2.1" }
|
||||||
junit = { module = "junit:junit", version = "4.13.2" }
|
junit = { module = "junit:junit", version = "4.13.2" }
|
||||||
|
|||||||
@@ -220,6 +220,9 @@
|
|||||||
|
|
||||||
<li><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a><br>
|
<li><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a><br>
|
||||||
© 2020 Philipp Jahoda; <a href="#apache2-license" class="license">Apache License</a></li>
|
© 2020 Philipp Jahoda; <a href="#apache2-license" class="license">Apache License</a></li>
|
||||||
|
|
||||||
|
<li><a href="https://github.com/AppDevNext/AndroidChart">AndroidChart</a><br>
|
||||||
|
© 2025 AppDevNext; <a href="#apache2-license" class="license">Apache License</a></li>
|
||||||
|
|
||||||
<li><a href="https://github.com/skarupke/flat_hash_map">Skarupke Hash Tables</a><br>
|
<li><a href="https://github.com/skarupke/flat_hash_map">Skarupke Hash Tables</a><br>
|
||||||
© Malte Skarupke 2017; <a href="#boost-license" class="license">Boost License</a></li>
|
© Malte Skarupke 2017; <a href="#boost-license" class="license">Boost License</a></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user