@keneth80/k-chart 1.26.0 → 1.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +7 -2
- package/examples/stackblitz-calendar-heatmap-basic/index.html +37 -0
- package/examples/stackblitz-calendar-heatmap-basic/package-lock.json +1548 -0
- package/examples/stackblitz-calendar-heatmap-basic/package.json +18 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/main.ts +172 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/style.css +33 -0
- package/examples/stackblitz-calendar-heatmap-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-dual-axis-combo-basic/index.html +27 -0
- package/examples/stackblitz-dual-axis-combo-basic/package-lock.json +1548 -0
- package/examples/stackblitz-dual-axis-combo-basic/package.json +18 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/main.ts +88 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/style.css +31 -0
- package/examples/stackblitz-dual-axis-combo-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-hybrid-operations-dashboard/index.html +53 -0
- package/examples/stackblitz-hybrid-operations-dashboard/package-lock.json +1548 -0
- package/examples/stackblitz-hybrid-operations-dashboard/package.json +18 -0
- package/examples/stackblitz-hybrid-operations-dashboard/src/main.ts +181 -0
- package/examples/stackblitz-hybrid-operations-dashboard/src/style.css +52 -0
- package/examples/stackblitz-pareto-basic/index.html +22 -0
- package/examples/stackblitz-pareto-basic/package-lock.json +1548 -0
- package/examples/stackblitz-pareto-basic/package.json +18 -0
- package/examples/stackblitz-pareto-basic/src/main.ts +101 -0
- package/examples/stackblitz-pareto-basic/src/style.css +31 -0
- package/examples/stackblitz-pareto-basic/src/vite-env.d.ts +1 -0
- package/examples/stackblitz-us-transport-route/index.html +29 -0
- package/examples/stackblitz-us-transport-route/package.json +17 -0
- package/examples/stackblitz-us-transport-route/src/main.ts +211 -0
- package/examples/stackblitz-us-transport-route/src/style.css +178 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kchart-stackblitz-pareto-basic",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"build": "tsc --noEmit && vite build",
|
|
9
|
+
"preview": "vite preview --host 0.0.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@keneth80/k-chart": "^1.26.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "^6.0.3",
|
|
16
|
+
"vite": "^7.2.7"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGroupedColumnSeries,
|
|
3
|
+
createGuideLineOption,
|
|
4
|
+
createKChart,
|
|
5
|
+
createLineSeries
|
|
6
|
+
} from '@keneth80/k-chart';
|
|
7
|
+
import './style.css';
|
|
8
|
+
|
|
9
|
+
interface IncidentPoint {
|
|
10
|
+
category: string;
|
|
11
|
+
incidents: number;
|
|
12
|
+
cumulative: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const rankedIncidents = [
|
|
16
|
+
{category: 'Late scans', incidents: 94},
|
|
17
|
+
{category: 'Label errors', incidents: 67},
|
|
18
|
+
{category: 'Count variance', incidents: 48},
|
|
19
|
+
{category: 'Routing', incidents: 35},
|
|
20
|
+
{category: 'Packaging', incidents: 24},
|
|
21
|
+
{category: 'Cold chain', incidents: 16},
|
|
22
|
+
{category: 'Other', incidents: 11}
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const total = rankedIncidents.reduce((sum, item) => sum + item.incidents, 0);
|
|
26
|
+
let runningTotal = 0;
|
|
27
|
+
const data: IncidentPoint[] = rankedIncidents.map((item) => {
|
|
28
|
+
runningTotal += item.incidents;
|
|
29
|
+
return {...item, cumulative: Number(((runningTotal / total) * 100).toFixed(1))};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const chart = createKChart<IncidentPoint>({
|
|
33
|
+
selector: '#chart',
|
|
34
|
+
data,
|
|
35
|
+
height: 480,
|
|
36
|
+
margin: {top: 90, right: 78, bottom: 68, left: 70},
|
|
37
|
+
title: {text: total + ' incidents reviewed', align: 'left', fontSize: 17},
|
|
38
|
+
grid: {visible: true, x: false, y: true, color: '#d9ddd8', dasharray: '2 6'},
|
|
39
|
+
legend: {visible: true, placement: 'top', selectable: false, itemGap: 18},
|
|
40
|
+
tooltip: {
|
|
41
|
+
visible: true,
|
|
42
|
+
formatter: ({data: point, series, color}) => {
|
|
43
|
+
const value = series.yField === 'cumulative'
|
|
44
|
+
? point.cumulative.toFixed(1) + '%'
|
|
45
|
+
: point.incidents + ' incidents';
|
|
46
|
+
return '<strong style="color:' + color + '">' + series.displayName + '</strong>' +
|
|
47
|
+
'<div>' + point.category + ': ' + value + '</div>';
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
options: [
|
|
51
|
+
createGuideLineOption({
|
|
52
|
+
y: [{
|
|
53
|
+
value: 80,
|
|
54
|
+
color: '#c3483e',
|
|
55
|
+
width: 1.5,
|
|
56
|
+
dasharray: '6 5',
|
|
57
|
+
}]
|
|
58
|
+
})
|
|
59
|
+
],
|
|
60
|
+
axes: [
|
|
61
|
+
{field: 'category', type: 'string', placement: 'bottom', title: 'Incident category', tickCount: 7},
|
|
62
|
+
{
|
|
63
|
+
field: 'cumulative', type: 'number', placement: 'right', min: 0, max: 100,
|
|
64
|
+
title: 'Cumulative share', tickCount: 5,
|
|
65
|
+
tickFormat: (value) => Number(value).toFixed(0) + '%'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
field: 'incidents', type: 'number', placement: 'left', min: 0, max: 110,
|
|
69
|
+
title: 'Incident count', tickCount: 6,
|
|
70
|
+
tickFormat: (value) => Number(value).toFixed(0)
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
series: [
|
|
74
|
+
createGroupedColumnSeries<IncidentPoint>({
|
|
75
|
+
selector: 'incident-count',
|
|
76
|
+
displayName: 'Incidents',
|
|
77
|
+
xField: 'category',
|
|
78
|
+
segments: [{field: 'incidents', label: 'Incidents', color: '#26766a'}],
|
|
79
|
+
groupWidthRatio: 0.62,
|
|
80
|
+
opacity: 0.95,
|
|
81
|
+
radius: 3
|
|
82
|
+
}),
|
|
83
|
+
createLineSeries<IncidentPoint>({
|
|
84
|
+
selector: 'cumulative-share',
|
|
85
|
+
displayName: 'Cumulative share',
|
|
86
|
+
xField: 'category',
|
|
87
|
+
yField: 'cumulative',
|
|
88
|
+
color: '#d06136',
|
|
89
|
+
strokeWidth: 3,
|
|
90
|
+
curve: false,
|
|
91
|
+
dot: {radius: 4, fill: '#d06136', stroke: '#ffffff'}
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
}).render();
|
|
95
|
+
|
|
96
|
+
const chartElement = document.querySelector<HTMLElement>('#chart');
|
|
97
|
+
if (chartElement) {
|
|
98
|
+
new ResizeObserver(() => chart.resize()).observe(chartElement);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
window.addEventListener('beforeunload', () => chart.destroy());
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
3
|
+
color: #1d2826;
|
|
4
|
+
background: #f4f6f3;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
* { box-sizing: border-box; }
|
|
8
|
+
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f3; }
|
|
9
|
+
.quality-shell { width: min(1120px, calc(100vw - 32px)); margin: 0 auto; padding: 34px 0; }
|
|
10
|
+
.quality-header { max-width: 760px; margin-bottom: 20px; }
|
|
11
|
+
.eyebrow { margin: 0 0 7px; color: #26766a; font-size: 12px; font-weight: 800; text-transform: uppercase; }
|
|
12
|
+
h1 { margin: 0; font-size: 34px; line-height: 1.12; }
|
|
13
|
+
.quality-header p:last-child { margin: 10px 0 0; color: #5d6966; line-height: 1.55; }
|
|
14
|
+
.chart-panel { min-height: 520px; padding: 20px; overflow: hidden; border: 1px solid #d5dbd5; border-radius: 8px; background: #ffffff; box-shadow: 0 16px 40px rgba(38, 62, 57, 0.08); }
|
|
15
|
+
.threshold-key { display: flex; align-items: center; justify-content: flex-end; gap: 7px; min-height: 20px; color: #71413c; font-size: 11px; font-weight: 800; }
|
|
16
|
+
.threshold-key i { width: 24px; border-top: 2px dashed #c3483e; }
|
|
17
|
+
#chart { width: 100%; height: 480px; }
|
|
18
|
+
#chart .kchart-svg text { font-family: inherit; }
|
|
19
|
+
#chart .domain, #chart .tick line { stroke: #a7b1ae; }
|
|
20
|
+
#chart .tick text, #chart .kchart-axis-title { fill: #51605c !important; }
|
|
21
|
+
#chart .kchart-title { fill: #1d2826 !important; }
|
|
22
|
+
#chart .kchart-legend text { fill: #344540 !important; }
|
|
23
|
+
|
|
24
|
+
@media (max-width: 640px) {
|
|
25
|
+
.quality-shell { width: calc(100vw - 20px); padding: 22px 0; }
|
|
26
|
+
h1 { font-size: 28px; }
|
|
27
|
+
.chart-panel { min-height: 504px; padding: 8px; }
|
|
28
|
+
.threshold-key { justify-content: flex-start; padding-left: 4px; }
|
|
29
|
+
#chart { height: 480px; }
|
|
30
|
+
#chart .kchart-axis-bottom .tick:nth-of-type(even) text { display: none; }
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>KChart US Transport Route</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<main class="route-lab is-route-animating">
|
|
10
|
+
<div id="map" class="route-map"></div>
|
|
11
|
+
<svg id="route-overlay" class="route-overlay" aria-label="Seattle to New York multimodal route"></svg>
|
|
12
|
+
|
|
13
|
+
<header class="route-toolbar">
|
|
14
|
+
<div>
|
|
15
|
+
<strong>US multimodal corridor</strong>
|
|
16
|
+
<span>Seattle to New York</span>
|
|
17
|
+
</div>
|
|
18
|
+
<button id="animation-toggle" type="button" aria-pressed="true">
|
|
19
|
+
<i aria-hidden="true">II</i>
|
|
20
|
+
Route animation
|
|
21
|
+
</button>
|
|
22
|
+
</header>
|
|
23
|
+
|
|
24
|
+
<aside id="route-legend" class="route-legend" aria-label="Transport route legend"></aside>
|
|
25
|
+
<div id="route-callout" class="route-callout" aria-live="polite"></div>
|
|
26
|
+
</main>
|
|
27
|
+
<script type="module" src="/src/main.ts"></script>
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kchart-us-transport-route",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview --host 0.0.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"maplibre-gl": "^5.24.0",
|
|
13
|
+
"typescript": "^6.0.3",
|
|
14
|
+
"vite": "^7.1.12"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {}
|
|
17
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import maplibregl, { type Map } from "maplibre-gl";
|
|
2
|
+
import "maplibre-gl/dist/maplibre-gl.css";
|
|
3
|
+
import "./style.css";
|
|
4
|
+
|
|
5
|
+
type Stop = {
|
|
6
|
+
id: string;
|
|
7
|
+
order: number;
|
|
8
|
+
name: string;
|
|
9
|
+
coordinates: [number, number];
|
|
10
|
+
role: "start" | "waypoint" | "transfer" | "arrival";
|
|
11
|
+
detail: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type Route = {
|
|
15
|
+
id: string;
|
|
16
|
+
mode: "sea" | "road" | "rail" | "air";
|
|
17
|
+
label: string;
|
|
18
|
+
color: string;
|
|
19
|
+
badge: string;
|
|
20
|
+
points: [number, number][];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const stops: Stop[] = [
|
|
24
|
+
{ id: "seattle", order: 1, name: "Seattle", coordinates: [-122.3321, 47.6062], role: "start", detail: "Pacific origin terminal" },
|
|
25
|
+
{ id: "san-francisco", order: 2, name: "San Francisco", coordinates: [-122.4194, 37.7749], role: "waypoint", detail: "Sea-to-road transfer" },
|
|
26
|
+
{ id: "denver", order: 3, name: "Denver", coordinates: [-104.9903, 39.7392], role: "transfer", detail: "Road-to-rail transfer" },
|
|
27
|
+
{ id: "chicago", order: 4, name: "Chicago", coordinates: [-87.6298, 41.8781], role: "transfer", detail: "Rail-to-air transfer" },
|
|
28
|
+
{ id: "new-york", order: 5, name: "New York", coordinates: [-74.006, 40.7128], role: "arrival", detail: "East Coast destination" }
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const routes: Route[] = [
|
|
32
|
+
{
|
|
33
|
+
id: "pacific-sea",
|
|
34
|
+
mode: "sea",
|
|
35
|
+
label: "Coastal shipping",
|
|
36
|
+
color: "#22d3ee",
|
|
37
|
+
badge: "SEA",
|
|
38
|
+
points: [[-122.3321, 47.6062], [-125.1, 44.8], [-124.7, 41.3], [-122.4194, 37.7749]]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "western-road",
|
|
42
|
+
mode: "road",
|
|
43
|
+
label: "Interstate road",
|
|
44
|
+
color: "#f59e0b",
|
|
45
|
+
badge: "ROAD",
|
|
46
|
+
points: [[-122.4194, 37.7749], [-118.8, 38.8], [-113.5, 40.2], [-109.2, 39.5], [-104.9903, 39.7392]]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "central-rail",
|
|
50
|
+
mode: "rail",
|
|
51
|
+
label: "Freight rail",
|
|
52
|
+
color: "#34d399",
|
|
53
|
+
badge: "RAIL",
|
|
54
|
+
points: [[-104.9903, 39.7392], [-100.4, 40.1], [-95.9, 41.2], [-91.5, 41.5], [-87.6298, 41.8781]]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "eastern-air",
|
|
58
|
+
mode: "air",
|
|
59
|
+
label: "Express air",
|
|
60
|
+
color: "#a78bfa",
|
|
61
|
+
badge: "AIR",
|
|
62
|
+
points: [[-87.6298, 41.8781], [-74.006, 40.7128]]
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
const stopColors: Record<Stop["role"], string> = {
|
|
67
|
+
start: "#22c55e",
|
|
68
|
+
waypoint: "#38bdf8",
|
|
69
|
+
transfer: "#f59e0b",
|
|
70
|
+
arrival: "#fb7185"
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const lab = document.querySelector<HTMLElement>(".route-lab");
|
|
74
|
+
const mapContainer = document.querySelector<HTMLElement>("#map");
|
|
75
|
+
const overlay = document.querySelector<SVGSVGElement>("#route-overlay");
|
|
76
|
+
const legend = document.querySelector<HTMLElement>("#route-legend");
|
|
77
|
+
const callout = document.querySelector<HTMLElement>("#route-callout");
|
|
78
|
+
const animationToggle = document.querySelector<HTMLButtonElement>("#animation-toggle");
|
|
79
|
+
|
|
80
|
+
if (!lab || !mapContainer || !overlay || !legend || !callout || !animationToggle) {
|
|
81
|
+
throw new Error("The route example container is incomplete.");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const svgNode = <K extends keyof SVGElementTagNameMap>(name: K): SVGElementTagNameMap[K] =>
|
|
85
|
+
document.createElementNS("http://www.w3.org/2000/svg", name);
|
|
86
|
+
|
|
87
|
+
const projectPath = (map: Map, route: Route): string => {
|
|
88
|
+
const projected = route.points.map((coordinates) => map.project(coordinates));
|
|
89
|
+
if (route.mode === "air") {
|
|
90
|
+
const [start, end] = projected;
|
|
91
|
+
const lift = Math.min(72, Math.abs(end.x - start.x) * 0.14);
|
|
92
|
+
return `M ${start.x} ${start.y} Q ${(start.x + end.x) / 2} ${Math.min(start.y, end.y) - lift} ${end.x} ${end.y}`;
|
|
93
|
+
}
|
|
94
|
+
return projected.map((point, index) => `${index ? "L" : "M"} ${point.x} ${point.y}`).join(" ");
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const showStop = (stop: Stop) => {
|
|
98
|
+
callout.replaceChildren();
|
|
99
|
+
const number = document.createElement("i");
|
|
100
|
+
number.style.backgroundColor = stopColors[stop.role];
|
|
101
|
+
number.textContent = String(stop.order);
|
|
102
|
+
const content = document.createElement("div");
|
|
103
|
+
const name = document.createElement("strong");
|
|
104
|
+
name.textContent = stop.name;
|
|
105
|
+
const detail = document.createElement("span");
|
|
106
|
+
detail.textContent = stop.detail;
|
|
107
|
+
content.append(name, detail);
|
|
108
|
+
callout.append(number, content);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
legend.innerHTML = `<strong>Transport modes</strong>${routes.map((route) => `
|
|
112
|
+
<div><i style="background:${route.color}"></i><b>${route.badge}</b><span>${route.label}</span></div>
|
|
113
|
+
`).join("")}`;
|
|
114
|
+
showStop(stops[3]);
|
|
115
|
+
|
|
116
|
+
const map = new maplibregl.Map({
|
|
117
|
+
container: mapContainer,
|
|
118
|
+
style: "https://tiles.openfreemap.org/styles/liberty",
|
|
119
|
+
bounds: [[-127.5, 32], [-69, 51.5]],
|
|
120
|
+
fitBoundsOptions: {
|
|
121
|
+
padding: { top: 76, right: 72, bottom: 46, left: 64 },
|
|
122
|
+
duration: 0
|
|
123
|
+
},
|
|
124
|
+
minZoom: 2.2,
|
|
125
|
+
maxZoom: 8,
|
|
126
|
+
attributionControl: { compact: true }
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
map.addControl(new maplibregl.NavigationControl({ showCompass: false }), "bottom-right");
|
|
130
|
+
|
|
131
|
+
const renderOverlay = () => {
|
|
132
|
+
const { width, height } = mapContainer.getBoundingClientRect();
|
|
133
|
+
overlay.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
134
|
+
overlay.replaceChildren();
|
|
135
|
+
|
|
136
|
+
routes.forEach((route) => {
|
|
137
|
+
const pathData = projectPath(map, route);
|
|
138
|
+
const path = svgNode("path");
|
|
139
|
+
path.setAttribute("d", pathData);
|
|
140
|
+
path.setAttribute("class", `route-path route-path-${route.mode}`);
|
|
141
|
+
path.setAttribute("stroke", route.color);
|
|
142
|
+
path.setAttribute("vector-effect", "non-scaling-stroke");
|
|
143
|
+
const flow = svgNode("path");
|
|
144
|
+
flow.setAttribute("d", pathData);
|
|
145
|
+
flow.setAttribute("class", "route-flow");
|
|
146
|
+
flow.setAttribute("vector-effect", "non-scaling-stroke");
|
|
147
|
+
overlay.append(path, flow);
|
|
148
|
+
|
|
149
|
+
const middle = map.project(route.points[Math.floor(route.points.length / 2)]);
|
|
150
|
+
const badge = svgNode("g");
|
|
151
|
+
badge.setAttribute("class", "route-mode-badge");
|
|
152
|
+
badge.setAttribute("transform", `translate(${middle.x} ${middle.y})`);
|
|
153
|
+
const circle = svgNode("circle");
|
|
154
|
+
circle.setAttribute("r", "20");
|
|
155
|
+
circle.setAttribute("fill", route.color);
|
|
156
|
+
const text = svgNode("text");
|
|
157
|
+
text.setAttribute("text-anchor", "middle");
|
|
158
|
+
text.setAttribute("dy", "4");
|
|
159
|
+
text.textContent = route.badge;
|
|
160
|
+
badge.append(circle, text);
|
|
161
|
+
overlay.append(badge);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
stops.forEach((stop) => {
|
|
165
|
+
const point = map.project(stop.coordinates);
|
|
166
|
+
const marker = svgNode("g");
|
|
167
|
+
marker.setAttribute("class", "route-stop");
|
|
168
|
+
marker.setAttribute("transform", `translate(${point.x} ${point.y})`);
|
|
169
|
+
marker.setAttribute("role", "button");
|
|
170
|
+
marker.setAttribute("tabindex", "0");
|
|
171
|
+
marker.setAttribute("aria-label", `${stop.order}. ${stop.name}: ${stop.detail}`);
|
|
172
|
+
const pin = svgNode("path");
|
|
173
|
+
pin.setAttribute("d", "M 0 18 C -5 11 -14 2 -14 -8 A 14 14 0 1 1 14 -8 C 14 2 5 11 0 18 Z");
|
|
174
|
+
pin.setAttribute("fill", stopColors[stop.role]);
|
|
175
|
+
const number = svgNode("text");
|
|
176
|
+
number.setAttribute("text-anchor", "middle");
|
|
177
|
+
number.setAttribute("dy", "-3");
|
|
178
|
+
number.textContent = String(stop.order);
|
|
179
|
+
const label = svgNode("text");
|
|
180
|
+
label.setAttribute("class", "route-stop-label");
|
|
181
|
+
label.setAttribute("x", "19");
|
|
182
|
+
label.setAttribute("dy", "5");
|
|
183
|
+
label.textContent = stop.name;
|
|
184
|
+
marker.append(pin, number, label);
|
|
185
|
+
marker.addEventListener("click", () => showStop(stop));
|
|
186
|
+
marker.addEventListener("keydown", (event) => {
|
|
187
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
showStop(stop);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
overlay.append(marker);
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
map.on("load", renderOverlay);
|
|
197
|
+
map.on("move", renderOverlay);
|
|
198
|
+
map.on("resize", renderOverlay);
|
|
199
|
+
new ResizeObserver(() => {
|
|
200
|
+
map.resize();
|
|
201
|
+
renderOverlay();
|
|
202
|
+
}).observe(mapContainer);
|
|
203
|
+
|
|
204
|
+
animationToggle.addEventListener("click", () => {
|
|
205
|
+
const isAnimating = lab.classList.toggle("is-route-animating");
|
|
206
|
+
animationToggle.setAttribute("aria-pressed", String(isAnimating));
|
|
207
|
+
const icon = animationToggle.querySelector("i");
|
|
208
|
+
if (icon) {
|
|
209
|
+
icon.textContent = isAnimating ? "II" : ">";
|
|
210
|
+
}
|
|
211
|
+
});
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@500;700;800&display=swap");
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
font-family: Inter, ui-sans-serif, system-ui, sans-serif;
|
|
5
|
+
color: #edf3f8;
|
|
6
|
+
background: #07111b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
* { box-sizing: border-box; }
|
|
10
|
+
html, body { width: 100%; height: 100%; margin: 0; }
|
|
11
|
+
button { font: inherit; }
|
|
12
|
+
|
|
13
|
+
.route-lab {
|
|
14
|
+
position: relative;
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 100%;
|
|
17
|
+
min-height: 560px;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
background: #0b1722;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.route-map,
|
|
23
|
+
.route-overlay {
|
|
24
|
+
position: absolute;
|
|
25
|
+
inset: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.route-overlay {
|
|
31
|
+
z-index: 2;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
overflow: visible;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.route-path {
|
|
37
|
+
fill: none;
|
|
38
|
+
stroke-width: 7;
|
|
39
|
+
stroke-linecap: round;
|
|
40
|
+
stroke-linejoin: round;
|
|
41
|
+
filter: drop-shadow(0 2px 4px rgba(3, 10, 18, .62));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.route-path-air { stroke-dasharray: 12 9; }
|
|
45
|
+
|
|
46
|
+
.route-flow {
|
|
47
|
+
fill: none;
|
|
48
|
+
stroke: rgba(255, 255, 255, .9);
|
|
49
|
+
stroke-width: 2;
|
|
50
|
+
stroke-linecap: round;
|
|
51
|
+
stroke-dasharray: 3 20;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.is-route-animating .route-flow { animation: route-flow 1.15s linear infinite; }
|
|
55
|
+
@keyframes route-flow { to { stroke-dashoffset: -46; } }
|
|
56
|
+
|
|
57
|
+
.route-mode-badge text,
|
|
58
|
+
.route-stop text {
|
|
59
|
+
fill: #fff;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
font-weight: 800;
|
|
62
|
+
paint-order: stroke;
|
|
63
|
+
stroke: rgba(6, 16, 25, .72);
|
|
64
|
+
stroke-width: 2px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.route-mode-badge circle {
|
|
68
|
+
stroke: #fff;
|
|
69
|
+
stroke-width: 2px;
|
|
70
|
+
filter: drop-shadow(0 4px 8px rgba(3, 10, 18, .42));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.route-stop { pointer-events: auto; cursor: pointer; outline: none; }
|
|
74
|
+
.route-stop path { stroke: #fff; stroke-width: 3px; filter: drop-shadow(0 3px 5px rgba(3, 10, 18, .58)); }
|
|
75
|
+
.route-stop:hover path, .route-stop:focus path { stroke-width: 5px; }
|
|
76
|
+
.route-stop .route-stop-label { font-size: 12px; stroke-width: 3px; }
|
|
77
|
+
|
|
78
|
+
.route-toolbar,
|
|
79
|
+
.route-legend,
|
|
80
|
+
.route-callout {
|
|
81
|
+
position: absolute;
|
|
82
|
+
z-index: 4;
|
|
83
|
+
border: 1px solid rgba(231, 241, 248, .22);
|
|
84
|
+
border-radius: 8px;
|
|
85
|
+
background: rgba(7, 17, 27, .87);
|
|
86
|
+
box-shadow: 0 12px 34px rgba(2, 8, 15, .26);
|
|
87
|
+
backdrop-filter: blur(12px);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.route-toolbar {
|
|
91
|
+
top: 14px;
|
|
92
|
+
right: 14px;
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
gap: 22px;
|
|
96
|
+
padding: 10px 11px 10px 14px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.route-toolbar > div, .route-callout > div { display: grid; gap: 2px; }
|
|
100
|
+
.route-toolbar strong, .route-legend strong, .route-callout strong { color: #f8fbff; font-size: 13px; }
|
|
101
|
+
.route-toolbar span, .route-callout span { color: #a8bac7; font-size: 11px; }
|
|
102
|
+
|
|
103
|
+
#animation-toggle {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 8px;
|
|
107
|
+
min-height: 34px;
|
|
108
|
+
border: 1px solid rgba(143, 216, 255, .3);
|
|
109
|
+
border-radius: 7px;
|
|
110
|
+
background: rgba(93, 184, 255, .15);
|
|
111
|
+
color: #e9f7ff;
|
|
112
|
+
padding: 7px 10px;
|
|
113
|
+
font-size: 11px;
|
|
114
|
+
font-weight: 800;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
#animation-toggle i {
|
|
118
|
+
display: grid;
|
|
119
|
+
width: 19px;
|
|
120
|
+
height: 19px;
|
|
121
|
+
place-items: center;
|
|
122
|
+
border-radius: 50%;
|
|
123
|
+
background: #5db8ff;
|
|
124
|
+
color: #07111b;
|
|
125
|
+
font-size: 8px;
|
|
126
|
+
font-style: normal;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.route-legend {
|
|
130
|
+
left: 14px;
|
|
131
|
+
bottom: 14px;
|
|
132
|
+
display: grid;
|
|
133
|
+
gap: 8px;
|
|
134
|
+
width: 180px;
|
|
135
|
+
padding: 13px 14px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.route-legend > div {
|
|
139
|
+
display: grid;
|
|
140
|
+
grid-template-columns: 22px 38px minmax(0, 1fr);
|
|
141
|
+
align-items: center;
|
|
142
|
+
gap: 5px;
|
|
143
|
+
color: #b8c8d2;
|
|
144
|
+
font-size: 10px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.route-legend i { width: 20px; height: 4px; border-radius: 2px; }
|
|
148
|
+
.route-legend b { color: #f8fbff; font-size: 9px; }
|
|
149
|
+
|
|
150
|
+
.route-callout {
|
|
151
|
+
top: 78px;
|
|
152
|
+
right: 14px;
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
gap: 10px;
|
|
156
|
+
min-width: 190px;
|
|
157
|
+
padding: 10px 12px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.route-callout > i {
|
|
161
|
+
display: grid;
|
|
162
|
+
width: 29px;
|
|
163
|
+
height: 29px;
|
|
164
|
+
place-items: center;
|
|
165
|
+
border-radius: 50%;
|
|
166
|
+
color: #07111b;
|
|
167
|
+
font-size: 12px;
|
|
168
|
+
font-style: normal;
|
|
169
|
+
font-weight: 900;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@media (max-width: 680px) {
|
|
173
|
+
.route-toolbar { left: 8px; right: 8px; top: 8px; justify-content: space-between; }
|
|
174
|
+
.route-toolbar > div span, .route-callout span { display: none; }
|
|
175
|
+
.route-legend { left: 8px; bottom: 8px; width: 140px; padding: 10px; }
|
|
176
|
+
.route-legend > div { grid-template-columns: 18px 30px minmax(0, 1fr); gap: 3px; }
|
|
177
|
+
.route-callout { top: 60px; right: 8px; min-width: 0; }
|
|
178
|
+
}
|
package/package.json
CHANGED