@sjvair/monitor-map 3.0.3 → 3.0.5
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/dist/lib/LoadScreen.svelte +68 -0
- package/dist/lib/LoadScreen.svelte.d.ts +25 -0
- package/dist/lib/MainMapView.svelte +1 -0
- package/dist/lib/MainMapView.svelte.d.ts +26 -0
- package/dist/lib/MapLegend.svelte +15 -0
- package/dist/lib/MapLegend.svelte.d.ts +18 -0
- package/dist/lib/MonitorDetailPanel.svelte +152 -0
- package/dist/lib/MonitorDetailPanel.svelte.d.ts +3 -0
- package/dist/lib/MonitorMapLayout.svelte +193 -0
- package/dist/lib/MonitorMapLayout.svelte.d.ts +7 -0
- package/dist/lib/actions.d.ts +3 -0
- package/dist/lib/actions.js +12 -8
- package/dist/lib/assets/icons/adjustment-horizontal.svg +3 -0
- package/dist/lib/assets/logos/airgradient-blue.svg +63 -0
- package/dist/lib/assets/logos/airnow-compact.jpg +0 -0
- package/dist/lib/assets/logos/carb-compact.jpg +0 -0
- package/dist/lib/assets/logos/purpleair-compact.png +0 -0
- package/dist/lib/assets/logos/sjvair-parts/sjvair-air.webp +0 -0
- package/dist/lib/assets/logos/sjvair-parts/sjvair-icon.webp +0 -0
- package/dist/lib/assets/logos/sjvair-parts/sjvair-sjv.webp +0 -0
- package/dist/lib/assets/logos/sjvair-white.svg +115 -0
- package/dist/lib/assets/logos/sjvair.svg +96 -0
- package/dist/lib/collocation-sites/CollocationTooltip.svelte +98 -0
- package/dist/lib/collocation-sites/CollocationTooltip.svelte.d.ts +7 -0
- package/dist/lib/collocation-sites/collocation-utils.d.ts +3 -0
- package/dist/lib/collocation-sites/collocation-utils.js +30 -0
- package/dist/lib/collocation-sites/collocations-icon-manager.svelte.d.ts +7 -0
- package/dist/lib/collocation-sites/collocations-icon-manager.svelte.js +17 -20
- package/dist/lib/collocation-sites/collocations-map-integration.svelte.d.ts +18 -0
- package/dist/lib/collocation-sites/collocations-map-integration.svelte.js +98 -83
- package/dist/lib/collocation-sites/collocations.svelte.d.ts +9 -0
- package/dist/lib/collocation-sites/collocations.svelte.js +17 -26
- package/dist/lib/collocation-sites/types.d.ts +8 -0
- package/dist/lib/collocation-sites/types.js +1 -0
- package/dist/lib/colors.d.ts +17 -0
- package/dist/lib/colors.js +29 -23
- package/dist/lib/components/DataBox.svelte +29 -0
- package/dist/lib/components/DataBox.svelte.d.ts +9 -0
- package/dist/lib/components/DisplayOption.svelte +7 -0
- package/dist/lib/components/DisplayOption.svelte.d.ts +5 -0
- package/dist/lib/components/MapLayersDisplayOptions.svelte +42 -0
- package/dist/lib/components/MapLayersDisplayOptions.svelte.d.ts +18 -0
- package/dist/lib/components/SegmentedControl.svelte +61 -0
- package/dist/lib/components/SegmentedControl.svelte.d.ts +11 -0
- package/dist/lib/components/ToggleSwitch.svelte +93 -0
- package/dist/lib/components/ToggleSwitch.svelte.d.ts +9 -0
- package/dist/lib/components/ui/button/button.svelte +89 -0
- package/dist/lib/components/ui/button/button.svelte.d.ts +70 -0
- package/dist/lib/components/ui/button/index.d.ts +2 -0
- package/dist/lib/components/ui/button/index.js +4 -0
- package/dist/lib/components/ui/range-calendar/index.d.ts +19 -0
- package/dist/lib/components/ui/range-calendar/index.js +21 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-caption.svelte +76 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-caption.svelte.d.ts +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-cell.svelte +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-cell.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-day.svelte +36 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-day.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-body.svelte +7 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-body.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-head.svelte +7 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-head.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-row.svelte +12 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-row.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid.svelte +16 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-grid.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-head-cell.svelte +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-head-cell.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-header.svelte +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-header.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-heading.svelte +16 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-heading.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month-select.svelte +44 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month-select.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month.svelte +15 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-month.svelte.d.ts +5 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-months.svelte +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-months.svelte.d.ts +5 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-nav.svelte +19 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-nav.svelte.d.ts +5 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-next-button.svelte +36 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-next-button.svelte.d.ts +8 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-prev-button.svelte +36 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-prev-button.svelte.d.ts +8 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-year-select.svelte +43 -0
- package/dist/lib/components/ui/range-calendar/range-calendar-year-select.svelte.d.ts +4 -0
- package/dist/lib/components/ui/range-calendar/range-calendar.svelte +112 -0
- package/dist/lib/components/ui/range-calendar/range-calendar.svelte.d.ts +21 -0
- package/dist/lib/data-chart/DataChart.svelte +303 -0
- package/dist/lib/data-chart/DataChart.svelte.d.ts +7 -0
- package/dist/lib/data-chart/DateRange.d.ts +6 -0
- package/dist/lib/data-chart/DateRange.js +15 -14
- package/dist/lib/data-chart/chart-utils.d.ts +3 -0
- package/dist/lib/data-chart/chart-utils.js +157 -93
- package/dist/lib/data-chart/data-chart.svelte.d.ts +7 -0
- package/dist/lib/data-chart/data-chart.svelte.js +7 -28
- package/dist/lib/data-chart/requests.d.ts +3 -0
- package/dist/lib/data-chart/requests.js +36 -28
- package/dist/lib/data-chart/tooltip.d.ts +10 -0
- package/dist/lib/data-chart/tooltip.js +160 -98
- package/dist/lib/ev-stations/components/EvStationClusterTooltip.svelte +16 -0
- package/dist/lib/ev-stations/components/EvStationClusterTooltip.svelte.d.ts +7 -0
- package/dist/lib/ev-stations/components/EvStationTooltip.svelte +127 -0
- package/dist/lib/ev-stations/components/EvStationTooltip.svelte.d.ts +7 -0
- package/dist/lib/ev-stations/components/EvStationsDisplayOptions.svelte +46 -0
- package/dist/lib/ev-stations/components/EvStationsDisplayOptions.svelte.d.ts +18 -0
- package/dist/lib/ev-stations/data-maps.d.ts +5 -0
- package/dist/lib/ev-stations/data-maps.js +152 -4
- package/dist/lib/ev-stations/ev-station-icons.d.ts +16 -0
- package/dist/lib/ev-stations/ev-station-icons.js +21 -27
- package/dist/lib/ev-stations/ev-stations-cluster-renderer.d.ts +19 -0
- package/dist/lib/ev-stations/ev-stations-cluster-renderer.js +130 -117
- package/dist/lib/ev-stations/ev-stations-map-integration.svelte.d.ts +31 -0
- package/dist/lib/ev-stations/ev-stations-map-integration.svelte.js +206 -180
- package/dist/lib/ev-stations/ev-stations.svelte.d.ts +9 -0
- package/dist/lib/ev-stations/ev-stations.svelte.js +54 -32
- package/dist/lib/ev-stations/types.d.ts +53 -0
- package/dist/lib/ev-stations/types.js +1 -0
- package/dist/lib/ev-stations/zip-codes.d.ts +13 -0
- package/dist/lib/ev-stations/zip-codes.js +457 -135
- package/dist/lib/hms/components/HMSFireLegend.svelte +21 -0
- package/dist/lib/hms/components/HMSFireLegend.svelte.d.ts +18 -0
- package/dist/lib/hms/hms-fire-icon-manager.d.ts +5 -0
- package/dist/lib/hms/hms-fire-icon-manager.js +28 -37
- package/dist/lib/hms/hms-fire-map-integration.svelte.d.ts +23 -0
- package/dist/lib/hms/hms-fire-map-integration.svelte.js +94 -97
- package/dist/lib/hms/hms-smoke-map-integration.svelte.d.ts +19 -0
- package/dist/lib/hms/hms-smoke-map-integration.svelte.js +68 -84
- package/dist/lib/hms/hms.svelte.d.ts +19 -0
- package/dist/lib/hms/hms.svelte.js +225 -76
- package/dist/lib/index.d.ts +68 -0
- package/dist/lib/index.js +56 -21
- package/dist/lib/map/Map.svelte +13 -0
- package/dist/lib/map/Map.svelte.d.ts +8 -0
- package/dist/lib/map/MapStyleDisplayOptions.svelte +61 -0
- package/dist/lib/map/MapStyleDisplayOptions.svelte.d.ts +3 -0
- package/dist/lib/map/Menu.svelte +64 -0
- package/dist/lib/map/Menu.svelte.d.ts +5 -0
- package/dist/lib/map/icons.d.ts +7 -0
- package/dist/lib/map/icons.js +24 -22
- package/dist/lib/map/integrations/base-layer-seperator.d.ts +9 -0
- package/dist/lib/map/integrations/base-layer-seperator.js +11 -12
- package/dist/lib/map/integrations/click-manager.d.ts +14 -0
- package/dist/lib/map/integrations/click-manager.js +52 -33
- package/dist/lib/map/integrations/integrations-manager.d.ts +8 -0
- package/dist/lib/map/integrations/integrations-manager.js +20 -12
- package/dist/lib/map/integrations/map-display-option.svelte.d.ts +7 -0
- package/dist/lib/map/integrations/map-display-option.svelte.js +10 -18
- package/dist/lib/map/integrations/map-geojson-integration.svelte.d.ts +13 -0
- package/dist/lib/map/integrations/map-geojson-integration.svelte.js +21 -17
- package/dist/lib/map/integrations/map-icon-manager.d.ts +15 -0
- package/dist/lib/map/integrations/map-icon-manager.js +52 -46
- package/dist/lib/map/integrations/map-integration.svelte.d.ts +6 -0
- package/dist/lib/map/integrations/map-integration.svelte.js +2 -5
- package/dist/lib/map/integrations/map-layer-integration.svelte.d.ts +11 -0
- package/dist/lib/map/integrations/map-layer-integration.svelte.js +36 -23
- package/dist/lib/map/integrations/tooltip.svelte.d.ts +28 -0
- package/dist/lib/map/integrations/tooltip.svelte.js +120 -78
- package/dist/lib/map/integrations/types.d.ts +14 -0
- package/dist/lib/map/integrations/types.js +1 -0
- package/dist/lib/map/map.svelte.d.ts +14 -0
- package/dist/lib/map/map.svelte.js +48 -50
- package/dist/lib/map/utils.d.ts +7 -0
- package/dist/lib/map/utils.js +32 -29
- package/dist/lib/monitors/components/MonitorClusterTooltip.svelte +112 -0
- package/dist/lib/monitors/components/MonitorClusterTooltip.svelte.d.ts +7 -0
- package/dist/lib/monitors/components/MonitorMarkersLegend.svelte +41 -0
- package/dist/lib/monitors/components/MonitorMarkersLegend.svelte.d.ts +3 -0
- package/dist/lib/monitors/components/MonitorSubscriptionManager.svelte +128 -0
- package/dist/lib/monitors/components/MonitorSubscriptionManager.svelte.d.ts +6 -0
- package/dist/lib/monitors/components/MonitorTooltip.svelte +61 -0
- package/dist/lib/monitors/components/MonitorTooltip.svelte.d.ts +7 -0
- package/dist/lib/monitors/components/MonitorWidgetModal.svelte +100 -0
- package/dist/lib/monitors/components/MonitorWidgetModal.svelte.d.ts +6 -0
- package/dist/lib/monitors/components/MonitorsDisplayOptions.svelte +79 -0
- package/dist/lib/monitors/components/MonitorsDisplayOptions.svelte.d.ts +3 -0
- package/dist/lib/monitors/monitor-utils.d.ts +4 -0
- package/dist/lib/monitors/monitor-utils.js +33 -23
- package/dist/lib/monitors/monitors-cluster-renderer.d.ts +33 -0
- package/dist/lib/monitors/monitors-cluster-renderer.js +218 -209
- package/dist/lib/monitors/monitors-icon-manager.svelte.d.ts +13 -0
- package/dist/lib/monitors/monitors-icon-manager.svelte.js +75 -70
- package/dist/lib/monitors/monitors-map-integration.svelte.d.ts +40 -0
- package/dist/lib/monitors/monitors-map-integration.svelte.js +278 -270
- package/dist/lib/monitors/monitors.svelte.d.ts +16 -0
- package/dist/lib/monitors/monitors.svelte.js +38 -63
- package/dist/lib/monitors/types.d.ts +26 -0
- package/dist/lib/monitors/types.js +1 -0
- package/dist/lib/reactivity.svelte.d.ts +0 -0
- package/dist/lib/reactivity.svelte.js +83 -0
- package/dist/lib/router-context.d.ts +27 -0
- package/dist/lib/router-context.js +11 -11
- package/dist/lib/routes.d.ts +2 -0
- package/dist/lib/routes.js +10 -9
- package/dist/lib/search/Search.svelte +189 -0
- package/dist/lib/search/Search.svelte.d.ts +3 -0
- package/dist/lib/search/service.d.ts +17 -0
- package/dist/lib/search/service.js +75 -85
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.js +10 -12
- package/dist/lib/weather.d.ts +1 -0
- package/dist/lib/weather.js +11 -7
- package/dist/lib/wind/wind.svelte.d.ts +10 -0
- package/dist/lib/wind/wind.svelte.js +13 -21
- package/package.json +9 -7
- package/src/lib/LoadScreen.svelte +3 -3
- package/src/lib/hms/components/HMSFireLegend.svelte +1 -1
- package/src/lib/hms/hms.svelte.ts +8 -9
- package/src/lib/index.ts +18 -0
- package/src/lib/routes.ts +6 -1
- package/src/lib/utils.ts +1 -1
- package/dist/lib/LoadScreen.js +0 -73
- package/dist/lib/MainMapView.js +0 -7
- package/dist/lib/MapLegend.js +0 -13
- package/dist/lib/MonitorDetailPanel.js +0 -169
- package/dist/lib/MonitorMapLayout.js +0 -91
- package/dist/lib/_virtual/_rolldown/runtime.js +0 -11
- package/dist/lib/assets/logos/airgradient-blue.js +0 -4
- package/dist/lib/assets/logos/airnow-compact.js +0 -4
- package/dist/lib/assets/logos/carb-compact.js +0 -4
- package/dist/lib/assets/logos/purpleair-compact.js +0 -4
- package/dist/lib/assets/logos/sjvair.js +0 -4
- package/dist/lib/collocation-sites/CollocationTooltip.js +0 -105
- package/dist/lib/components/DataBox.js +0 -30
- package/dist/lib/components/DisplayOption.js +0 -10
- package/dist/lib/components/MapLayersDisplayOptions.js +0 -87
- package/dist/lib/components/SegmentedControl.js +0 -37
- package/dist/lib/components/ToggleSwitch.js +0 -17
- package/dist/lib/components/ui/button/button.js +0 -34
- package/dist/lib/components/ui/range-calendar/range-calendar-caption.js +0 -82
- package/dist/lib/components/ui/range-calendar/range-calendar-cell.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-day.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-body.js +0 -27
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-head.js +0 -27
- package/dist/lib/components/ui/range-calendar/range-calendar-grid-row.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-grid.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-head-cell.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-header.js +0 -35
- package/dist/lib/components/ui/range-calendar/range-calendar-month-select.js +0 -61
- package/dist/lib/components/ui/range-calendar/range-calendar-month.js +0 -25
- package/dist/lib/components/ui/range-calendar/range-calendar-months.js +0 -25
- package/dist/lib/components/ui/range-calendar/range-calendar-nav.js +0 -25
- package/dist/lib/components/ui/range-calendar/range-calendar-next-button.js +0 -58
- package/dist/lib/components/ui/range-calendar/range-calendar-prev-button.js +0 -58
- package/dist/lib/components/ui/range-calendar/range-calendar-year-select.js +0 -59
- package/dist/lib/components/ui/range-calendar/range-calendar.js +0 -272
- package/dist/lib/data-chart/DataChart.js +0 -142
- package/dist/lib/ev-stations/components/EvStationClusterTooltip.js +0 -16
- package/dist/lib/ev-stations/components/EvStationTooltip.js +0 -120
- package/dist/lib/ev-stations/components/EvStationsDisplayOptions.js +0 -41
- package/dist/lib/hms/components/HMSFireLegend.js +0 -35
- package/dist/lib/map/Map.js +0 -14
- package/dist/lib/map/MapStyleDisplayOptions.js +0 -43
- package/dist/lib/map/Menu.js +0 -44
- package/dist/lib/monitors/components/MonitorClusterTooltip.js +0 -83
- package/dist/lib/monitors/components/MonitorMarkersLegend.js +0 -35
- package/dist/lib/monitors/components/MonitorSubscriptionManager.js +0 -104
- package/dist/lib/monitors/components/MonitorTooltip.js +0 -59
- package/dist/lib/monitors/components/MonitorWidgetModal.js +0 -40
- package/dist/lib/monitors/components/MonitorsDisplayOptions.js +0 -76
- package/dist/lib/search/Search.js +0 -124
- package/dist/lib/sjvair-air.avif +0 -0
- package/dist/lib/sjvair-air.png +0 -0
- package/dist/lib/sjvair-air.webp +0 -0
- package/dist/lib/sjvair-air2.avif +0 -0
- package/dist/lib/sjvair-air2.png +0 -0
- package/dist/lib/sjvair-air2.webp +0 -0
- package/dist/lib/sjvair-icon.avif +0 -0
- package/dist/lib/sjvair-icon.png +0 -0
- package/dist/lib/sjvair-icon.webp +0 -0
- package/dist/lib/sjvair-icon2.avif +0 -0
- package/dist/lib/sjvair-icon2.png +0 -0
- package/dist/lib/sjvair-icon2.webp +0 -0
- package/dist/lib/sjvair-sjv.avif +0 -0
- package/dist/lib/sjvair-sjv.png +0 -0
- package/dist/lib/sjvair-sjv.webp +0 -0
- package/dist/lib/sjvair-sjv2.avif +0 -0
- package/dist/lib/sjvair-sjv2.png +0 -0
- package/dist/lib/sjvair-sjv2.webp +0 -0
|
@@ -1,99 +1,163 @@
|
|
|
1
|
-
import { monitorsManager
|
|
2
|
-
import { tooltipsPlugin
|
|
3
|
-
import { fromUnixTime
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { monitorsManager } from "../monitors/monitors.svelte";
|
|
2
|
+
import { tooltipsPlugin, uPlotCursorConfig } from "./tooltip";
|
|
3
|
+
import { fromUnixTime, getUnixTime, isToday, isAfter } from "date-fns";
|
|
4
|
+
const PM25_AVG_60_STROKE = "3572b0";
|
|
5
|
+
function getColors() {
|
|
6
|
+
const levels = monitorsManager.levels ?? [];
|
|
7
|
+
const colors = levels.map((level) => [level.range[0], level.color.replace(/^#/, "")]);
|
|
8
|
+
colors.push([Infinity, "000000"]);
|
|
9
|
+
return colors;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
...u,
|
|
16
|
-
label: "Real Time",
|
|
17
|
-
width: 2,
|
|
18
|
-
stroke: (e) => g(e, "y", 1, c(), !0)
|
|
19
|
-
}, f = {
|
|
20
|
-
...u,
|
|
21
|
-
label: "60 Minute Average",
|
|
22
|
-
stroke: (e) => h(e, s)
|
|
11
|
+
const baseXSeriesConfig = {};
|
|
12
|
+
const baseYSeriesConfig = {
|
|
13
|
+
show: true,
|
|
14
|
+
spanGaps: false,
|
|
15
|
+
width: 1
|
|
23
16
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
17
|
+
const pm25SeriesConfig = {
|
|
18
|
+
...baseYSeriesConfig,
|
|
19
|
+
label: "Real Time",
|
|
20
|
+
width: 2,
|
|
21
|
+
stroke: (u) => scaleGradient(u, "y", 1, getColors(), true)
|
|
22
|
+
};
|
|
23
|
+
const pm25Avg60SeriesConfig = {
|
|
24
|
+
...baseYSeriesConfig,
|
|
25
|
+
label: "60 Minute Average",
|
|
26
|
+
stroke: (u) => autograd(u, PM25_AVG_60_STROKE)
|
|
27
|
+
};
|
|
28
|
+
export function getChartConfig(sourceName, maxDiff, width, height) {
|
|
29
|
+
const series = getSeriesConfigs(sourceName);
|
|
30
|
+
const getStroke = (u, sIdx) => {
|
|
31
|
+
const stroke = series[sIdx].stroke;
|
|
32
|
+
return stroke(u, sIdx);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
cursor: uPlotCursorConfig.get(),
|
|
38
|
+
// @ts-expect-error: select missing pseudo "required" options
|
|
39
|
+
select: {
|
|
40
|
+
show: false
|
|
41
|
+
},
|
|
42
|
+
plugins: [tooltipsPlugin()],
|
|
43
|
+
series,
|
|
44
|
+
legend: {
|
|
45
|
+
live: false,
|
|
46
|
+
markers: {
|
|
47
|
+
fill: (u, sIdx) => getStroke(u, sIdx)
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
scales: {
|
|
51
|
+
x: {
|
|
52
|
+
range: (_, min, max) => {
|
|
53
|
+
const maxDate = fromUnixTime(max);
|
|
54
|
+
const now = new Date();
|
|
55
|
+
max = isToday(maxDate) && isAfter(now, maxDate) ? getUnixTime(now) : max;
|
|
56
|
+
return [min, max];
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
y: {
|
|
60
|
+
range: {
|
|
61
|
+
min: {
|
|
62
|
+
mode: 1,
|
|
63
|
+
pad: 0.1
|
|
64
|
+
},
|
|
65
|
+
max: {
|
|
66
|
+
mode: 2,
|
|
67
|
+
soft: 0,
|
|
68
|
+
pad: 0.1
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
axes: [
|
|
74
|
+
{
|
|
75
|
+
grid: {
|
|
76
|
+
show: false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: monitorsManager.pollutant === "pm25" ? "PM 2.5" : "Ozone",
|
|
81
|
+
side: 3,
|
|
82
|
+
values: (_, ticks) => ticks.map((v) => v.toFixed(maxDiff < 5 ? 1 : 0))
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
hooks: {
|
|
86
|
+
ready: [() => document.querySelector(".u-series").remove()]
|
|
87
|
+
}
|
|
88
|
+
};
|
|
64
89
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
function getSeriesConfigs(monitorType) {
|
|
91
|
+
const singleSeriesConfig = Object.assign({}, pm25Avg60SeriesConfig);
|
|
92
|
+
singleSeriesConfig.width = 2;
|
|
93
|
+
switch (monitorType) {
|
|
94
|
+
case "airnow":
|
|
95
|
+
case "aqview":
|
|
96
|
+
case "bam1022":
|
|
97
|
+
return [baseXSeriesConfig, singleSeriesConfig];
|
|
98
|
+
case "airgradient":
|
|
99
|
+
case "purpleair":
|
|
100
|
+
return [baseXSeriesConfig, pm25SeriesConfig];
|
|
101
|
+
}
|
|
74
102
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
103
|
+
function autograd(u, fallback) {
|
|
104
|
+
if (u.series.length > 2) {
|
|
105
|
+
return fallback;
|
|
106
|
+
}
|
|
107
|
+
return scaleGradient(u, "y", 1, getColors(), true);
|
|
77
108
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
109
|
+
function scaleGradient(u, scaleKey, ori, scaleStops, discrete = false) {
|
|
110
|
+
const scale = u.scales[scaleKey];
|
|
111
|
+
let minStopIdx;
|
|
112
|
+
let maxStopIdx;
|
|
113
|
+
for (let i = 0; i < scaleStops.length; i++) {
|
|
114
|
+
const stopVal = scaleStops[i][0];
|
|
115
|
+
if (stopVal <= scale.min || minStopIdx === undefined) {
|
|
116
|
+
minStopIdx = i;
|
|
117
|
+
}
|
|
118
|
+
maxStopIdx = i;
|
|
119
|
+
if (stopVal >= scale.max)
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (minStopIdx == maxStopIdx) {
|
|
123
|
+
return scaleStops[minStopIdx][1];
|
|
124
|
+
}
|
|
125
|
+
let minStopVal = scaleStops[minStopIdx][0];
|
|
126
|
+
let maxStopVal = scaleStops[maxStopIdx][0];
|
|
127
|
+
if (minStopVal === -Infinity)
|
|
128
|
+
minStopVal = scale.min || 0;
|
|
129
|
+
if (maxStopVal === Infinity)
|
|
130
|
+
maxStopVal = scale.max || 0;
|
|
131
|
+
const minStopPos = u.valToPos(minStopVal, scaleKey, true);
|
|
132
|
+
const maxStopPos = u.valToPos(maxStopVal, scaleKey, true);
|
|
133
|
+
if (!minStopPos || !maxStopPos)
|
|
134
|
+
return;
|
|
135
|
+
const range = minStopPos - maxStopPos;
|
|
136
|
+
let x0, y0, x1, y1;
|
|
137
|
+
if (ori == 1) {
|
|
138
|
+
x0 = x1 = 0;
|
|
139
|
+
y0 = minStopPos;
|
|
140
|
+
y1 = maxStopPos;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
y0 = y1 = 0;
|
|
144
|
+
x0 = minStopPos;
|
|
145
|
+
x1 = maxStopPos;
|
|
146
|
+
}
|
|
147
|
+
const grd = u.ctx.createLinearGradient(x0, y0, x1, y1);
|
|
148
|
+
let prevColor;
|
|
149
|
+
for (let i = minStopIdx; i <= maxStopIdx; i++) {
|
|
150
|
+
const s = scaleStops[i];
|
|
151
|
+
const stopPos = i == minStopIdx
|
|
152
|
+
? minStopPos
|
|
153
|
+
: i == maxStopIdx
|
|
154
|
+
? maxStopPos
|
|
155
|
+
: u.valToPos(s[0], scaleKey, true);
|
|
156
|
+
const pct = (minStopPos - stopPos) / range;
|
|
157
|
+
if (discrete && i > minStopIdx) {
|
|
158
|
+
grd.addColorStop(pct, prevColor);
|
|
159
|
+
}
|
|
160
|
+
grd.addColorStop(pct, (prevColor = `#${s[1]}`));
|
|
161
|
+
}
|
|
162
|
+
return grd;
|
|
97
163
|
}
|
|
98
|
-
//#endregion
|
|
99
|
-
export { p as getChartConfig };
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
import { createDateRange
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
set dateRange(e) {
|
|
10
|
-
t.set(this.#e, e, !0);
|
|
11
|
-
}
|
|
12
|
-
#t = t.state(t.proxy([]));
|
|
13
|
-
get chartData() {
|
|
14
|
-
return t.get(this.#t);
|
|
15
|
-
}
|
|
16
|
-
set chartData(e) {
|
|
17
|
-
t.set(this.#t, e, !0);
|
|
18
|
-
}
|
|
19
|
-
#n = t.state(!1);
|
|
20
|
-
get loading() {
|
|
21
|
-
return t.get(this.#n);
|
|
22
|
-
}
|
|
23
|
-
set loading(e) {
|
|
24
|
-
t.set(this.#n, e, !0);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
//#endregion
|
|
28
|
-
export { n as DataChartManager };
|
|
1
|
+
import { createDateRange } from "./DateRange.ts";
|
|
2
|
+
class DataChartManager {
|
|
3
|
+
dateRange = $state(createDateRange());
|
|
4
|
+
chartData = $state([]);
|
|
5
|
+
loading = $state(false);
|
|
6
|
+
}
|
|
7
|
+
export { DataChartManager };
|
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { getMonitorEntries } from "@sjvair/sdk";
|
|
2
|
+
import { getUnixTime, parseISO, differenceInMinutes, addMinutes } from "date-fns";
|
|
3
|
+
import { monitorsManager } from "../monitors/monitors.svelte";
|
|
4
|
+
export async function fetchChartData(m, d) {
|
|
5
|
+
return await getMonitorEntries({
|
|
6
|
+
entryType: monitorsManager.pollutant ?? "pm25",
|
|
7
|
+
monitorId: m.id,
|
|
8
|
+
timestampGte: d.start,
|
|
9
|
+
timestampLte: d.end
|
|
10
|
+
})
|
|
11
|
+
.then((entries) => {
|
|
12
|
+
const xAxisData = [];
|
|
13
|
+
const updateDuration = m.data_source.name === "PurpleAir" ? 2 : 60;
|
|
14
|
+
const yAxisRecord = [];
|
|
15
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
16
|
+
const entry = entries[i];
|
|
17
|
+
if (xAxisData.length > 1) {
|
|
18
|
+
const entryTime = parseISO(entry.timestamp);
|
|
19
|
+
let prevTimestamp = xAxisData[xAxisData.length - 1];
|
|
20
|
+
while (Math.abs(differenceInMinutes(entryTime, prevTimestamp)) > updateDuration + 1) {
|
|
21
|
+
prevTimestamp = addMinutes(prevTimestamp, updateDuration);
|
|
22
|
+
fillChartDataRecords(xAxisData, yAxisRecord, entry, prevTimestamp);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
fillChartDataRecords(xAxisData, yAxisRecord, entry);
|
|
26
|
+
}
|
|
27
|
+
return [xAxisData.map((d) => getUnixTime(d)), yAxisRecord];
|
|
28
|
+
})
|
|
29
|
+
.catch((err) => {
|
|
30
|
+
console.error("Failed to load chart data: ", err);
|
|
31
|
+
return [];
|
|
32
|
+
});
|
|
23
33
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
function fillChartDataRecords(xAxisData, yAxisRecord, entry, timestamp) {
|
|
35
|
+
xAxisData.push(timestamp ?? parseISO(entry.timestamp));
|
|
36
|
+
const value = parseFloat(entry.value);
|
|
37
|
+
yAxisRecord.push(timestamp ? null : value >= 0 ? value : 0);
|
|
28
38
|
}
|
|
29
|
-
//#endregion
|
|
30
|
-
export { o as fetchChartData };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const uPlotCursorConfig: {
|
|
2
|
+
set: (left: number, top: number) => void;
|
|
3
|
+
get: () => uPlot.Cursor;
|
|
4
|
+
};
|
|
5
|
+
export declare function tooltipsPlugin(): {
|
|
6
|
+
hooks: {
|
|
7
|
+
init: (u: uPlot, opts: uPlot.Options) => void;
|
|
8
|
+
setCursor: (u: uPlot) => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -1,101 +1,163 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { format, fromUnixTime } from "date-fns";
|
|
2
|
+
import { monitorsManager } from "../monitors/monitors.svelte";
|
|
3
|
+
function getColors() {
|
|
4
|
+
return (monitorsManager.levels ?? []).map((level) => [
|
|
5
|
+
level.range[0],
|
|
6
|
+
level.color.replace(/^#/, "")
|
|
7
|
+
]);
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, c = {
|
|
38
|
-
textAlign: "center",
|
|
39
|
-
backgroundColor: "#f5f5f5",
|
|
40
|
-
fontWeight: "600",
|
|
41
|
-
fontSize: ".8rem",
|
|
42
|
-
padding: ".5rem"
|
|
43
|
-
}, l = {
|
|
44
|
-
margin: ".5rem",
|
|
45
|
-
fontSize: ".9rem"
|
|
9
|
+
let cursLeft = -100;
|
|
10
|
+
let cursTop = -100;
|
|
11
|
+
export const uPlotCursorConfig = {
|
|
12
|
+
set: (left, top) => {
|
|
13
|
+
cursLeft = left;
|
|
14
|
+
cursTop = top;
|
|
15
|
+
},
|
|
16
|
+
get: () => ({
|
|
17
|
+
left: cursLeft,
|
|
18
|
+
top: cursTop,
|
|
19
|
+
y: false,
|
|
20
|
+
points: {
|
|
21
|
+
size: 7,
|
|
22
|
+
fill: (u, sIdx) => {
|
|
23
|
+
const xIdx = u.cursor.idxs[sIdx];
|
|
24
|
+
const colors = getColors();
|
|
25
|
+
if (xIdx != null && u.series.length >= 2 && sIdx === 1) {
|
|
26
|
+
const val = u.data[sIdx][xIdx];
|
|
27
|
+
for (let i = colors.length - 1; i >= 0; i--) {
|
|
28
|
+
const stop = colors[i];
|
|
29
|
+
if (val >= stop[0]) {
|
|
30
|
+
return `#${stop[1]}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const stroke = u.series[sIdx].stroke;
|
|
35
|
+
return stroke(u, sIdx);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
46
39
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
40
|
+
const ttContainerStyles = {
|
|
41
|
+
pointerEvents: "none",
|
|
42
|
+
whiteSpace: "nowrap",
|
|
43
|
+
position: "absolute",
|
|
44
|
+
backgroundColor: "white",
|
|
45
|
+
zIndex: "100"
|
|
46
|
+
};
|
|
47
|
+
const ttHeaderStyles = {
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
backgroundColor: "#f5f5f5",
|
|
50
|
+
fontWeight: "600",
|
|
51
|
+
fontSize: ".8rem",
|
|
52
|
+
padding: ".5rem"
|
|
53
|
+
};
|
|
54
|
+
const ttLineItemStyles = {
|
|
55
|
+
margin: ".5rem",
|
|
56
|
+
fontSize: ".9rem"
|
|
57
|
+
};
|
|
58
|
+
export function tooltipsPlugin() {
|
|
59
|
+
let ttContainer;
|
|
60
|
+
let ttHeader;
|
|
61
|
+
let seriesList;
|
|
62
|
+
function init(u, opts) {
|
|
63
|
+
const over = u.over;
|
|
64
|
+
ttHeader = document.createElement("p");
|
|
65
|
+
ttHeader.classList.add("card-header");
|
|
66
|
+
Object.assign(ttHeader.style, ttHeaderStyles);
|
|
67
|
+
ttContainer = document.createElement("div");
|
|
68
|
+
ttContainer.classList.add("card");
|
|
69
|
+
Object.assign(ttContainer.style, ttContainerStyles);
|
|
70
|
+
ttContainer.appendChild(ttHeader);
|
|
71
|
+
over.appendChild(ttContainer);
|
|
72
|
+
seriesList = opts.series.map((s, i) => {
|
|
73
|
+
if (i === 0)
|
|
74
|
+
return;
|
|
75
|
+
const stroke = s.stroke;
|
|
76
|
+
const line = document.createElement("p");
|
|
77
|
+
Object.assign(line.style, ttLineItemStyles);
|
|
78
|
+
line.style.color = stroke(u, i);
|
|
79
|
+
if (i === 1) {
|
|
80
|
+
line.style.fontWeight = "600";
|
|
81
|
+
}
|
|
82
|
+
ttContainer.appendChild(line);
|
|
83
|
+
return line;
|
|
84
|
+
});
|
|
85
|
+
function hideTips() {
|
|
86
|
+
ttContainer.style.display = "none";
|
|
87
|
+
seriesList.forEach((tt, i) => {
|
|
88
|
+
if (i == 0)
|
|
89
|
+
return;
|
|
90
|
+
tt.style.display = "none";
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function showTips() {
|
|
94
|
+
ttContainer.style.display = "block";
|
|
95
|
+
seriesList.forEach((line, i) => {
|
|
96
|
+
if (i == 0)
|
|
97
|
+
return;
|
|
98
|
+
const s = u.series[i];
|
|
99
|
+
line.style.display = s.show ? "block" : "none";
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
over.addEventListener("mouseleave", () => {
|
|
103
|
+
if (!u.cursor.lock)
|
|
104
|
+
hideTips();
|
|
105
|
+
});
|
|
106
|
+
over.addEventListener("mouseenter", () => {
|
|
107
|
+
showTips();
|
|
108
|
+
});
|
|
109
|
+
if (u.cursor.left < 0) {
|
|
110
|
+
setTimeout(() => hideTips());
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
showTips();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function setCursor(u) {
|
|
117
|
+
const { left, top, idx } = u.cursor;
|
|
118
|
+
if (idx == null)
|
|
119
|
+
return;
|
|
120
|
+
uPlotCursorConfig.set(left, top);
|
|
121
|
+
seriesList.forEach((tt, i) => {
|
|
122
|
+
if (i == 0)
|
|
123
|
+
return;
|
|
124
|
+
const s = u.series[i];
|
|
125
|
+
if (s.show) {
|
|
126
|
+
const xVal = u.data[0][idx];
|
|
127
|
+
const yVal = u.data[i][idx];
|
|
128
|
+
if (yVal === null) {
|
|
129
|
+
tt.style.display = "none";
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
tt.style.display = "block";
|
|
133
|
+
let label = u.series[i].label;
|
|
134
|
+
label = label?.substring(label.indexOf("(") + 1, label.indexOf(")")) || label;
|
|
135
|
+
ttHeader.textContent = format(fromUnixTime(xVal), "MMM d, yyyy h:mm a");
|
|
136
|
+
tt.textContent = `${label}: ${yVal}`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
const hasContent = !!seriesList
|
|
141
|
+
.slice(1, seriesList.length)
|
|
142
|
+
.find((tt) => tt.style.display === "block");
|
|
143
|
+
if (!hasContent) {
|
|
144
|
+
ttContainer.style.display = "none";
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
ttContainer.style.display = "block";
|
|
148
|
+
const offset = 15;
|
|
149
|
+
const ttWidth = ttContainer.offsetWidth;
|
|
150
|
+
const chartWidth = u.over.offsetWidth;
|
|
151
|
+
const overflowsRight = left + offset + ttWidth > chartWidth;
|
|
152
|
+
ttContainer.style.left = overflowsRight
|
|
153
|
+
? `${left - offset - ttWidth}px`
|
|
154
|
+
: `${left + offset}px`;
|
|
155
|
+
ttContainer.style.top = top + "px";
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
hooks: {
|
|
159
|
+
init,
|
|
160
|
+
setCursor
|
|
161
|
+
}
|
|
162
|
+
};
|
|
99
163
|
}
|
|
100
|
-
//#endregion
|
|
101
|
-
export { u as tooltipsPlugin, o as uPlotCursorConfig };
|