@opengeoweb/time-series 21.0.0 → 21.1.0

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/index.esm.js CHANGED
@@ -7315,10 +7315,34 @@ var TimeSeriesMarkersSwitch = function TimeSeriesMarkersSwitch(_ref) {
7315
7315
  });
7316
7316
  };
7317
7317
 
7318
- var MIN_GRAPH_WIDTH = 300;
7319
- var dateFormatter = function dateFormatter(date) {
7320
- return dateUtils.dateToString(dateUtils.utc(date), 'eee HH:mm');
7318
+ /* *
7319
+ * Licensed under the Apache License, Version 2.0 (the "License");
7320
+ * you may not use this file except in compliance with the License.
7321
+ * You may obtain a copy of the License at
7322
+ *
7323
+ * http://www.apache.org/licenses/LICENSE-2.0
7324
+ *
7325
+ * Unless required by applicable law or agreed to in writing, software
7326
+ * distributed under the License is distributed on an "AS IS" BASIS,
7327
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7328
+ * See the License for the specific language governing permissions and
7329
+ * limitations under the License.
7330
+ *
7331
+ * Copyright 2026 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7332
+ * Copyright 2026 - Finnish Meteorological Institute (FMI)
7333
+ * Copyright 2026 - The Norwegian Meteorological Institute (MET Norway)
7334
+ * */
7335
+ var dateFormatter = function dateFormatter(date, format) {
7336
+ var _dateUtils$dateToStri;
7337
+ if (format === void 0) {
7338
+ format = 'eee HH:mm';
7339
+ }
7340
+ // The zoombar can request labels before the time axis has any data.
7341
+ var parsedDate = typeof date === 'number' ? new Date(date) : dateUtils.getUtcFromString(date);
7342
+ return (_dateUtils$dateToStri = dateUtils.dateToString(parsedDate, format)) != null ? _dateUtils$dateToStri : '';
7321
7343
  };
7344
+
7345
+ var MIN_GRAPH_WIDTH = 300;
7322
7346
  var getTooltipTimeLabel = function getTooltipTimeLabel(date) {
7323
7347
  return dateUtils.dateToString(dateUtils.utc(date), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH);
7324
7348
  };
@@ -7489,6 +7513,9 @@ var getYAxis = function getYAxis(plotCharts) {
7489
7513
  // still show the axis, but without min/max if there is no data
7490
7514
  return {
7491
7515
  type: 'value',
7516
+ splitLine: {
7517
+ show: true
7518
+ },
7492
7519
  position: position,
7493
7520
  axisTick: {
7494
7521
  show: false
@@ -7523,6 +7550,9 @@ var getYAxis = function getYAxis(plotCharts) {
7523
7550
  }
7524
7551
  return {
7525
7552
  type: 'value',
7553
+ splitLine: {
7554
+ show: true
7555
+ },
7526
7556
  position: position,
7527
7557
  axisTick: {
7528
7558
  show: true
@@ -7551,15 +7581,19 @@ var getXAxis = function getXAxis(plotCharts) {
7551
7581
  return plotCharts.map(function (_plotChart, index) {
7552
7582
  if (index === plotCharts.length - 1) {
7553
7583
  return {
7554
- type: 'category',
7584
+ type: 'time',
7585
+ min: 'dataMin',
7586
+ max: 'dataMax',
7587
+ splitLine: {
7588
+ show: false
7589
+ },
7555
7590
  gridIndex: index,
7591
+ // Labels and ticks share the vertical gridline timestamps in the overlay.
7556
7592
  axisLabel: {
7557
- formatter: dateFormatter,
7558
- hideOverlap: true
7593
+ show: false
7559
7594
  },
7560
7595
  axisTick: {
7561
- show: true,
7562
- alignWithLabel: true
7596
+ show: false
7563
7597
  },
7564
7598
  axisLine: {
7565
7599
  onZero: false
@@ -7570,7 +7604,12 @@ var getXAxis = function getXAxis(plotCharts) {
7570
7604
  }
7571
7605
  return {
7572
7606
  gridIndex: index,
7573
- type: 'category',
7607
+ type: 'time',
7608
+ min: 'dataMin',
7609
+ max: 'dataMax',
7610
+ splitLine: {
7611
+ show: false
7612
+ },
7574
7613
  show: false,
7575
7614
  containShape: false
7576
7615
  };
@@ -7684,10 +7723,13 @@ var getZoomPreviewPlot = function getZoomPreviewPlot(plots) {
7684
7723
  }]
7685
7724
  };
7686
7725
  };
7687
- var getOption = function getOption(plotsWithData, shouldShowLegend, sharedTimesteps) {
7726
+ var getOption = function getOption(plotsWithData, shouldShowLegend, sharedTimesteps, formatZoomLabel) {
7688
7727
  if (shouldShowLegend === void 0) {
7689
7728
  shouldShowLegend = true;
7690
7729
  }
7730
+ if (formatZoomLabel === void 0) {
7731
+ formatZoomLabel = dateFormatter;
7732
+ }
7691
7733
  var parameterNames = createParameterNames(plotsWithData);
7692
7734
  var plotCharts = getPlotCharts(plotsWithData);
7693
7735
  var xAxis = getXAxis(plotCharts).map(function (axis) {
@@ -7741,6 +7783,7 @@ var getOption = function getOption(plotsWithData, shouldShowLegend, sharedTimest
7741
7783
  });
7742
7784
  var dataZoomLabelWidth = 70;
7743
7785
  var option = {
7786
+ useUTC: true,
7744
7787
  legend: legend,
7745
7788
  tooltip: tooltip,
7746
7789
  axisPointer: {
@@ -7757,8 +7800,8 @@ var getOption = function getOption(plotsWithData, shouldShowLegend, sharedTimest
7757
7800
  xAxisIndex: plotCharts.map(function (_, index) {
7758
7801
  return index;
7759
7802
  }),
7760
- labelFormatter: function labelFormatter(_, date) {
7761
- return dateFormatter(date);
7803
+ labelFormatter: function labelFormatter(value) {
7804
+ return formatZoomLabel(value);
7762
7805
  },
7763
7806
  // Visual styling (colors, handles, data background) is provided by the
7764
7807
  // EChartsLightTheme / EChartsDarkTheme `dataZoom` config so it stays
@@ -7973,24 +8016,8 @@ var useCurrentTime = function useCurrentTime(enabled) {
7973
8016
  }, [enabled]);
7974
8017
  return now;
7975
8018
  };
7976
- /** Fractional category index, preserving the spacing of the chart's time axis. */
7977
- var getCurrentTimeIndex = function getCurrentTimeIndex(timestamps, currentTime) {
7978
- if (!Number.isFinite(currentTime) || !timestamps.length || currentTime < timestamps[0] || currentTime > timestamps[timestamps.length - 1]) {
7979
- return undefined;
7980
- }
7981
- var next = timestamps.findIndex(function (time) {
7982
- return time >= currentTime;
7983
- });
7984
- if (next < 0) {
7985
- return undefined;
7986
- }
7987
- if (next === 0 || timestamps[next] === currentTime) {
7988
- return next;
7989
- }
7990
- return next - 1 + (currentTime - timestamps[next - 1]) / (timestamps[next] - timestamps[next - 1]);
7991
- };
7992
8019
  var getCurrentTimeLines = function getCurrentTimeLines(instance, currentTime, showPlots, showZoom) {
7993
- if (instance.isDisposed()) {
8020
+ if (instance.isDisposed() || !Number.isFinite(currentTime)) {
7994
8021
  return [];
7995
8022
  }
7996
8023
  var api = instance;
@@ -8000,28 +8027,18 @@ var getCurrentTimeLines = function getCurrentTimeLines(instance, currentTime, sh
8000
8027
  }
8001
8028
  var lines = [];
8002
8029
  model.eachComponent('xAxis', function (axis) {
8003
- var timestamps = axis.getCategories().map(function (time) {
8004
- return Date.parse(time);
8005
- });
8006
- var index = getCurrentTimeIndex(timestamps, currentTime);
8007
- if (index === undefined) {
8030
+ if (axis.axis.scale.isBlank()) {
8008
8031
  return;
8009
8032
  }
8010
8033
  var _axis$axis$scale$getE = axis.axis.scale.getExtent(),
8011
8034
  min = _axis$axis$scale$getE[0],
8012
8035
  max = _axis$axis$scale$getE[1];
8013
- if (showPlots && index >= min && index <= max) {
8036
+ if (showPlots && currentTime >= min && currentTime <= max) {
8014
8037
  var _model$getComponent;
8015
8038
  var rect = (_model$getComponent = model.getComponent('grid', axis.get('gridIndex'))) == null || (_model$getComponent = _model$getComponent.coordinateSystem) == null ? void 0 : _model$getComponent.getRect();
8016
- var lower = Math.floor(index);
8017
- var upper = Math.ceil(index);
8018
- var left = instance.convertToPixel({
8039
+ var x = instance.convertToPixel({
8019
8040
  xAxisIndex: axis.componentIndex
8020
- }, lower);
8021
- var right = instance.convertToPixel({
8022
- xAxisIndex: axis.componentIndex
8023
- }, upper);
8024
- var x = left + (right - left) * (index - lower);
8041
+ }, currentTime);
8025
8042
  if (rect && Number.isFinite(x) && x >= rect.x && x <= rect.x + rect.width) {
8026
8043
  lines.push({
8027
8044
  id: "plot-" + axis.componentIndex,
@@ -8032,17 +8049,20 @@ var getCurrentTimeLines = function getCurrentTimeLines(instance, currentTime, sh
8032
8049
  }
8033
8050
  }
8034
8051
  if (showZoom && axis.componentIndex === 0) {
8035
- var _displayables$sliderG;
8052
+ var _displayables$sliderG, _zoom$getAxisProxy;
8036
8053
  var zoom = model.getComponent('dataZoom', 0);
8037
8054
  var view = zoom && zoom.get('show') && api.getViewOfComponentModel(zoom);
8038
8055
  var _ref = view || {},
8039
8056
  displayables = _ref._displayables;
8040
8057
  var background = displayables == null || (_displayables$sliderG = displayables.sliderGroup) == null ? void 0 : _displayables$sliderG.childAt(0);
8041
- if (background) {
8058
+ // The proxy retains the full axis extent while the scale is zoomed.
8059
+ var _ref2 = (_zoom$getAxisProxy = zoom == null || zoom.getAxisProxy == null ? void 0 : zoom.getAxisProxy('x', axis.componentIndex)) != null ? _zoom$getAxisProxy : {},
8060
+ extent = _ref2._extent;
8061
+ if (background && extent && extent.every(Number.isFinite) && currentTime >= extent[0] && currentTime <= extent[1]) {
8042
8062
  background.getComputedTransform();
8043
8063
  var start = background.transformCoordToGlobal(0, 0);
8044
8064
  var end = background.transformCoordToGlobal(background.shape.width, background.shape.height);
8045
- var fraction = timestamps.length === 1 ? 0.5 : index / (timestamps.length - 1);
8065
+ var fraction = extent[0] === extent[1] ? 0.5 : (currentTime - extent[0]) / (extent[1] - extent[0]);
8046
8066
  lines.push({
8047
8067
  id: 'zoom',
8048
8068
  x: start[0] + fraction * (end[0] - start[0]),
@@ -8054,11 +8074,11 @@ var getCurrentTimeLines = function getCurrentTimeLines(instance, currentTime, sh
8054
8074
  });
8055
8075
  return lines;
8056
8076
  };
8057
- var CurrentTime = function CurrentTime(_ref2) {
8058
- var instance = _ref2.instance,
8059
- currentTime = _ref2.currentTime,
8060
- showPlots = _ref2.showPlots,
8061
- showZoom = _ref2.showZoom;
8077
+ var CurrentTime = function CurrentTime(_ref3) {
8078
+ var instance = _ref3.instance,
8079
+ currentTime = _ref3.currentTime,
8080
+ showPlots = _ref3.showPlots,
8081
+ showZoom = _ref3.showZoom;
8062
8082
  var theme = useTheme();
8063
8083
  var _React$useState2 = React.useState([]),
8064
8084
  lines = _React$useState2[0],
@@ -8095,11 +8115,11 @@ var CurrentTime = function CurrentTime(_ref2) {
8095
8115
  pointerEvents: 'none',
8096
8116
  overflow: 'hidden'
8097
8117
  },
8098
- children: lines.map(function (_ref3) {
8099
- var id = _ref3.id,
8100
- x = _ref3.x,
8101
- y = _ref3.y,
8102
- height = _ref3.height;
8118
+ children: lines.map(function (_ref4) {
8119
+ var id = _ref4.id,
8120
+ x = _ref4.x,
8121
+ y = _ref4.y,
8122
+ height = _ref4.height;
8103
8123
  return jsxs("g", {
8104
8124
  children: [jsx("line", {
8105
8125
  stroke: playerNeedleTime.rgba,
@@ -8121,6 +8141,149 @@ var CurrentTime = function CurrentTime(_ref2) {
8121
8141
  });
8122
8142
  };
8123
8143
 
8144
+ /* *
8145
+ * Licensed under the Apache License, Version 2.0 (the "License");
8146
+ * you may not use this file except in compliance with the License.
8147
+ * You may obtain a copy of the License at
8148
+ *
8149
+ * http://www.apache.org/licenses/LICENSE-2.0
8150
+ *
8151
+ * Unless required by applicable law or agreed to in writing, software
8152
+ * distributed under the License is distributed on an "AS IS" BASIS,
8153
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8154
+ * See the License for the specific language governing permissions and
8155
+ * limitations under the License.
8156
+ *
8157
+ * Copyright 2026 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
8158
+ * Copyright 2026 - Finnish Meteorological Institute (FMI)
8159
+ * Copyright 2026 - The Norwegian Meteorological Institute (MET Norway)
8160
+ * */
8161
+ var MINUTE = 60000;
8162
+ var HOUR = 60 * MINUTE;
8163
+ var DAY = 24 * HOUR;
8164
+ // UTC calendar addition, clamping month-end dates rather than overflowing.
8165
+ var addMonths = function addMonths(timestamp, months) {
8166
+ var date = new Date(timestamp);
8167
+ var day = date.getUTCDate();
8168
+ date.setUTCDate(1);
8169
+ date.setUTCMonth(date.getUTCMonth() + months);
8170
+ var lastDay = new Date(date.getTime());
8171
+ lastDay.setUTCMonth(lastDay.getUTCMonth() + 1, 0);
8172
+ date.setUTCDate(Math.min(day, lastDay.getUTCDate()));
8173
+ return date.getTime();
8174
+ };
8175
+ var getGridlineInterval = function getGridlineInterval(start, end) {
8176
+ var duration = end - start;
8177
+ var bands = [[20 * MINUTE, MINUTE], [2 * HOUR, 10 * MINUTE], [4 * HOUR, 30 * MINUTE], [12 * HOUR, HOUR], [DAY, 3 * HOUR], [4 * DAY, 6 * HOUR], [7 * DAY, 12 * HOUR], [21 * DAY, DAY]];
8178
+ var band = bands.find(function (_ref) {
8179
+ var limit = _ref[0];
8180
+ return duration <= limit;
8181
+ });
8182
+ if (band) {
8183
+ return {
8184
+ milliseconds: band[1]
8185
+ };
8186
+ }
8187
+ if (end <= addMonths(start, 3)) {
8188
+ return {
8189
+ milliseconds: 7 * DAY
8190
+ };
8191
+ }
8192
+ return {
8193
+ months: end <= addMonths(start, 24) ? 1 : 6
8194
+ };
8195
+ };
8196
+ var getGridlineTimes = function getGridlineTimes(start, end) {
8197
+ if (!Number.isFinite(start) || !Number.isFinite(end) || end <= start) {
8198
+ return [];
8199
+ }
8200
+ var interval = getGridlineInterval(start, end);
8201
+ var times = [];
8202
+ if ('milliseconds' in interval) {
8203
+ // Unix epoch was Thursday; anchor seven-day lines to Monday midnight UTC.
8204
+ var anchor = interval.milliseconds === 7 * DAY ? 4 * DAY : 0;
8205
+ var first = Math.ceil((start - anchor) / interval.milliseconds) * interval.milliseconds + anchor;
8206
+ for (var time = first; time <= end; time += interval.milliseconds) {
8207
+ times.push(time);
8208
+ }
8209
+ } else {
8210
+ var date = new Date(start);
8211
+ date.setUTCDate(1);
8212
+ date.setUTCHours(0, 0, 0, 0);
8213
+ date.setUTCMonth(Math.floor(date.getUTCMonth() / interval.months) * interval.months);
8214
+ while (date.getTime() < start) {
8215
+ date.setUTCMonth(date.getUTCMonth() + interval.months);
8216
+ }
8217
+ while (date.getTime() <= end) {
8218
+ times.push(date.getTime());
8219
+ date.setUTCMonth(date.getUTCMonth() + interval.months);
8220
+ }
8221
+ }
8222
+ return times;
8223
+ };
8224
+ var getGridlineLabel = function getGridlineLabel(timestamp, interval) {
8225
+ var formats = 'months' in interval ? ['MMM', 'yyyy'] : [interval.milliseconds < DAY * 7 ? 'eee' : 'dd MMM', 'HH:mm'];
8226
+ return [dateFormatter(timestamp, formats[0]), dateFormatter(timestamp, formats[1])];
8227
+ };
8228
+
8229
+ var getVisibleTimeRange = function getVisibleTimeRange(chart) {
8230
+ var _chart$getModel$getCo;
8231
+ if (!chart || chart.isDisposed()) {
8232
+ return undefined;
8233
+ }
8234
+ var axis = (_chart$getModel$getCo = chart.getModel().getComponent('xAxis', 0)) == null ? void 0 : _chart$getModel$getCo.axis;
8235
+ return axis && !axis.scale.isBlank() ? axis.scale.getExtent() : undefined;
8236
+ };
8237
+ var getVerticalGridlines = function getVerticalGridlines(chart, plotCount) {
8238
+ if (chart.isDisposed()) {
8239
+ return [];
8240
+ }
8241
+ var model = chart.getModel();
8242
+ var lines = [];
8243
+ for (var index = 0; index < plotCount; index += 1) {
8244
+ var _model$getComponent;
8245
+ var axis = (_model$getComponent = model.getComponent('xAxis', index)) == null ? void 0 : _model$getComponent.axis;
8246
+ if (axis && !axis.scale.isBlank()) {
8247
+ var _axis$scale$getExtent = axis.scale.getExtent(),
8248
+ start = _axis$scale$getExtent[0],
8249
+ end = _axis$scale$getExtent[1];
8250
+ var rect = axis.grid.getRect();
8251
+ var interval = getGridlineInterval(start, end);
8252
+ for (var _iterator = _createForOfIteratorHelperLoose(getGridlineTimes(start, end)), _step; !(_step = _iterator()).done;) {
8253
+ var timestamp = _step.value;
8254
+ var x = chart.convertToPixel({
8255
+ xAxisIndex: index
8256
+ }, timestamp);
8257
+ if (Number.isFinite(x) && x >= rect.x && x <= rect.x + rect.width) {
8258
+ lines.push(Object.assign({
8259
+ x: x,
8260
+ top: rect.y,
8261
+ bottom: rect.y + rect.height
8262
+ }, index === plotCount - 1 && {
8263
+ label: getGridlineLabel(timestamp, interval)
8264
+ }));
8265
+ }
8266
+ }
8267
+ }
8268
+ }
8269
+ return lines;
8270
+ };
8271
+ var useVerticalGridlines = function useVerticalGridlines(plotCount) {
8272
+ var _React$useState = React.useState([]),
8273
+ lines = _React$useState[0],
8274
+ setLines = _React$useState[1];
8275
+ var updateGridlines = React.useCallback(function (chart) {
8276
+ var next = getVerticalGridlines(chart, plotCount);
8277
+ setLines(function (previous) {
8278
+ return isEqual(previous, next) ? previous : next;
8279
+ });
8280
+ }, [plotCount]);
8281
+ return {
8282
+ lines: lines,
8283
+ updateGridlines: updateGridlines
8284
+ };
8285
+ };
8286
+
8124
8287
  // Guard: mocked ReactECharts (forwardRef) has no real prototype chain.
8125
8288
  var reactEChartsProto = ReactECharts.prototype;
8126
8289
  var echartsReactCoreProto = reactEChartsProto ? Object.getPrototypeOf(reactEChartsProto) : null;
@@ -8383,6 +8546,10 @@ var TimeSeriesChart = function TimeSeriesChart(_ref3) {
8383
8546
  };
8384
8547
  }, [synchronization]);
8385
8548
  var dataZoomStateRef = React.useRef(null);
8549
+ var formatZoomLabel = React.useCallback(function (timestamp) {
8550
+ var range = getVisibleTimeRange(registeredInstance.current);
8551
+ return range ? getGridlineLabel(timestamp, getGridlineInterval.apply(void 0, range)).filter(Boolean).join(' ') : dateFormatter(timestamp);
8552
+ }, []);
8386
8553
  var lastLegendEventRef = React.useRef(null);
8387
8554
  var enabledPlots = React.useMemo(function () {
8388
8555
  return plotsWithData.filter(function (plot) {
@@ -8390,7 +8557,7 @@ var TimeSeriesChart = function TimeSeriesChart(_ref3) {
8390
8557
  });
8391
8558
  }, [plotsWithData]);
8392
8559
  var option = React.useMemo(function () {
8393
- var base = getOption(controlsOnly === 'zoom' ? [getZoomPreviewPlot(enabledPlots)] : enabledPlots, shouldShowLegend, sharedTimesteps);
8560
+ var base = getOption(controlsOnly === 'zoom' ? [getZoomPreviewPlot(enabledPlots)] : enabledPlots, shouldShowLegend, sharedTimesteps, formatZoomLabel);
8394
8561
  var dataZoom = Array.isArray(base.dataZoom) ? base.dataZoom : [];
8395
8562
  if (!controlsOnly) {
8396
8563
  return Object.assign({}, base, {
@@ -8458,7 +8625,12 @@ var TimeSeriesChart = function TimeSeriesChart(_ref3) {
8458
8625
  });
8459
8626
  }) : []
8460
8627
  });
8461
- }, [enabledPlots, shouldShowLegend, shouldShowZoom, controlsOnly, sharedTimesteps]);
8628
+ }, [enabledPlots, shouldShowLegend, shouldShowZoom, controlsOnly, sharedTimesteps, formatZoomLabel]);
8629
+ var _useVerticalGridlines = useVerticalGridlines(controlsOnly ? 0 : enabledPlots.length),
8630
+ lines = _useVerticalGridlines.lines,
8631
+ updateGridlines = _useVerticalGridlines.updateGridlines;
8632
+ var timeAxisStyle = (isDark ? EChartsDarkTheme : EChartsLightTheme).timeAxis;
8633
+ var gridlineStyle = timeAxisStyle.splitLine.lineStyle;
8462
8634
  var optionWithZoom = React.useMemo(function () {
8463
8635
  var _synchronization$zoom;
8464
8636
  return applyDataZoomState(option, (_synchronization$zoom = synchronization == null ? void 0 : synchronization.zoomState.current) != null ? _synchronization$zoom : dataZoomStateRef.current);
@@ -8517,11 +8689,15 @@ var TimeSeriesChart = function TimeSeriesChart(_ref3) {
8517
8689
  synchronization == null || synchronization.register(instance, controlsOnly !== 'zoom');
8518
8690
  }
8519
8691
  updateHeight(instance);
8692
+ updateGridlines(instance);
8520
8693
  setIndicatorInstance(instance);
8521
8694
  },
8522
8695
  // noop, prevent flickering when toggling legend
8523
8696
  onEvents: {
8524
8697
  finished: function finished() {},
8698
+ rendered: function rendered(_params, chart) {
8699
+ updateGridlines(chart);
8700
+ },
8525
8701
  datazoom: function datazoom(params) {
8526
8702
  var newState = extractDataZoomState(params);
8527
8703
  if (newState) {
@@ -8565,6 +8741,52 @@ var TimeSeriesChart = function TimeSeriesChart(_ref3) {
8565
8741
  minWidth: fitToContainer ? 0 : MIN_GRAPH_WIDTH
8566
8742
  },
8567
8743
  theme: isDark ? EChartsDarkTheme : EChartsLightTheme
8744
+ }), jsx("svg", {
8745
+ "aria-hidden": "true",
8746
+ "data-testid": "TimeSeriesChart-gridlines",
8747
+ style: {
8748
+ position: 'absolute',
8749
+ inset: 0,
8750
+ width: '100%',
8751
+ height: '100%',
8752
+ pointerEvents: 'none'
8753
+ },
8754
+ children: lines.map(function (line) {
8755
+ return jsxs("g", {
8756
+ children: [jsx("line", {
8757
+ opacity: gridlineStyle.opacity,
8758
+ stroke: gridlineStyle.color[0],
8759
+ strokeWidth: 1,
8760
+ x1: line.x,
8761
+ x2: line.x,
8762
+ y1: line.top,
8763
+ y2: line.bottom
8764
+ }), line.label ? jsxs(Fragment, {
8765
+ children: [jsx("line", {
8766
+ stroke: timeAxisStyle.axisTick.lineStyle.color,
8767
+ x1: line.x,
8768
+ x2: line.x,
8769
+ y1: line.bottom,
8770
+ y2: line.bottom + 4
8771
+ }), jsxs("text", {
8772
+ "data-testid": "TimeSeriesChart-timeLabel",
8773
+ fill: timeAxisStyle.axisLabel.color,
8774
+ fontSize: timeAxisStyle.axisLabel.fontSize,
8775
+ textAnchor: "middle",
8776
+ x: line.x,
8777
+ y: line.bottom + 12,
8778
+ children: [jsx("tspan", {
8779
+ x: line.x,
8780
+ children: line.label[0]
8781
+ }), jsx("tspan", {
8782
+ dy: 10,
8783
+ x: line.x,
8784
+ children: line.label[1]
8785
+ })]
8786
+ })]
8787
+ }) : null]
8788
+ }, line.top + "-" + line.x);
8789
+ })
8568
8790
  }), controlsOnly !== 'legend' && jsx(CurrentTime, {
8569
8791
  currentTime: currentTime != null ? currentTime : now,
8570
8792
  instance: indicatorInstance,
@@ -2,8 +2,6 @@ import type { EChartsInstance } from 'echarts-for-react';
2
2
  import React from 'react';
3
3
  /** One clock per view; standalone charts can use their own clock. Times are milliseconds. */
4
4
  export declare const useCurrentTime: (enabled?: boolean) => number;
5
- /** Fractional category index, preserving the spacing of the chart's time axis. */
6
- export declare const getCurrentTimeIndex: (timestamps: number[], currentTime: number) => number | undefined;
7
5
  interface IndicatorLine {
8
6
  id: string;
9
7
  x: number;
@@ -1,7 +1,6 @@
1
1
  import type { EChartsOption, XAXisComponentOption, YAXisComponentOption, GridComponentOption, LineSeriesOption, BarSeriesOption, ScatterSeriesOption } from 'echarts';
2
2
  import type { ParameterWithData, Plot, PlotWithData } from './types';
3
3
  export declare const MIN_GRAPH_WIDTH = 300;
4
- export declare const dateFormatter: (date: string) => string;
5
4
  export declare const getTooltipTimeLabel: (date: string) => string;
6
5
  export declare const createParameterNames: (plotsWithData: PlotWithData[]) => {
7
6
  name: string;
@@ -25,7 +24,7 @@ export declare const roundDecimalValues: (value: number) => string;
25
24
  export declare const getSharedTimesteps: (plots: PlotWithData[]) => Date[];
26
25
  /** Build a unit-independent overview from visible, open plots and enabled parameters. */
27
26
  export declare const getZoomPreviewPlot: (plots: PlotWithData[]) => PlotWithData;
28
- export declare const getOption: (plotsWithData: PlotWithData[], shouldShowLegend?: boolean, sharedTimesteps?: Date[]) => EChartsOption;
27
+ export declare const getOption: (plotsWithData: PlotWithData[], shouldShowLegend?: boolean, sharedTimesteps?: Date[], formatZoomLabel?: (timestamp: number) => string) => EChartsOption;
29
28
  export declare const getEChartsSeriesDataByTimestep: (timesteps: Date[], parameter: ParameterWithData) => (number | string)[][];
30
29
  export declare const getSeries: (plotCharts: PlotChart[], parameterNames: {
31
30
  name: string;
@@ -0,0 +1 @@
1
+ export declare const dateFormatter: (date: string | number, format?: string) => string;
@@ -0,0 +1,14 @@
1
+ import type { EChartsInstance } from 'echarts-for-react';
2
+ interface Gridline {
3
+ x: number;
4
+ top: number;
5
+ bottom: number;
6
+ label?: [string, string];
7
+ }
8
+ export declare const getVisibleTimeRange: (chart: EChartsInstance | null) => [number, number] | undefined;
9
+ export declare const getVerticalGridlines: (chart: EChartsInstance, plotCount: number) => Gridline[];
10
+ export declare const useVerticalGridlines: (plotCount: number) => {
11
+ lines: Gridline[];
12
+ updateGridlines: (chart: EChartsInstance) => void;
13
+ };
14
+ export {};
@@ -0,0 +1,8 @@
1
+ export type GridlineInterval = {
2
+ milliseconds: number;
3
+ } | {
4
+ months: number;
5
+ };
6
+ export declare const getGridlineInterval: (start: number, end: number) => GridlineInterval;
7
+ export declare const getGridlineTimes: (start: number, end: number) => number[];
8
+ export declare const getGridlineLabel: (timestamp: number, interval: GridlineInterval) => [string, string];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/time-series",
3
- "version": "21.0.0",
3
+ "version": "21.1.0",
4
4
  "description": "GeoWeb time-series library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,26 +21,26 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "immer": "^10.0.3",
24
- "@opengeoweb/shared": "21.0.0",
24
+ "@opengeoweb/shared": "21.1.0",
25
25
  "@reduxjs/toolkit": "^2.6.1",
26
26
  "react-redux": "^9.2.0",
27
- "@opengeoweb/webmap": "21.0.0",
28
- "@opengeoweb/webmap-react": "21.0.0",
27
+ "@opengeoweb/webmap": "21.1.0",
28
+ "@opengeoweb/webmap-react": "21.1.0",
29
29
  "lodash": "^4.18.1",
30
- "@opengeoweb/api": "21.0.0",
31
- "@opengeoweb/authentication": "21.0.0",
32
- "@opengeoweb/theme": "21.0.0",
33
- "@opengeoweb/store": "21.0.0",
30
+ "@opengeoweb/api": "21.1.0",
31
+ "@opengeoweb/authentication": "21.1.0",
32
+ "@opengeoweb/theme": "21.1.0",
33
+ "@opengeoweb/store": "21.1.0",
34
34
  "echarts-for-react": "^3.0.6",
35
35
  "echarts": "^6.1.0",
36
36
  "react-sortablejs": "^6.1.4",
37
- "@opengeoweb/snackbar": "21.0.0",
37
+ "@opengeoweb/snackbar": "21.1.0",
38
38
  "react-window": "^2.2.6",
39
39
  "msw": "^2.7.3",
40
40
  "i18next": "^25.0.1",
41
41
  "react-i18next": "^15.1.1",
42
- "@opengeoweb/core": "21.0.0",
43
- "@opengeoweb/form-fields": "21.0.0",
42
+ "@opengeoweb/core": "21.1.0",
43
+ "@opengeoweb/form-fields": "21.1.0",
44
44
  "@mui/material": "^9.0.1",
45
45
  "react-hook-form": "^7.61.1",
46
46
  "uuid": "^11.1.1",