Skip to content

Commit 25ece15

Browse files
committed
fix: elevation chart fixes
1 parent 3f772e7 commit 25ece15

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

app/components/chart/ElevationChart.svelte

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import { getMapContext } from '~/mapModules/MapModule';
2222
import type { AscentSegment, IItem as Item } from '~/models/Item';
2323
import { showError } from '@shared/utils/showError';
24-
import { colors, fonts } from '~/variables';
24+
import { colors, fontScale, fonts } from '~/variables';
2525
import { SDK_VERSION } from '@akylas/nativescript/utils';
2626
let { colorOnPrimary, colorOnSurface, colorOutline, colorOutlineVariant, colorPrimary } = $colors;
2727
$: ({ colorOnPrimary, colorOnSurface, colorOutline, colorOutlineVariant, colorPrimary } = $colors);
@@ -384,7 +384,7 @@
384384
chartView.resetZoom();
385385
}
386386
const deltaA = profile.max[1] - profile.min[1];
387-
const spaceMin = 50;
387+
const spaceMin = 100;
388388
let spaceMax = 0;
389389
const chartElevationMinRange = ApplicationSettings.getNumber('chart_elevation_min_range', 250);
390390
if (deltaA < chartElevationMinRange) {
@@ -398,14 +398,14 @@
398398
leftAxis.labelCount = labelCount;
399399
leftAxis.spaceMin = spaceMin;
400400
leftAxis.spaceMax = spaceMax;
401-
leftAxis.textSize = 9;
401+
leftAxis.textSize = 9 * $fontScale;
402402
403403
const totalDistance = it.route.totalDistance;
404404
const xLabelCount = 6;
405405
xinterval = closestUpper(xintervals, totalDistance / xLabelCount / 1000) * 1000;
406406
xAxis.forcedInterval = xinterval;
407407
xAxis.labelCount = xLabelCount;
408-
xAxis.textSize = 9;
408+
xAxis.textSize = 9 * $fontScale;
409409
xAxis.clipLimitLinesToContent = false;
410410
const chartData = chartView.data;
411411
let set: LineDataSet;
@@ -460,7 +460,7 @@
460460
limitLine.enableDashedLine(4, 3, 0);
461461
limitLine.lineWidth = 0.5;
462462
limitLine.yOffset = -1;
463-
limitLine.textSize = 9;
463+
limitLine.textSize = 9 * $fontScale;
464464
limitLine.textColor = colorOnSurface;
465465
// limitLine.ensureVisible = true;
466466
limitLine.labelPosition = LimitLabelPosition.RIGHT_BOTTOM;
@@ -471,27 +471,26 @@
471471
limitLine.enableDashedLine(4, 3, 0);
472472
limitLine.lineWidth = 0.5;
473473
limitLine.yOffset = 1;
474-
limitLine.textSize = 9;
474+
limitLine.textSize = 9 * $fontScale;
475475
limitLine.textColor = colorOnSurface;
476476
limitLine.ensureVisible = true;
477477
leftAxis.addLimitLine(limitLine);
478478
479479
xAxis.removeAllLimitLines();
480-
if (showAscents) {
480+
if (showAscents && profile.ascents) {
481481
profile.ascents.forEach((ascent: AscentSegment) => {
482482
const text = convertElevation(ascent.highestElevation) + '\n+' + convertElevation(ascent.gain);
483-
484483
limitLine = new LimitLine(profileData[ascent.highestPointIndex].d, text);
485484
limitLine.lineColor = colorOutline;
486485
limitLine.enableDashedLine(6, 3, 0);
487486
limitLine.lineWidth = 0.5;
488-
limitLine.textSize = 7;
487+
limitLine.textSize = 7 * $fontScale;
489488
limitLine.xOffset = 0;
490489
limitLine.textColor = colorOnSurface;
491490
limitLine.ensureVisible = true;
492491
limitLine.drawLabel = (c: Canvas, label: string, x: number, y: number, paint: Paint) => {
493492
c.drawCircle(x + 5, y - 6, 6, waypointsBackPaint);
494-
waypointsPaint.textSize = 7;
493+
waypointsPaint.textSize = 7 * $fontScale;
495494
c.drawText('', x + 5, y - 5 + 1, waypointsPaint);
496495
// paint.setTextAlign(Align.CENTER);
497496
const staticLayout = new StaticLayout(label, paint, c.getWidth(), LayoutAlignment.ALIGN_NORMAL, 1, 0, true);
@@ -503,8 +502,7 @@
503502
xAxis.addLimitLine(limitLine);
504503
});
505504
}
506-
if (showWaypoints) {
507-
const positions = packageService.getRouteItemPoses(it);
505+
if (showWaypoints && it.route.waypoints) {
508506
it.route.waypoints.forEach((p) => {
509507
if (p.properties.showOnMap && p.properties.index > 0) {
510508
limitLine = new LimitLine(profileData[p.properties.index].d, ' ');
@@ -514,7 +512,7 @@
514512
limitLine.ensureVisible = true;
515513
limitLine.drawLabel = (c: Canvas, label: string, x: number, y: number, paint: Paint) => {
516514
c.drawCircle(x - 5, y + 0, 6, waypointsBackPaint);
517-
waypointsPaint.textSize = 8;
515+
waypointsPaint.textSize = 8 * $fontScale;
518516
c.drawText('', x - 5, y + 4 - 1, waypointsPaint);
519517
};
520518
xAxis.addLimitLine(limitLine);

0 commit comments

Comments
 (0)