@opendata-ai/openchart-engine 9.7.1 → 9.8.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.js +17 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9712,7 +9712,7 @@ function resolveRampColors(channel, theme) {
|
|
|
9712
9712
|
const scheme = resolveThemeScheme(channel.scale.scheme, theme);
|
|
9713
9713
|
if (scheme) return channel.scale.reverse ? [...scheme].reverse() : scheme;
|
|
9714
9714
|
}
|
|
9715
|
-
return
|
|
9715
|
+
return theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
|
|
9716
9716
|
}
|
|
9717
9717
|
function resolveBarWidth(availableWidth) {
|
|
9718
9718
|
const preferred = Math.min(
|
|
@@ -10968,13 +10968,13 @@ function applyColorScaleRange(scales, encoding, theme, highlight, markType) {
|
|
|
10968
10968
|
return [];
|
|
10969
10969
|
}
|
|
10970
10970
|
if (scales.color.type === "sequential") {
|
|
10971
|
-
const seqStops =
|
|
10971
|
+
const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
|
|
10972
10972
|
scales.color.scale.range([
|
|
10973
10973
|
seqStops[0],
|
|
10974
10974
|
seqStops[seqStops.length - 1]
|
|
10975
10975
|
]);
|
|
10976
10976
|
} else if (scales.color.type === "quantile" || scales.color.type === "quantize" || scales.color.type === "threshold") {
|
|
10977
|
-
const seqStops =
|
|
10977
|
+
const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
|
|
10978
10978
|
const scale = scales.color.scale;
|
|
10979
10979
|
scale.range(sampleRampColors(seqStops, scale.range().length));
|
|
10980
10980
|
} else {
|
|
@@ -16956,7 +16956,7 @@ function checkMapSchemeName(channelObj, channelPath, errors) {
|
|
|
16956
16956
|
message: `Spec error: ${channelPath.join(".")}.scale.scheme "${scale.scheme}" is not a supported map palette`,
|
|
16957
16957
|
path: jsonPointer3(...channelPath, "scale", "scheme"),
|
|
16958
16958
|
code: "INVALID_VALUE",
|
|
16959
|
-
suggestion: `Maps support sequential and diverging palettes: ${MAP_PALETTE_NAMES}. The default is "blue".`
|
|
16959
|
+
suggestion: `Maps support sequential and diverging palettes: ${MAP_PALETTE_NAMES}. The default is the theme's default sequential ramp ("blue" unless colors.defaultSequential is set).`
|
|
16960
16960
|
});
|
|
16961
16961
|
}
|
|
16962
16962
|
}
|
|
@@ -20516,6 +20516,14 @@ function isStop(stop) {
|
|
|
20516
20516
|
}
|
|
20517
20517
|
function validateThemeRamps(theme, themePath, errors) {
|
|
20518
20518
|
if (!isObject(theme.colors)) return;
|
|
20519
|
+
if (theme.colors.defaultSequential !== void 0 && typeof theme.colors.defaultSequential !== "string") {
|
|
20520
|
+
errors.push({
|
|
20521
|
+
code: "INVALID_TYPE",
|
|
20522
|
+
path: `${themePath}${jsonPointer19("colors", "defaultSequential")}`,
|
|
20523
|
+
message: "theme.colors.defaultSequential must be a string naming a sequential ramp.",
|
|
20524
|
+
suggestion: 'Use a ramp key such as "blue", or omit defaultSequential to use the first merged sequential ramp.'
|
|
20525
|
+
});
|
|
20526
|
+
}
|
|
20519
20527
|
for (const kind of ["sequential", "diverging"]) {
|
|
20520
20528
|
const ramps = theme.colors[kind];
|
|
20521
20529
|
if (ramps === void 0) continue;
|
|
@@ -25444,10 +25452,11 @@ function compileTileMapFrame(spec, options, scope) {
|
|
|
25444
25452
|
isDarkMode,
|
|
25445
25453
|
watermark,
|
|
25446
25454
|
chromeLayout,
|
|
25455
|
+
(spec.palette === void 0 ? theme.colors.sequential[theme.colors.defaultSequential] : resolveThemeScheme(tilemapSpec.palette, theme)) ?? SEQUENTIAL_PALETTES3.blue,
|
|
25447
25456
|
scope
|
|
25448
25457
|
);
|
|
25449
25458
|
}
|
|
25450
|
-
function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, scope) {
|
|
25459
|
+
function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, paletteStops, scope) {
|
|
25451
25460
|
const stateField = tilemapSpec.encoding.state.field;
|
|
25452
25461
|
const valueField = tilemapSpec.encoding.value.field;
|
|
25453
25462
|
const stateValueMap = /* @__PURE__ */ new Map();
|
|
@@ -25461,7 +25470,6 @@ function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDa
|
|
|
25461
25470
|
const values = scope?.valueRows ? scope.valueRows.flatMap((row) => finiteNumber(row[valueField]) ?? []) : Array.from(stateValueMap.values());
|
|
25462
25471
|
const min4 = values.length > 0 ? Math.min(...values) : 0;
|
|
25463
25472
|
const max4 = values.length > 0 ? Math.max(...values) : 100;
|
|
25464
|
-
const paletteStops = resolveThemeScheme(tilemapSpec.palette, theme) ?? SEQUENTIAL_PALETTES3.blue;
|
|
25465
25473
|
const baseColor = isDarkMode ? paletteStops[0] : paletteStops[paletteStops.length - 1];
|
|
25466
25474
|
const opacityRange = isDarkMode ? [0.3, 1] : [0.25, 1];
|
|
25467
25475
|
const opacityScale = scaleLinear6().domain([min4, max4]).range(opacityRange).clamp(true);
|
|
@@ -30938,8 +30946,7 @@ function resolveNodeVisuals(nodes, encoding, edges, theme, nodeOverrides) {
|
|
|
30938
30946
|
const values = nodes.map((n) => Number(n[field])).filter((v) => Number.isFinite(v));
|
|
30939
30947
|
const colorMin = min3(values) ?? 0;
|
|
30940
30948
|
const colorMax = max3(values) ?? 1;
|
|
30941
|
-
const
|
|
30942
|
-
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
30949
|
+
const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
|
|
30943
30950
|
const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
|
|
30944
30951
|
const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
|
|
30945
30952
|
const colorScale = scaleLinear7().domain(domain).range(range);
|
|
@@ -31054,8 +31061,7 @@ function resolveEdgeVisuals(edges, encoding, theme, nodeFills) {
|
|
|
31054
31061
|
const values = edges.map((e) => Number(e[field])).filter((v) => Number.isFinite(v));
|
|
31055
31062
|
const colorMin = min3(values) ?? 0;
|
|
31056
31063
|
const colorMax = max3(values) ?? 1;
|
|
31057
|
-
const
|
|
31058
|
-
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
31064
|
+
const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
|
|
31059
31065
|
const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
|
|
31060
31066
|
const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
|
|
31061
31067
|
const colorScale = scaleLinear7().domain(domain).range(range);
|
|
@@ -32698,8 +32704,7 @@ function resolvePalette(palette, theme) {
|
|
|
32698
32704
|
if (seqPalettes[palette]) return seqPalettes[palette];
|
|
32699
32705
|
if (divPalettes[palette]) return divPalettes[palette];
|
|
32700
32706
|
}
|
|
32701
|
-
|
|
32702
|
-
return firstSeqKey ? seqPalettes[firstSeqKey] : ["#deebf7", "#08519c"];
|
|
32707
|
+
return seqPalettes[theme.colors.defaultSequential] ?? ["#deebf7", "#08519c"];
|
|
32703
32708
|
}
|
|
32704
32709
|
function computeHeatmapColors(data, column, theme, darkMode) {
|
|
32705
32710
|
const result = /* @__PURE__ */ new Map();
|