This commit is contained in:
Vincent van der Wal
2026-07-19 14:57:26 +02:00
parent 9e1944396e
commit 6d81af8df5
26 changed files with 408 additions and 466 deletions
+6 -4
View File
@@ -16,7 +16,9 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte';
import * as echarts from 'echarts';
import { echarts } from './echarts';
import type { ECharts } from 'echarts';
// ─── Props ──────────────────────────────────────────────────────────────────
@@ -36,7 +38,7 @@
/** Optional CSS class for the outer container */
class?: string;
/** Callback fired once the chart instance is initialized */
onChartReady?: (chart: echarts.ECharts) => void;
onChartReady?: (chart: ECharts) => void;
/** Callback fired when the chart is disposed */
onChartDisposed?: () => void;
}
@@ -56,7 +58,7 @@
// ─── Internal State ─────────────────────────────────────────────────────────
let containerEl: HTMLDivElement;
let chartInstance: echarts.ECharts | null = null;
let chartInstance: ECharts | null = null;
let resizeObserver: ResizeObserver | null = null;
// ─── Public API ─────────────────────────────────────────────────────────────
@@ -64,7 +66,7 @@
/**
* Returns the underlying ECharts instance, or null if not yet initialized.
*/
export function getChart(): echarts.ECharts | null {
export function getChart(): ECharts | null {
return chartInstance;
}
+34
View File
@@ -0,0 +1,34 @@
// Tree-shaken ECharts build: only the pieces the app actually renders (line
// and bar series with grid/tooltip/legend/dataZoom/mark/graphic features) are
// registered, instead of the ~1 MB full bundle.
import { BarChart, LineChart } from 'echarts/charts';
import {
DataZoomInsideComponent,
DataZoomSliderComponent,
GraphicComponent,
GridComponent,
LegendComponent,
MarkAreaComponent,
MarkLineComponent,
TitleComponent,
TooltipComponent
} from 'echarts/components';
import * as echarts from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
echarts.use([
LineChart,
BarChart,
GridComponent,
TooltipComponent,
LegendComponent,
TitleComponent,
DataZoomInsideComponent,
DataZoomSliderComponent,
MarkLineComponent,
MarkAreaComponent,
GraphicComponent,
CanvasRenderer
]);
export { echarts };
@@ -64,17 +64,19 @@
return {
results: [
{
id: 100000000 + Math.floor(latitude * 100 + longitude + 1000),
// coordinate-only location: id 0 + COORD makes
// buildLocationRoute emit a "52.52N13.41E" route
id: 0,
name: `GPS ${latitude.toFixed(2)}°N ${longitude.toFixed(2)}°E`,
latitude: latitude,
longitude: longitude,
elevation: position.coords.altitude ?? NaN,
feature_code: '',
elevation: position.coords.altitude ?? 0,
feature_code: 'COORD',
country_code: undefined,
admin1_id: undefined,
admin3_id: undefined,
admin4_id: undefined,
timezone: '',
timezone: 'UTC',
population: undefined,
postcodes: undefined,
country_id: undefined,