@oicl/openbridge-webcomponents 2.0.0-next.94 → 2.0.0-next.95
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/bundle/openbridge-webcomponents.bundle.js +153 -23
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +66 -49
- package/dist/building-blocks/chart-line/chart-line-base.d.ts +95 -33
- package/dist/building-blocks/chart-line/chart-line-base.d.ts.map +1 -1
- package/dist/building-blocks/chart-line/chart-line-base.js +88 -23
- package/dist/building-blocks/chart-line/chart-line-base.js.map +1 -1
- package/dist/charthelpers/index.d.ts +1 -0
- package/dist/charthelpers/index.d.ts.map +1 -1
- package/dist/charthelpers/index.js +4 -0
- package/dist/charthelpers/index.js.map +1 -1
- package/dist/charthelpers/x-value.d.ts +72 -0
- package/dist/charthelpers/x-value.d.ts.map +1 -0
- package/dist/charthelpers/x-value.js +60 -0
- package/dist/charthelpers/x-value.js.map +1 -0
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts +16 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.d.ts.map +1 -1
- package/dist/navigation-instruments/gauge-trend/gauge-trend.js +12 -0
- package/dist/navigation-instruments/gauge-trend/gauge-trend.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart-line-base.d.ts","sourceRoot":"","sources":["../../../src/building-blocks/chart-line/chart-line-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,cAAc,EAAkB,MAAM,KAAK,CAAC;AAkBhE,OAAO,KAAK,EAAC,YAAY,EAAE,YAAY,EAAqB,MAAM,UAAU,CAAC;AAC7E,OAAO,EACL,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACT,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"chart-line-base.d.ts","sourceRoot":"","sources":["../../../src/building-blocks/chart-line/chart-line-base.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MAAM,CAAC,EAAE;;IAcvD;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,YAAY,CAAC,MAAM,CAAC;IAwIjD;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAyC5B;;;;;;;;OAQG;IACH,SAAS,CAAC,iBAAiB,CACzB,IAAI,CAAC,EAAE,MAAM,EACb,UAAU,UAAQ,EAClB,aAAa,UAAO,GA2HG,YAAY,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC;IAGvD;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAUjC,OAAO,CAAC,WAAW;IA2BnB,OAAO,CAAC,WAAW;IAmBnB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;IACH,OAAO,CAAC,YAAY;IAqDX,MAAM;IAgCf,OAAgB,MAAM,4BAKpB;CACH"}
|
|
@@ -12,6 +12,7 @@ import { observeThemeChanges } from "../../charthelpers/theme.js";
|
|
|
12
12
|
import { formatNumericValue } from "../../charthelpers/canvas-layout.js";
|
|
13
13
|
import { getChartTooltipOptions } from "../../charthelpers/tooltip.js";
|
|
14
14
|
import { generateLegendHTML } from "../../charthelpers/legend.js";
|
|
15
|
+
import { XValueMode, normalizeXValue, formatXValue } from "../../charthelpers/x-value.js";
|
|
15
16
|
import { readExternalScaleBorderRadiusPx, ScaleType, startExternalScaleBorderRadiusObserver, EXTERNAL_SCALE_BORDER_RADIUS_CSS_VAR } from "../external-scale/external-scale.js";
|
|
16
17
|
var __defProp = Object.defineProperty;
|
|
17
18
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
@@ -36,6 +37,7 @@ Chart.register(
|
|
|
36
37
|
var XAxisType = /* @__PURE__ */ ((XAxisType2) => {
|
|
37
38
|
XAxisType2["category"] = "category";
|
|
38
39
|
XAxisType2["time"] = "time";
|
|
40
|
+
XAxisType2["number"] = "number";
|
|
39
41
|
return XAxisType2;
|
|
40
42
|
})(XAxisType || {});
|
|
41
43
|
var YAxisPosition = /* @__PURE__ */ ((YAxisPosition2) => {
|
|
@@ -178,6 +180,23 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
178
180
|
}, 16);
|
|
179
181
|
};
|
|
180
182
|
}
|
|
183
|
+
/** @internal - True when the x-axis positions points by numeric value. */
|
|
184
|
+
get isNumericXAxis() {
|
|
185
|
+
return this.xAxisType === "time" || this.xAxisType === "number";
|
|
186
|
+
}
|
|
187
|
+
/** @internal - Normalization mode for the current x-axis type. */
|
|
188
|
+
get xValueMode() {
|
|
189
|
+
return this.xAxisType === "number" ? XValueMode.number : XValueMode.time;
|
|
190
|
+
}
|
|
191
|
+
/** @internal - Warn once per data assignment about unparseable x-values. */
|
|
192
|
+
warnOnInvalidX(xValues, sourceRef) {
|
|
193
|
+
const invalid = xValues.filter((x) => !Number.isFinite(x)).length;
|
|
194
|
+
if (invalid === 0 || this.lastWarnedXSource === sourceRef) return;
|
|
195
|
+
this.lastWarnedXSource = sourceRef;
|
|
196
|
+
console.warn(
|
|
197
|
+
`[obc-chart] ${invalid} x value(s) could not be parsed for xAxisType='${this.xAxisType}'; the points render as gaps.`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
181
200
|
/**
|
|
182
201
|
* Should fill be applied to this chart?
|
|
183
202
|
* Line graph returns false, area graph returns true.
|
|
@@ -1014,8 +1033,8 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1014
1033
|
*/
|
|
1015
1034
|
buildDataset(data, index, chartColors, totalCount = 1) {
|
|
1016
1035
|
const currentColor = chartColors[index % chartColors.length];
|
|
1017
|
-
const existingDataset =
|
|
1018
|
-
const values =
|
|
1036
|
+
const existingDataset = Array.isArray(data) ? null : data;
|
|
1037
|
+
const values = Array.isArray(data) ? data : null;
|
|
1019
1038
|
const borderColor = existingDataset?.borderColor ?? currentColor;
|
|
1020
1039
|
const fillFlag = existingDataset?.fill ?? this.shouldApplyFill();
|
|
1021
1040
|
const tension = this.lineMode === "smooth" ? this.DEFAULT_TENSION : 0;
|
|
@@ -1063,14 +1082,18 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1063
1082
|
return result;
|
|
1064
1083
|
}
|
|
1065
1084
|
/**
|
|
1066
|
-
* Create threshold mode datasets: invisible baseline + main dataset with
|
|
1085
|
+
* Create threshold mode datasets: invisible baseline + main dataset with
|
|
1086
|
+
* above/below fills. Accepts plain values (category mode) or {x, y} points
|
|
1087
|
+
* (time/number mode); the baseline mirrors the input x-positions.
|
|
1067
1088
|
*/
|
|
1068
1089
|
createThresholdDatasets(values, chartColors) {
|
|
1069
|
-
const
|
|
1070
|
-
const minV =
|
|
1071
|
-
const maxV =
|
|
1090
|
+
const yValues = values.map((v) => typeof v === "number" ? v : v.y).filter((n) => Number.isFinite(n));
|
|
1091
|
+
const minV = yValues.length ? Math.min(...yValues) : 0;
|
|
1092
|
+
const maxV = yValues.length ? Math.max(...yValues) : 100;
|
|
1072
1093
|
const threshold = (minV + maxV) / 2;
|
|
1073
|
-
const baselineData =
|
|
1094
|
+
const baselineData = values.map(
|
|
1095
|
+
(v) => typeof v === "number" ? threshold : { x: v.x, y: threshold }
|
|
1096
|
+
);
|
|
1074
1097
|
const lowRaw = LINE_GRAPH_GRID_CONFIG.thresholdLowColorVar;
|
|
1075
1098
|
const highRaw = LINE_GRAPH_GRID_CONFIG.thresholdHighColorVar;
|
|
1076
1099
|
const highFill = applyAlphaToColor(this, highRaw, 0.35);
|
|
@@ -1096,7 +1119,9 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1096
1119
|
return [baselineDataset, main];
|
|
1097
1120
|
}
|
|
1098
1121
|
/**
|
|
1099
|
-
* Prepare normalized datasets for multi-series charts
|
|
1122
|
+
* Prepare normalized datasets for multi-series charts.
|
|
1123
|
+
* In time/number mode every point's x is normalized (epoch ms / number)
|
|
1124
|
+
* so strings, Dates and Temporal objects position correctly.
|
|
1100
1125
|
*/
|
|
1101
1126
|
prepareMultiSeriesDatasets() {
|
|
1102
1127
|
const defaultPalette = this.priority === Priority.enhanced ? CHART_SECTOR_ENHANCED_COLORS : CHART_SECTOR_DEFAULT_COLORS;
|
|
@@ -1105,18 +1130,37 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1105
1130
|
this.colors,
|
|
1106
1131
|
defaultPalette
|
|
1107
1132
|
);
|
|
1133
|
+
const normalized = this.datasets.map((ds) => this.normalizeDatasetX(ds));
|
|
1134
|
+
if (this.isNumericXAxis) {
|
|
1135
|
+
this.warnOnInvalidX(
|
|
1136
|
+
normalized.flatMap(
|
|
1137
|
+
(ds) => (ds.data ?? []).map(
|
|
1138
|
+
(pt) => pt && typeof pt === "object" ? pt.x : 0
|
|
1139
|
+
)
|
|
1140
|
+
),
|
|
1141
|
+
this.datasets
|
|
1142
|
+
);
|
|
1143
|
+
}
|
|
1108
1144
|
const totalCount = this.datasets.length;
|
|
1109
|
-
return
|
|
1145
|
+
return normalized.map(
|
|
1110
1146
|
(ds, i) => this.buildDataset(ds, i, chartColors, totalCount)
|
|
1111
1147
|
);
|
|
1112
1148
|
}
|
|
1149
|
+
/** @internal - Return a copy of the dataset with normalized point x-values. */
|
|
1150
|
+
normalizeDatasetX(ds) {
|
|
1151
|
+
if (!this.isNumericXAxis || !ds.data) return ds;
|
|
1152
|
+
const data = ds.data.map(
|
|
1153
|
+
(pt) => pt && typeof pt === "object" && "x" in pt ? { ...pt, x: normalizeXValue(pt.x, this.xValueMode) } : pt
|
|
1154
|
+
);
|
|
1155
|
+
return { ...ds, data };
|
|
1156
|
+
}
|
|
1113
1157
|
/**
|
|
1114
|
-
* Prepare datasets for single-series charts
|
|
1115
|
-
*
|
|
1158
|
+
* Prepare datasets for single-series charts.
|
|
1159
|
+
* Category mode: labels + numeric values (unchanged legacy path).
|
|
1160
|
+
* Time/number mode: normalized {x, y} points on a linear scale.
|
|
1161
|
+
* Handles both regular and threshold fill modes.
|
|
1116
1162
|
*/
|
|
1117
1163
|
prepareSingleSeriesDatasets() {
|
|
1118
|
-
const values = this.data.map((d) => d.value);
|
|
1119
|
-
const labels = this.data.map((d) => d.label);
|
|
1120
1164
|
const defaultPalette = this.priority === Priority.enhanced ? CHART_SECTOR_ENHANCED_COLORS : CHART_SECTOR_DEFAULT_COLORS;
|
|
1121
1165
|
const chartColors = getChartColorsOrDefault(
|
|
1122
1166
|
this,
|
|
@@ -1125,6 +1169,20 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1125
1169
|
);
|
|
1126
1170
|
const fill = this.shouldApplyFill();
|
|
1127
1171
|
const fillMode = this.getFillMode();
|
|
1172
|
+
if (this.isNumericXAxis) {
|
|
1173
|
+
const points = this.data.map((d) => ({
|
|
1174
|
+
x: normalizeXValue(d.x ?? d.label ?? NaN, this.xValueMode),
|
|
1175
|
+
y: d.value
|
|
1176
|
+
}));
|
|
1177
|
+
this.warnOnInvalidX(
|
|
1178
|
+
points.map((p) => p.x),
|
|
1179
|
+
this.data
|
|
1180
|
+
);
|
|
1181
|
+
const datasets2 = fill && fillMode === "threshold" ? this.createThresholdDatasets(points, chartColors) : [this.buildDataset(points, 0, chartColors)];
|
|
1182
|
+
return { datasets: datasets2, labels: [] };
|
|
1183
|
+
}
|
|
1184
|
+
const values = this.data.map((d) => d.value);
|
|
1185
|
+
const labels = this.data.map((d) => d.label ?? String(d.x ?? ""));
|
|
1128
1186
|
const datasets = fill && fillMode === "threshold" ? this.createThresholdDatasets(values, chartColors) : [this.buildDataset(values, 0, chartColors)];
|
|
1129
1187
|
return { datasets, labels };
|
|
1130
1188
|
}
|
|
@@ -1189,10 +1247,15 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1189
1247
|
callbacks: {
|
|
1190
1248
|
title: () => "",
|
|
1191
1249
|
label: (context) => {
|
|
1192
|
-
const label = context.label ?? "";
|
|
1193
1250
|
const value = typeof context.parsed === "object" && context.parsed !== null ? context.parsed.y : context.parsed;
|
|
1194
1251
|
const numericValue = formatNumericValue(value, 1, false, 0);
|
|
1195
1252
|
const unit = this.unit ? `${this.unit}` : "";
|
|
1253
|
+
let label = context.label ?? "";
|
|
1254
|
+
if (this.isNumericXAxis) {
|
|
1255
|
+
const x = typeof context.parsed === "object" && context.parsed !== null ? context.parsed.x : NaN;
|
|
1256
|
+
const relativeTo = this.timeDisplay === "minutes" ? refTs : void 0;
|
|
1257
|
+
label = formatXValue(x, this.xValueMode, relativeTo);
|
|
1258
|
+
}
|
|
1196
1259
|
return `${label} ${numericValue}${unit}`;
|
|
1197
1260
|
}
|
|
1198
1261
|
}
|
|
@@ -1207,18 +1270,23 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1207
1270
|
* Returns earliest timestamp for 'date' mode, latest for 'minutes' mode.
|
|
1208
1271
|
*/
|
|
1209
1272
|
computeTimeReference() {
|
|
1273
|
+
if (this.xAxisType !== "time") return void 0;
|
|
1210
1274
|
const timestamps = [];
|
|
1211
1275
|
if (this.datasets?.length) {
|
|
1212
1276
|
this.datasets.forEach((ds) => {
|
|
1213
1277
|
if (!ds.data) return;
|
|
1214
1278
|
ds.data.forEach((pt) => {
|
|
1215
1279
|
if (pt && typeof pt === "object" && "x" in pt) {
|
|
1216
|
-
const
|
|
1217
|
-
const ts = typeof xVal === "string" ? new Date(String(xVal)).getTime() : Number(xVal);
|
|
1280
|
+
const ts = normalizeXValue(pt.x, XValueMode.time);
|
|
1218
1281
|
if (Number.isFinite(ts)) timestamps.push(ts);
|
|
1219
1282
|
}
|
|
1220
1283
|
});
|
|
1221
1284
|
});
|
|
1285
|
+
} else if (this.data?.length) {
|
|
1286
|
+
this.data.forEach((d) => {
|
|
1287
|
+
const ts = normalizeXValue(d.x ?? d.label ?? NaN, XValueMode.time);
|
|
1288
|
+
if (Number.isFinite(ts)) timestamps.push(ts);
|
|
1289
|
+
});
|
|
1222
1290
|
}
|
|
1223
1291
|
if (!timestamps.length && this.labels?.length) {
|
|
1224
1292
|
this.labels.forEach((l) => {
|
|
@@ -1268,7 +1336,7 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1268
1336
|
const showTicks = showTickMarks && !isTooSmall && this.hasLabelPadding;
|
|
1269
1337
|
const fontConfig = { family: fontFamily, size: fontSize, weight: fontWeight };
|
|
1270
1338
|
const x = {
|
|
1271
|
-
type: this.xAxisType === "
|
|
1339
|
+
type: this.xAxisType === "category" ? "category" : "linear",
|
|
1272
1340
|
offset: false,
|
|
1273
1341
|
// Always edge-to-edge (no padding on x-axis)
|
|
1274
1342
|
grace: 0,
|
|
@@ -1292,14 +1360,11 @@ const _ObcChartLineBase = class _ObcChartLineBase extends LitElement {
|
|
|
1292
1360
|
maxTicksLimit: this.xTicksLimit,
|
|
1293
1361
|
stepSize: this.xStepSize,
|
|
1294
1362
|
callback: (value) => {
|
|
1295
|
-
if (this.
|
|
1363
|
+
if (!this.isNumericXAxis) return String(value);
|
|
1296
1364
|
const n = Number(value);
|
|
1297
1365
|
if (!Number.isFinite(n)) return String(value);
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return `${minutes}min`;
|
|
1301
|
-
}
|
|
1302
|
-
return new Date(n).toLocaleDateString();
|
|
1366
|
+
const relativeTo = this.timeDisplay === "minutes" ? minX : void 0;
|
|
1367
|
+
return formatXValue(n, this.xValueMode, relativeTo);
|
|
1303
1368
|
}
|
|
1304
1369
|
},
|
|
1305
1370
|
border: {
|