@opendata-ai/openchart-engine 9.7.1 → 9.8.1
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 +21 -27
- 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(
|
|
@@ -9975,17 +9975,6 @@ function applyDomainEnds(fitted, scale) {
|
|
|
9975
9975
|
function* fieldIterable(data, field) {
|
|
9976
9976
|
for (const d of data) yield d[field];
|
|
9977
9977
|
}
|
|
9978
|
-
function chromeToInput(chrome) {
|
|
9979
|
-
return {
|
|
9980
|
-
eyebrow: chrome.eyebrow,
|
|
9981
|
-
title: chrome.title,
|
|
9982
|
-
subtitle: chrome.subtitle,
|
|
9983
|
-
source: chrome.source,
|
|
9984
|
-
byline: chrome.byline,
|
|
9985
|
-
footer: chrome.footer,
|
|
9986
|
-
brand: chrome.brand
|
|
9987
|
-
};
|
|
9988
|
-
}
|
|
9989
9978
|
function scalePadding(basePadding, width, height) {
|
|
9990
9979
|
const minDim = Math.min(width, height);
|
|
9991
9980
|
if (minDim >= 500) return basePadding;
|
|
@@ -10968,13 +10957,13 @@ function applyColorScaleRange(scales, encoding, theme, highlight, markType) {
|
|
|
10968
10957
|
return [];
|
|
10969
10958
|
}
|
|
10970
10959
|
if (scales.color.type === "sequential") {
|
|
10971
|
-
const seqStops =
|
|
10960
|
+
const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
|
|
10972
10961
|
scales.color.scale.range([
|
|
10973
10962
|
seqStops[0],
|
|
10974
10963
|
seqStops[seqStops.length - 1]
|
|
10975
10964
|
]);
|
|
10976
10965
|
} else if (scales.color.type === "quantile" || scales.color.type === "quantize" || scales.color.type === "threshold") {
|
|
10977
|
-
const seqStops =
|
|
10966
|
+
const seqStops = theme.colors.sequential[theme.colors.defaultSequential] ?? theme.colors.categorical;
|
|
10978
10967
|
const scale = scales.color.scale;
|
|
10979
10968
|
scale.range(sampleRampColors(seqStops, scale.range().length));
|
|
10980
10969
|
} else {
|
|
@@ -13601,7 +13590,7 @@ function resolveLayoutPlan(chartSpec, renderSpec, options, theme, strategy, wate
|
|
|
13601
13590
|
);
|
|
13602
13591
|
const bottomLegendReservation = hasLegendContent(legendContent) && legendContent.position === "bottom" ? legendContent.height + legendGap(width) : 0;
|
|
13603
13592
|
const chrome = computeChrome(
|
|
13604
|
-
|
|
13593
|
+
renderSpec.chrome,
|
|
13605
13594
|
theme,
|
|
13606
13595
|
width,
|
|
13607
13596
|
options.measureText,
|
|
@@ -13762,7 +13751,7 @@ function resolveLayoutPlan(chartSpec, renderSpec, options, theme, strategy, wate
|
|
|
13762
13751
|
);
|
|
13763
13752
|
const bottomLegendReservation = hasLegendContent(legendContent) && legendContent.position === "bottom" ? legendContent.height + legendGap(width) : 0;
|
|
13764
13753
|
let chrome = computeChrome(
|
|
13765
|
-
|
|
13754
|
+
renderSpec.chrome,
|
|
13766
13755
|
theme,
|
|
13767
13756
|
width,
|
|
13768
13757
|
options.measureText,
|
|
@@ -13992,7 +13981,7 @@ function resolveLayoutPlan(chartSpec, renderSpec, options, theme, strategy, wate
|
|
|
13992
13981
|
);
|
|
13993
13982
|
const bottomReserve = hasLegendContent(legendContent) && legendContent.position === "bottom" ? legendContent.height + legendGap(width) : 0;
|
|
13994
13983
|
chrome = computeChrome(
|
|
13995
|
-
|
|
13984
|
+
renderSpec.chrome,
|
|
13996
13985
|
theme,
|
|
13997
13986
|
width,
|
|
13998
13987
|
options.measureText,
|
|
@@ -14265,7 +14254,7 @@ function resolveFigureBudget(spec, options, legendLayout, theme, strategy, water
|
|
|
14265
14254
|
if ((preliminary.width < MIN_CHART_WIDTH || preliminary.height < MIN_CHART_HEIGHT2 || chromeEatsPlot) && chromeMode !== "hidden") {
|
|
14266
14255
|
const fallbackMode = chromeMode === "full" ? "compact" : "hidden";
|
|
14267
14256
|
const fallbackChrome = computeChrome2(
|
|
14268
|
-
|
|
14257
|
+
spec.chrome,
|
|
14269
14258
|
theme,
|
|
14270
14259
|
width,
|
|
14271
14260
|
options.measureText,
|
|
@@ -16956,7 +16945,7 @@ function checkMapSchemeName(channelObj, channelPath, errors) {
|
|
|
16956
16945
|
message: `Spec error: ${channelPath.join(".")}.scale.scheme "${scale.scheme}" is not a supported map palette`,
|
|
16957
16946
|
path: jsonPointer3(...channelPath, "scale", "scheme"),
|
|
16958
16947
|
code: "INVALID_VALUE",
|
|
16959
|
-
suggestion: `Maps support sequential and diverging palettes: ${MAP_PALETTE_NAMES}. The default is "blue".`
|
|
16948
|
+
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
16949
|
});
|
|
16961
16950
|
}
|
|
16962
16951
|
}
|
|
@@ -20516,6 +20505,14 @@ function isStop(stop) {
|
|
|
20516
20505
|
}
|
|
20517
20506
|
function validateThemeRamps(theme, themePath, errors) {
|
|
20518
20507
|
if (!isObject(theme.colors)) return;
|
|
20508
|
+
if (theme.colors.defaultSequential !== void 0 && typeof theme.colors.defaultSequential !== "string") {
|
|
20509
|
+
errors.push({
|
|
20510
|
+
code: "INVALID_TYPE",
|
|
20511
|
+
path: `${themePath}${jsonPointer19("colors", "defaultSequential")}`,
|
|
20512
|
+
message: "theme.colors.defaultSequential must be a string naming a sequential ramp.",
|
|
20513
|
+
suggestion: 'Use a ramp key such as "blue", or omit defaultSequential to use the first merged sequential ramp.'
|
|
20514
|
+
});
|
|
20515
|
+
}
|
|
20519
20516
|
for (const kind of ["sequential", "diverging"]) {
|
|
20520
20517
|
const ramps = theme.colors[kind];
|
|
20521
20518
|
if (ramps === void 0) continue;
|
|
@@ -25444,10 +25441,11 @@ function compileTileMapFrame(spec, options, scope) {
|
|
|
25444
25441
|
isDarkMode,
|
|
25445
25442
|
watermark,
|
|
25446
25443
|
chromeLayout,
|
|
25444
|
+
(spec.palette === void 0 ? theme.colors.sequential[theme.colors.defaultSequential] : resolveThemeScheme(tilemapSpec.palette, theme)) ?? SEQUENTIAL_PALETTES3.blue,
|
|
25447
25445
|
scope
|
|
25448
25446
|
);
|
|
25449
25447
|
}
|
|
25450
|
-
function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, scope) {
|
|
25448
|
+
function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDarkMode, watermark, chromeLayout, paletteStops, scope) {
|
|
25451
25449
|
const stateField = tilemapSpec.encoding.state.field;
|
|
25452
25450
|
const valueField = tilemapSpec.encoding.value.field;
|
|
25453
25451
|
const stateValueMap = /* @__PURE__ */ new Map();
|
|
@@ -25461,7 +25459,6 @@ function compileQuantitative(tilemapSpec, options, theme, chrome, fullArea, isDa
|
|
|
25461
25459
|
const values = scope?.valueRows ? scope.valueRows.flatMap((row) => finiteNumber(row[valueField]) ?? []) : Array.from(stateValueMap.values());
|
|
25462
25460
|
const min4 = values.length > 0 ? Math.min(...values) : 0;
|
|
25463
25461
|
const max4 = values.length > 0 ? Math.max(...values) : 100;
|
|
25464
|
-
const paletteStops = resolveThemeScheme(tilemapSpec.palette, theme) ?? SEQUENTIAL_PALETTES3.blue;
|
|
25465
25462
|
const baseColor = isDarkMode ? paletteStops[0] : paletteStops[paletteStops.length - 1];
|
|
25466
25463
|
const opacityRange = isDarkMode ? [0.3, 1] : [0.25, 1];
|
|
25467
25464
|
const opacityScale = scaleLinear6().domain([min4, max4]).range(opacityRange).clamp(true);
|
|
@@ -30938,8 +30935,7 @@ function resolveNodeVisuals(nodes, encoding, edges, theme, nodeOverrides) {
|
|
|
30938
30935
|
const values = nodes.map((n) => Number(n[field])).filter((v) => Number.isFinite(v));
|
|
30939
30936
|
const colorMin = min3(values) ?? 0;
|
|
30940
30937
|
const colorMax = max3(values) ?? 1;
|
|
30941
|
-
const
|
|
30942
|
-
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
30938
|
+
const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
|
|
30943
30939
|
const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
|
|
30944
30940
|
const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
|
|
30945
30941
|
const colorScale = scaleLinear7().domain(domain).range(range);
|
|
@@ -31054,8 +31050,7 @@ function resolveEdgeVisuals(edges, encoding, theme, nodeFills) {
|
|
|
31054
31050
|
const values = edges.map((e) => Number(e[field])).filter((v) => Number.isFinite(v));
|
|
31055
31051
|
const colorMin = min3(values) ?? 0;
|
|
31056
31052
|
const colorMax = max3(values) ?? 1;
|
|
31057
|
-
const
|
|
31058
|
-
const palette = seqPalettes.length > 0 ? seqPalettes[0] : ["#ccc", "#333"];
|
|
31053
|
+
const palette = theme.colors.sequential[theme.colors.defaultSequential] ?? ["#ccc", "#333"];
|
|
31059
31054
|
const domain = scaleConfig?.domain && scaleConfig.domain.length === 2 ? scaleConfig.domain : [colorMin, colorMax];
|
|
31060
31055
|
const range = scaleConfig?.range && scaleConfig.range.length >= 2 ? scaleConfig.range : [palette[0], palette[palette.length - 1]];
|
|
31061
31056
|
const colorScale = scaleLinear7().domain(domain).range(range);
|
|
@@ -32698,8 +32693,7 @@ function resolvePalette(palette, theme) {
|
|
|
32698
32693
|
if (seqPalettes[palette]) return seqPalettes[palette];
|
|
32699
32694
|
if (divPalettes[palette]) return divPalettes[palette];
|
|
32700
32695
|
}
|
|
32701
|
-
|
|
32702
|
-
return firstSeqKey ? seqPalettes[firstSeqKey] : ["#deebf7", "#08519c"];
|
|
32696
|
+
return seqPalettes[theme.colors.defaultSequential] ?? ["#deebf7", "#08519c"];
|
|
32703
32697
|
}
|
|
32704
32698
|
function computeHeatmapColors(data, column, theme, darkMode) {
|
|
32705
32699
|
const result = /* @__PURE__ */ new Map();
|