forked from upstream-mirrors/OpenTracks
fill the area below a chart curve only when there are at most 2 curves
This makes charts more readable when there are many curves in it. Fixes #1823
This commit is contained in:
committed by
Dennis Guse
parent
1ae18836cb
commit
7ebb629b44
@@ -136,8 +136,10 @@ abstract class ChartValueSeries {
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPath(Canvas canvas) {
|
void drawPath(Canvas canvas, boolean shouldFillPathArea) {
|
||||||
canvas.drawPath(path, fillPaint);
|
if (shouldFillPathArea) {
|
||||||
|
canvas.drawPath(path, fillPaint);
|
||||||
|
}
|
||||||
canvas.drawPath(path, strokePaint);
|
canvas.drawPath(path, strokePaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ public class ChartView extends View {
|
|||||||
private int height = 0;
|
private int height = 0;
|
||||||
private int effectiveWidth = 0;
|
private int effectiveWidth = 0;
|
||||||
private int effectiveHeight = 0;
|
private int effectiveHeight = 0;
|
||||||
|
private TitleDimensions titleDimensions;
|
||||||
|
|
||||||
private boolean chartByDistance = false;
|
private boolean chartByDistance = false;
|
||||||
private UnitSystem unitSystem = UnitSystem.defaultUnitSystem();
|
private UnitSystem unitSystem = UnitSystem.defaultUnitSystem();
|
||||||
@@ -622,7 +623,7 @@ public class ChartView extends View {
|
|||||||
private void drawDataSeries(Canvas canvas) {
|
private void drawDataSeries(Canvas canvas) {
|
||||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||||
if (chartValueSeries.isEnabled() && chartValueSeries.hasData()) {
|
if (chartValueSeries.isEnabled() && chartValueSeries.hasData()) {
|
||||||
chartValueSeries.drawPath(canvas);
|
chartValueSeries.drawPath(canvas, titleDimensions.titlePositions.size() < 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -689,14 +690,13 @@ public class ChartView extends View {
|
|||||||
* @param canvas the canvas
|
* @param canvas the canvas
|
||||||
*/
|
*/
|
||||||
private void drawSeriesTitles(Canvas canvas) {
|
private void drawSeriesTitles(Canvas canvas) {
|
||||||
TitleDimensions td = getTitleDimensions();
|
Iterator<TitlePosition> tpI = titleDimensions.titlePositions.iterator();
|
||||||
Iterator<TitlePosition> tpI = td.titlePositions.iterator();
|
|
||||||
for (ChartValueSeries chartValueSeries : seriesList) {
|
for (ChartValueSeries chartValueSeries : seriesList) {
|
||||||
if (chartValueSeries.isEnabled() && chartValueSeries.hasData() || allowIfEmpty(chartValueSeries)) {
|
if (chartValueSeries.isEnabled() && chartValueSeries.hasData() || allowIfEmpty(chartValueSeries)) {
|
||||||
String title = getContext().getString(chartValueSeries.getTitleId(unitSystem));
|
String title = getContext().getString(chartValueSeries.getTitleId(unitSystem));
|
||||||
Paint paint = chartValueSeries.getTitlePaint();
|
Paint paint = chartValueSeries.getTitlePaint();
|
||||||
TitlePosition tp = tpI.next();
|
TitlePosition tp = tpI.next();
|
||||||
int y = topBorder - spacer - (td.lineCount - tp.line) * (td.lineHeight + spacer);
|
int y = topBorder - spacer - (titleDimensions.lineCount - tp.line) * (titleDimensions.lineHeight + spacer);
|
||||||
canvas.drawText(title, tp.xPos + getScrollX(), y, paint);
|
canvas.drawText(title, tp.xPos + getScrollX(), y, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -957,8 +957,8 @@ public class ChartView extends View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leftBorder = (int) (density * BORDER + markerLength);
|
leftBorder = (int) (density * BORDER + markerLength);
|
||||||
TitleDimensions td = getTitleDimensions();
|
titleDimensions = getTitleDimensions();
|
||||||
topBorder = (int) (density * BORDER + td.lineCount * (td.lineHeight + spacer));
|
topBorder = (int) (density * BORDER + titleDimensions.lineCount * (titleDimensions.lineHeight + spacer));
|
||||||
Rect xAxisLabelRect = getRect(axisPaint, getXAxisLabel());
|
Rect xAxisLabelRect = getRect(axisPaint, getXAxisLabel());
|
||||||
// border + x axis marker + spacer + .5 x axis label
|
// border + x axis marker + spacer + .5 x axis label
|
||||||
bottomBorder = (int) (density * BORDER + getRect(xAxisMarkerPaint, "1").height() + spacer + (xAxisLabelRect.height() / 2));
|
bottomBorder = (int) (density * BORDER + getRect(xAxisMarkerPaint, "1").height() + spacer + (xAxisLabelRect.height() / 2));
|
||||||
|
|||||||
Reference in New Issue
Block a user