mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
add time to chart tooltip
This commit is contained in:
@@ -1,13 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as ToggleGroup from '$lib/components/ui/toggle-group';
|
import * as ToggleGroup from '$lib/components/ui/toggle-group';
|
||||||
import Tooltip from '$lib/components/Tooltip.svelte';
|
import Tooltip from '$lib/components/Tooltip.svelte';
|
||||||
|
|
||||||
import Chart from 'chart.js/auto';
|
import Chart from 'chart.js/auto';
|
||||||
import mapboxgl from 'mapbox-gl';
|
import mapboxgl from 'mapbox-gl';
|
||||||
|
|
||||||
import { map, gpxStatistics, slicedGPXStatistics } from '$lib/stores';
|
import { map, gpxStatistics, slicedGPXStatistics } from '$lib/stores';
|
||||||
import { settings } from '$lib/db';
|
import { settings } from '$lib/db';
|
||||||
|
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy, onMount } from 'svelte';
|
||||||
import {
|
import {
|
||||||
BrickWall,
|
BrickWall,
|
||||||
@@ -19,8 +16,7 @@
|
|||||||
Zap
|
Zap
|
||||||
} from 'lucide-svelte';
|
} from 'lucide-svelte';
|
||||||
import { surfaceColors } from '$lib/assets/surfaces';
|
import { surfaceColors } from '$lib/assets/surfaces';
|
||||||
|
import { _, locale } from 'svelte-i18n';
|
||||||
import { _ } from 'svelte-i18n';
|
|
||||||
import {
|
import {
|
||||||
getCadenceUnits,
|
getCadenceUnits,
|
||||||
getCadenceWithUnits,
|
getCadenceWithUnits,
|
||||||
@@ -42,6 +38,12 @@
|
|||||||
secondsToHHMMSS
|
secondsToHHMMSS
|
||||||
} from '$lib/units';
|
} from '$lib/units';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
|
import { DateFormatter } from '@internationalized/date';
|
||||||
|
|
||||||
|
const df = new DateFormatter($locale ?? 'en', {
|
||||||
|
dateStyle: 'medium',
|
||||||
|
timeStyle: 'medium'
|
||||||
|
});
|
||||||
|
|
||||||
let canvas: HTMLCanvasElement;
|
let canvas: HTMLCanvasElement;
|
||||||
let overlay: HTMLCanvasElement;
|
let overlay: HTMLCanvasElement;
|
||||||
@@ -143,11 +145,22 @@
|
|||||||
};
|
};
|
||||||
let surface = point.surface ? point.surface : 'unknown';
|
let surface = point.surface ? point.surface : 'unknown';
|
||||||
|
|
||||||
return [
|
let labels = [
|
||||||
` ${$_('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
|
` ${$_('quantities.distance')}: ${getDistanceWithUnits(point.x, false)}`,
|
||||||
` ${$_('quantities.slope')}: ${slope.at} %${elevationFill === 'slope' ? ` (${slope.length} @${slope.segment} %)` : ''}`,
|
` ${$_('quantities.slope')}: ${slope.at} %${elevationFill === 'slope' ? ` (${slope.length} @${slope.segment} %)` : ''}`
|
||||||
` ${$_('quantities.surface')}: ${$_(`toolbar.routing.surface.${surface}`)}`
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (elevationFill === 'surface') {
|
||||||
|
labels.push(
|
||||||
|
` ${$_('quantities.surface')}: ${$_(`toolbar.routing.surface.${surface}`)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (point.time) {
|
||||||
|
labels.push(` ${$_('quantities.time')}: ${df.format(point.time)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return labels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,6 +340,7 @@
|
|||||||
return {
|
return {
|
||||||
x: getConvertedDistance(data.local.distance.total[index]),
|
x: getConvertedDistance(data.local.distance.total[index]),
|
||||||
y: point.ele ? getConvertedElevation(point.ele) : 0,
|
y: point.ele ? getConvertedElevation(point.ele) : 0,
|
||||||
|
time: point.time,
|
||||||
slope: {
|
slope: {
|
||||||
at: data.local.slope.at[index],
|
at: data.local.slope.at[index],
|
||||||
segment: data.local.slope.segment[index],
|
segment: data.local.slope.segment[index],
|
||||||
|
Reference in New Issue
Block a user