diff --git a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java index da4b99bb01..f960221b43 100644 --- a/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/ShowRouteInfoDialogFragment.java @@ -26,6 +26,8 @@ import android.widget.ListView; import android.widget.TextView; import com.github.mikephil.charting.charts.LineChart; +import com.github.mikephil.charting.data.LineData; +import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import net.osmand.Location; import net.osmand.data.PointDescription; @@ -51,6 +53,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED; @@ -222,7 +225,15 @@ public class ShowRouteInfoDialogFragment extends DialogFragment { }); GPXTrackAnalysis analysis = gpx.getAnalysis(0); - GpxUiHelper.setGPXElevationChartData(app, mChart, analysis, false, true); + List dataSets = new ArrayList<>(); + GpxUiHelper.OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, mChart, analysis, false, true); + dataSets.add(elevationDataSet); + if (analysis.elevationData.size() > 1) { + GpxUiHelper.OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, mChart, analysis, true, true); + dataSets.add(slopeDataSet); + } + LineData data = new LineData(dataSets); + mChart.setData(data); ((TextView) headerView.findViewById(R.id.average_text)) .setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app)); diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java index 0a063d15a3..b13c9babf4 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java @@ -1268,12 +1268,12 @@ public class GpxUiHelper { nextXRaw += e.distance; nextYRaw = (float) e.elevation; nextX += (float) e.distance / divX; - if (nextXRaw - prevXRaw > 10) { - nextY = (nextYRaw - prevYRaw) / (nextXRaw - prevXRaw) * 100f; + nextY = (nextYRaw - prevYRaw) / (nextXRaw - prevXRaw) * 100f; + if (nextXRaw - prevXRaw > 50 && Math.abs(nextY) < 120) { values.add(new Entry(nextX, nextY)); - prevXRaw = nextXRaw; - prevYRaw = nextYRaw; } + prevXRaw = nextXRaw; + prevYRaw = nextYRaw; } } } @@ -1304,12 +1304,16 @@ public class GpxUiHelper { dataSet.setDrawHorizontalHighlightIndicator(false); dataSet.setHighLightColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark)); + dataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER); + + /* dataSet.setFillFormatter(new IFillFormatter() { @Override public float getFillLinePosition(ILineDataSet dataSet, LineDataProvider dataProvider) { return dataProvider.getYChartMin(); } }); + */ if (useRightAxis) { dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index af077eea1c..7d4da055cc 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -354,7 +354,7 @@ public class TrackSegmentFragment extends SelectedGPXFragment { OrderedLineDataSet elevationDataSet = GpxUiHelper.createGPXElevationDataSet(app, chart, analysis, false, true); dataSets.add(elevationDataSet); if (analysis.elevationData.size() > 1) { - OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis, true, false); + OrderedLineDataSet slopeDataSet = GpxUiHelper.createGPXSlopeDataSet(app, chart, analysis, true, true); dataSets.add(slopeDataSet); } LineData data = new LineData(dataSets);