@opendata-ai/openchart-engine 2.4.0 → 2.5.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.d.ts +2 -0
- package/dist/index.js +15 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__test-fixtures__/specs.ts +3 -0
- package/src/charts/line/__tests__/compute.test.ts +109 -0
- package/src/charts/line/compute.ts +18 -6
- package/src/compiler/normalize.ts +1 -0
- package/src/compiler/types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,8 @@ interface NormalizedChartSpec {
|
|
|
180
180
|
darkMode: DarkMode;
|
|
181
181
|
/** Series names to hide from rendering. */
|
|
182
182
|
hiddenSeries: string[];
|
|
183
|
+
/** Per-series visual style overrides. */
|
|
184
|
+
seriesStyles: Record<string, _opendata_ai_openchart_core.SeriesStyle>;
|
|
183
185
|
}
|
|
184
186
|
/** A TableSpec with all optional fields filled with sensible defaults. */
|
|
185
187
|
interface NormalizedTableSpec {
|
package/dist/index.js
CHANGED
|
@@ -1299,27 +1299,35 @@ function computeLineMarks(spec, scales, _chartArea, _strategy) {
|
|
|
1299
1299
|
label: ariaLabel
|
|
1300
1300
|
};
|
|
1301
1301
|
const combinedPath = pathParts.join(" ");
|
|
1302
|
+
const seriesStyleKey = seriesKey === "__default__" ? void 0 : seriesKey;
|
|
1303
|
+
const styleOverride = seriesStyleKey ? spec.seriesStyles?.[seriesStyleKey] : void 0;
|
|
1304
|
+
let strokeDasharray;
|
|
1305
|
+
if (styleOverride?.lineStyle === "dashed") strokeDasharray = "6 4";
|
|
1306
|
+
else if (styleOverride?.lineStyle === "dotted") strokeDasharray = "2 3";
|
|
1302
1307
|
const lineMark = {
|
|
1303
1308
|
type: "line",
|
|
1304
1309
|
points: allPoints,
|
|
1305
1310
|
path: combinedPath,
|
|
1306
1311
|
stroke: color,
|
|
1307
|
-
strokeWidth: DEFAULT_STROKE_WIDTH,
|
|
1308
|
-
|
|
1312
|
+
strokeWidth: styleOverride?.strokeWidth ?? DEFAULT_STROKE_WIDTH,
|
|
1313
|
+
strokeDasharray,
|
|
1314
|
+
opacity: styleOverride?.opacity,
|
|
1315
|
+
seriesKey: seriesStyleKey,
|
|
1309
1316
|
data: pointsWithData.map((p) => p.row),
|
|
1310
1317
|
aria
|
|
1311
1318
|
};
|
|
1312
1319
|
marks.push(lineMark);
|
|
1320
|
+
const showPoints = styleOverride?.showPoints !== false;
|
|
1313
1321
|
for (let i = 0; i < pointsWithData.length; i++) {
|
|
1314
1322
|
const p = pointsWithData[i];
|
|
1315
1323
|
const pointMark = {
|
|
1316
1324
|
type: "point",
|
|
1317
1325
|
cx: p.x,
|
|
1318
1326
|
cy: p.y,
|
|
1319
|
-
r: DEFAULT_POINT_RADIUS,
|
|
1327
|
+
r: showPoints ? DEFAULT_POINT_RADIUS : 0,
|
|
1320
1328
|
fill: color,
|
|
1321
|
-
stroke: "#ffffff",
|
|
1322
|
-
strokeWidth: 1.5,
|
|
1329
|
+
stroke: showPoints ? "#ffffff" : "transparent",
|
|
1330
|
+
strokeWidth: showPoints ? 1.5 : 0,
|
|
1323
1331
|
fillOpacity: 0,
|
|
1324
1332
|
data: p.row,
|
|
1325
1333
|
aria: {
|
|
@@ -1899,7 +1907,8 @@ function normalizeChartSpec(spec, warnings) {
|
|
|
1899
1907
|
responsive: spec.responsive ?? true,
|
|
1900
1908
|
theme: spec.theme ?? {},
|
|
1901
1909
|
darkMode: spec.darkMode ?? "off",
|
|
1902
|
-
hiddenSeries: spec.hiddenSeries ?? []
|
|
1910
|
+
hiddenSeries: spec.hiddenSeries ?? [],
|
|
1911
|
+
seriesStyles: spec.seriesStyles ?? {}
|
|
1903
1912
|
};
|
|
1904
1913
|
}
|
|
1905
1914
|
function normalizeTableSpec(spec, _warnings) {
|