@opendata-ai/openchart-vanilla 7.7.0 → 7.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/{chunk-PSMDJEXK.js → chunk-KYRQV6KR.js} +343 -3
- package/dist/chunk-KYRQV6KR.js.map +1 -0
- package/dist/index.js +14 -357
- package/dist/index.js.map +1 -1
- package/dist/static.d.ts +2 -2
- package/dist/static.js +37 -27
- package/dist/static.js.map +1 -1
- package/package.json +3 -3
- package/src/static.ts +42 -32
- package/src/tilemap-renderer.ts +2 -3
- package/dist/chunk-PSMDJEXK.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerMarkRenderer,
|
|
3
3
|
renderChartSVG,
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
renderTileMapSVG
|
|
5
|
+
} from "./chunk-KYRQV6KR.js";
|
|
6
6
|
|
|
7
7
|
// src/barlist-mount.ts
|
|
8
8
|
import { compileBarList } from "@opendata-ai/openchart-engine";
|
|
@@ -3370,7 +3370,7 @@ function createGraph(container, spec, options) {
|
|
|
3370
3370
|
}
|
|
3371
3371
|
chromeEl = document.createElement("div");
|
|
3372
3372
|
chromeEl.className = "oc-graph-chrome";
|
|
3373
|
-
|
|
3373
|
+
renderChrome3();
|
|
3374
3374
|
wrapper.appendChild(chromeEl);
|
|
3375
3375
|
canvas = document.createElement("canvas");
|
|
3376
3376
|
canvas.className = "oc-graph-canvas";
|
|
@@ -3382,7 +3382,7 @@ function createGraph(container, spec, options) {
|
|
|
3382
3382
|
if (options?.legend !== false) {
|
|
3383
3383
|
legendEl = document.createElement("div");
|
|
3384
3384
|
legendEl.className = "oc-graph-legend";
|
|
3385
|
-
|
|
3385
|
+
renderLegend2();
|
|
3386
3386
|
wrapper.appendChild(legendEl);
|
|
3387
3387
|
}
|
|
3388
3388
|
container.appendChild(wrapper);
|
|
@@ -3390,7 +3390,7 @@ function createGraph(container, spec, options) {
|
|
|
3390
3390
|
renderer = new GraphCanvasRenderer(canvas);
|
|
3391
3391
|
renderer.resize(width, canvasHeight);
|
|
3392
3392
|
}
|
|
3393
|
-
function
|
|
3393
|
+
function renderChrome3() {
|
|
3394
3394
|
if (!chromeEl) return;
|
|
3395
3395
|
let html = "";
|
|
3396
3396
|
if (compilation.chrome.title) {
|
|
@@ -3406,7 +3406,7 @@ function createGraph(container, spec, options) {
|
|
|
3406
3406
|
chromeEl.style.display = "";
|
|
3407
3407
|
}
|
|
3408
3408
|
}
|
|
3409
|
-
function
|
|
3409
|
+
function renderLegend2() {
|
|
3410
3410
|
if (!legendEl) return;
|
|
3411
3411
|
const entries = "entries" in compilation.legend ? compilation.legend.entries : [];
|
|
3412
3412
|
if (entries.length === 0) {
|
|
@@ -3704,8 +3704,8 @@ function createGraph(container, spec, options) {
|
|
|
3704
3704
|
compilation = compile();
|
|
3705
3705
|
adjacencyMap = buildAdjacencyMap(compilation.edges);
|
|
3706
3706
|
buildDataMaps();
|
|
3707
|
-
|
|
3708
|
-
|
|
3707
|
+
renderChrome3();
|
|
3708
|
+
renderLegend2();
|
|
3709
3709
|
initSimulation();
|
|
3710
3710
|
initInteraction();
|
|
3711
3711
|
hoveredNodeId = null;
|
|
@@ -3739,8 +3739,8 @@ function createGraph(container, spec, options) {
|
|
|
3739
3739
|
};
|
|
3740
3740
|
});
|
|
3741
3741
|
spatialIndex.rebuild(positionedNodes);
|
|
3742
|
-
|
|
3743
|
-
|
|
3742
|
+
renderChrome3();
|
|
3743
|
+
renderLegend2();
|
|
3744
3744
|
needsRender = true;
|
|
3745
3745
|
scheduleRender();
|
|
3746
3746
|
}
|
|
@@ -4335,7 +4335,7 @@ function wireAnnotationDrag(svg, specAnnotations, onAnnotationEdit, onEdit, setD
|
|
|
4335
4335
|
};
|
|
4336
4336
|
}
|
|
4337
4337
|
function wireConnectorEndpointDrag(svg, specAnnotations, onEdit, setDragging) {
|
|
4338
|
-
const
|
|
4338
|
+
const SVG_NS3 = "http://www.w3.org/2000/svg";
|
|
4339
4339
|
const cleanups = [];
|
|
4340
4340
|
const annotationGroups = svg.querySelectorAll(".oc-annotation-text");
|
|
4341
4341
|
for (const el of annotationGroups) {
|
|
@@ -4374,7 +4374,7 @@ function wireConnectorEndpointDrag(svg, specAnnotations, onEdit, setDragging) {
|
|
|
4374
4374
|
const createdHandles = [];
|
|
4375
4375
|
for (const ep of endpoints) {
|
|
4376
4376
|
if (!Number.isFinite(ep.cx) || !Number.isFinite(ep.cy)) continue;
|
|
4377
|
-
const handleEl = document.createElementNS(
|
|
4377
|
+
const handleEl = document.createElementNS(SVG_NS3, "circle");
|
|
4378
4378
|
handleEl.setAttribute("class", "oc-connector-handle");
|
|
4379
4379
|
handleEl.setAttribute("data-endpoint", ep.name);
|
|
4380
4380
|
handleEl.setAttribute("cx", String(ep.cx));
|
|
@@ -6335,7 +6335,7 @@ function renderBrand(parent, layout) {
|
|
|
6335
6335
|
a2.appendChild(text);
|
|
6336
6336
|
parent.appendChild(a2);
|
|
6337
6337
|
}
|
|
6338
|
-
function
|
|
6338
|
+
function renderLegend(parent, legendLayout) {
|
|
6339
6339
|
if (!("entries" in legendLayout) || legendLayout.entries.length === 0) return;
|
|
6340
6340
|
const legend = legendLayout;
|
|
6341
6341
|
const g = createSVGElement2("g");
|
|
@@ -6582,7 +6582,7 @@ function renderSankeySVG(layout, animation) {
|
|
|
6582
6582
|
renderLinks(svg, layout.links, nodePositions, animation);
|
|
6583
6583
|
renderNodes(svg, layout.nodes, animation);
|
|
6584
6584
|
renderLabels(svg, layout.nodes, layout.measureText);
|
|
6585
|
-
|
|
6585
|
+
renderLegend(svg, layout.legend);
|
|
6586
6586
|
renderChrome2(svg, layout);
|
|
6587
6587
|
if (layout.watermark) {
|
|
6588
6588
|
renderBrand(svg, layout);
|
|
@@ -7792,349 +7792,6 @@ function createTable(container, spec, options) {
|
|
|
7792
7792
|
|
|
7793
7793
|
// src/tilemap-mount.ts
|
|
7794
7794
|
import { compileTileMap } from "@opendata-ai/openchart-engine";
|
|
7795
|
-
|
|
7796
|
-
// src/tilemap-renderer.ts
|
|
7797
|
-
import { textAscent as textAscent3 } from "@opendata-ai/openchart-core";
|
|
7798
|
-
var SVG_NS3 = "http://www.w3.org/2000/svg";
|
|
7799
|
-
var XLINK_NS3 = "http://www.w3.org/1999/xlink";
|
|
7800
|
-
var BRAND_URL4 = "https://tryopendata.ai";
|
|
7801
|
-
var EASE_VAR_MAP3 = {
|
|
7802
|
-
smooth: "var(--oc-ease-smooth)",
|
|
7803
|
-
snappy: "var(--oc-ease-snappy)"
|
|
7804
|
-
};
|
|
7805
|
-
var gradientIdCounter = 0;
|
|
7806
|
-
function createSVGElement3(tag) {
|
|
7807
|
-
return document.createElementNS(SVG_NS3, tag);
|
|
7808
|
-
}
|
|
7809
|
-
function setAttrs3(el, attrs) {
|
|
7810
|
-
for (const [key, value] of Object.entries(attrs)) {
|
|
7811
|
-
el.setAttribute(key, String(value));
|
|
7812
|
-
}
|
|
7813
|
-
}
|
|
7814
|
-
function renderChrome3(parent, layout) {
|
|
7815
|
-
const g = createSVGElement3("g");
|
|
7816
|
-
g.setAttribute("class", "oc-chrome");
|
|
7817
|
-
const { chrome } = layout;
|
|
7818
|
-
const bottomOffset = layout.area.y + layout.area.height;
|
|
7819
|
-
if (chrome.title) {
|
|
7820
|
-
const text = createSVGElement3("text");
|
|
7821
|
-
setAttrs3(text, {
|
|
7822
|
-
x: chrome.title.x,
|
|
7823
|
-
y: chrome.title.y + textAscent3(chrome.title.style.fontSize)
|
|
7824
|
-
});
|
|
7825
|
-
text.setAttribute("class", "oc-title");
|
|
7826
|
-
text.setAttribute("font-family", chrome.title.style.fontFamily);
|
|
7827
|
-
text.setAttribute("font-size", String(chrome.title.style.fontSize));
|
|
7828
|
-
text.setAttribute("font-weight", String(chrome.title.style.fontWeight));
|
|
7829
|
-
text.style.setProperty("fill", chrome.title.style.fill);
|
|
7830
|
-
text.textContent = chrome.title.text;
|
|
7831
|
-
g.appendChild(text);
|
|
7832
|
-
}
|
|
7833
|
-
if (chrome.subtitle) {
|
|
7834
|
-
const text = createSVGElement3("text");
|
|
7835
|
-
setAttrs3(text, {
|
|
7836
|
-
x: chrome.subtitle.x,
|
|
7837
|
-
y: chrome.subtitle.y + textAscent3(chrome.subtitle.style.fontSize)
|
|
7838
|
-
});
|
|
7839
|
-
text.setAttribute("class", "oc-subtitle");
|
|
7840
|
-
text.setAttribute("font-family", chrome.subtitle.style.fontFamily);
|
|
7841
|
-
text.setAttribute("font-size", String(chrome.subtitle.style.fontSize));
|
|
7842
|
-
text.setAttribute("font-weight", String(chrome.subtitle.style.fontWeight));
|
|
7843
|
-
text.style.setProperty(
|
|
7844
|
-
"fill",
|
|
7845
|
-
chrome.subtitle.style.fill
|
|
7846
|
-
);
|
|
7847
|
-
text.textContent = chrome.subtitle.text;
|
|
7848
|
-
g.appendChild(text);
|
|
7849
|
-
}
|
|
7850
|
-
if (chrome.source) {
|
|
7851
|
-
const text = createSVGElement3("text");
|
|
7852
|
-
setAttrs3(text, {
|
|
7853
|
-
x: chrome.source.x,
|
|
7854
|
-
y: bottomOffset + chrome.source.y + textAscent3(chrome.source.style.fontSize)
|
|
7855
|
-
});
|
|
7856
|
-
text.setAttribute("class", "oc-source");
|
|
7857
|
-
text.setAttribute("font-family", chrome.source.style.fontFamily);
|
|
7858
|
-
text.setAttribute("font-size", String(chrome.source.style.fontSize));
|
|
7859
|
-
text.setAttribute("font-weight", String(chrome.source.style.fontWeight));
|
|
7860
|
-
text.style.setProperty(
|
|
7861
|
-
"fill",
|
|
7862
|
-
chrome.source.style.fill
|
|
7863
|
-
);
|
|
7864
|
-
text.textContent = chrome.source.text;
|
|
7865
|
-
g.appendChild(text);
|
|
7866
|
-
}
|
|
7867
|
-
if (chrome.byline) {
|
|
7868
|
-
const text = createSVGElement3("text");
|
|
7869
|
-
setAttrs3(text, {
|
|
7870
|
-
x: chrome.byline.x,
|
|
7871
|
-
y: bottomOffset + chrome.byline.y + textAscent3(chrome.byline.style.fontSize)
|
|
7872
|
-
});
|
|
7873
|
-
text.setAttribute("class", "oc-byline");
|
|
7874
|
-
text.setAttribute("font-family", chrome.byline.style.fontFamily);
|
|
7875
|
-
text.setAttribute("font-size", String(chrome.byline.style.fontSize));
|
|
7876
|
-
text.setAttribute("font-weight", String(chrome.byline.style.fontWeight));
|
|
7877
|
-
text.style.setProperty(
|
|
7878
|
-
"fill",
|
|
7879
|
-
chrome.byline.style.fill
|
|
7880
|
-
);
|
|
7881
|
-
text.textContent = chrome.byline.text;
|
|
7882
|
-
g.appendChild(text);
|
|
7883
|
-
}
|
|
7884
|
-
if (chrome.footer) {
|
|
7885
|
-
const text = createSVGElement3("text");
|
|
7886
|
-
setAttrs3(text, {
|
|
7887
|
-
x: chrome.footer.x,
|
|
7888
|
-
y: bottomOffset + chrome.footer.y + textAscent3(chrome.footer.style.fontSize)
|
|
7889
|
-
});
|
|
7890
|
-
text.setAttribute("class", "oc-footer");
|
|
7891
|
-
text.setAttribute("font-family", chrome.footer.style.fontFamily);
|
|
7892
|
-
text.setAttribute("font-size", String(chrome.footer.style.fontSize));
|
|
7893
|
-
text.setAttribute("font-weight", String(chrome.footer.style.fontWeight));
|
|
7894
|
-
text.style.setProperty(
|
|
7895
|
-
"fill",
|
|
7896
|
-
chrome.footer.style.fill
|
|
7897
|
-
);
|
|
7898
|
-
text.textContent = chrome.footer.text;
|
|
7899
|
-
g.appendChild(text);
|
|
7900
|
-
}
|
|
7901
|
-
parent.appendChild(g);
|
|
7902
|
-
}
|
|
7903
|
-
function renderWatermark2(parent, layout) {
|
|
7904
|
-
if (layout.width < 480) return;
|
|
7905
|
-
const { width, height } = layout;
|
|
7906
|
-
const { theme } = layout;
|
|
7907
|
-
const padding = theme.spacing.padding;
|
|
7908
|
-
const rightEdge = width - padding;
|
|
7909
|
-
const bottomEdge = height - padding;
|
|
7910
|
-
const fill = theme.colors.axis;
|
|
7911
|
-
const a2 = createSVGElement3("a");
|
|
7912
|
-
a2.setAttribute("href", BRAND_URL4);
|
|
7913
|
-
a2.setAttributeNS(XLINK_NS3, "xlink:href", BRAND_URL4);
|
|
7914
|
-
a2.setAttribute("target", "_blank");
|
|
7915
|
-
a2.setAttribute("rel", "noopener");
|
|
7916
|
-
a2.setAttribute("class", "oc-chrome-ref");
|
|
7917
|
-
const text = createSVGElement3("text");
|
|
7918
|
-
setAttrs3(text, {
|
|
7919
|
-
x: rightEdge,
|
|
7920
|
-
y: bottomEdge,
|
|
7921
|
-
"dominant-baseline": "alphabetic",
|
|
7922
|
-
"text-anchor": "end",
|
|
7923
|
-
"font-family": theme.fonts.family,
|
|
7924
|
-
"font-size": 12,
|
|
7925
|
-
"fill-opacity": 0.55
|
|
7926
|
-
});
|
|
7927
|
-
text.style.setProperty("fill", fill);
|
|
7928
|
-
const trySpan = createSVGElement3("tspan");
|
|
7929
|
-
setAttrs3(trySpan, { "font-weight": 500 });
|
|
7930
|
-
trySpan.textContent = "try";
|
|
7931
|
-
const openDataSpan = createSVGElement3("tspan");
|
|
7932
|
-
setAttrs3(openDataSpan, { "font-weight": 600, "font-size": 16 });
|
|
7933
|
-
openDataSpan.textContent = "OpenData";
|
|
7934
|
-
const aiSpan = createSVGElement3("tspan");
|
|
7935
|
-
setAttrs3(aiSpan, { "font-weight": 500 });
|
|
7936
|
-
aiSpan.textContent = ".ai";
|
|
7937
|
-
text.appendChild(trySpan);
|
|
7938
|
-
text.appendChild(openDataSpan);
|
|
7939
|
-
text.appendChild(aiSpan);
|
|
7940
|
-
a2.appendChild(text);
|
|
7941
|
-
parent.appendChild(a2);
|
|
7942
|
-
}
|
|
7943
|
-
function renderTiles(parent, tiles, animation) {
|
|
7944
|
-
const g = createSVGElement3("g");
|
|
7945
|
-
g.setAttribute("class", "oc-tilemap-tiles");
|
|
7946
|
-
g.setAttribute("role", "list");
|
|
7947
|
-
const tileDelays = [];
|
|
7948
|
-
if (animation?.enabled) {
|
|
7949
|
-
const baseStagger = 800 / Math.max(tiles.length, 1);
|
|
7950
|
-
let seed = 17;
|
|
7951
|
-
for (let i = 0; i < tiles.length; i++) {
|
|
7952
|
-
const idx = tiles[i].animationIndex ?? i;
|
|
7953
|
-
seed = seed * 1103515245 + 12345 & 2147483647;
|
|
7954
|
-
const jitter = (seed % 1e3 / 1e3 - 0.5) * 0.8;
|
|
7955
|
-
tileDelays.push(Math.max(0, Math.round(idx * baseStagger * (1 + jitter))));
|
|
7956
|
-
}
|
|
7957
|
-
}
|
|
7958
|
-
for (let i = 0; i < tiles.length; i++) {
|
|
7959
|
-
const tile = tiles[i];
|
|
7960
|
-
const tileGroup = createSVGElement3("g");
|
|
7961
|
-
tileGroup.setAttribute("class", "oc-tilemap-tile");
|
|
7962
|
-
tileGroup.setAttribute("data-state", tile.stateCode);
|
|
7963
|
-
tileGroup.setAttribute("role", "listitem");
|
|
7964
|
-
if (tile.aria?.label) {
|
|
7965
|
-
tileGroup.setAttribute("aria-label", tile.aria.label);
|
|
7966
|
-
}
|
|
7967
|
-
if (animation?.enabled) {
|
|
7968
|
-
const idx = tile.animationIndex ?? i;
|
|
7969
|
-
tileGroup.setAttribute("data-animation-index", String(idx));
|
|
7970
|
-
tileGroup.style.setProperty(
|
|
7971
|
-
"--oc-mark-index",
|
|
7972
|
-
String(idx)
|
|
7973
|
-
);
|
|
7974
|
-
tileGroup.style.setProperty(
|
|
7975
|
-
"--oc-tile-delay",
|
|
7976
|
-
`${tileDelays[i]}ms`
|
|
7977
|
-
);
|
|
7978
|
-
}
|
|
7979
|
-
const rect = createSVGElement3("rect");
|
|
7980
|
-
setAttrs3(rect, {
|
|
7981
|
-
x: tile.x,
|
|
7982
|
-
y: tile.y,
|
|
7983
|
-
width: tile.size,
|
|
7984
|
-
height: tile.size,
|
|
7985
|
-
rx: tile.cornerRadius,
|
|
7986
|
-
fill: tile.fill,
|
|
7987
|
-
"fill-opacity": tile.fillOpacity ?? 1,
|
|
7988
|
-
stroke: tile.stroke,
|
|
7989
|
-
"stroke-width": tile.strokeWidth
|
|
7990
|
-
});
|
|
7991
|
-
tileGroup.appendChild(rect);
|
|
7992
|
-
const codeLabel = createSVGElement3("text");
|
|
7993
|
-
setAttrs3(codeLabel, {
|
|
7994
|
-
x: tile.label.x,
|
|
7995
|
-
y: tile.label.y,
|
|
7996
|
-
"text-anchor": "middle",
|
|
7997
|
-
"dominant-baseline": "central",
|
|
7998
|
-
"font-family": tile.label.style.fontFamily,
|
|
7999
|
-
"font-size": tile.label.style.fontSize,
|
|
8000
|
-
"font-weight": tile.label.style.fontWeight
|
|
8001
|
-
});
|
|
8002
|
-
codeLabel.style.setProperty(
|
|
8003
|
-
"fill",
|
|
8004
|
-
tile.label.style.fill
|
|
8005
|
-
);
|
|
8006
|
-
codeLabel.textContent = tile.label.text;
|
|
8007
|
-
tileGroup.appendChild(codeLabel);
|
|
8008
|
-
if (tile.valueLabel.visible && tile.valueLabel.text) {
|
|
8009
|
-
const valueLabel = createSVGElement3("text");
|
|
8010
|
-
setAttrs3(valueLabel, {
|
|
8011
|
-
x: tile.valueLabel.x,
|
|
8012
|
-
y: tile.valueLabel.y,
|
|
8013
|
-
"text-anchor": "middle",
|
|
8014
|
-
"dominant-baseline": "central",
|
|
8015
|
-
"font-family": tile.valueLabel.style.fontFamily,
|
|
8016
|
-
"font-size": tile.valueLabel.style.fontSize,
|
|
8017
|
-
"font-weight": tile.valueLabel.style.fontWeight
|
|
8018
|
-
});
|
|
8019
|
-
valueLabel.style.setProperty(
|
|
8020
|
-
"fill",
|
|
8021
|
-
tile.valueLabel.style.fill
|
|
8022
|
-
);
|
|
8023
|
-
valueLabel.textContent = tile.valueLabel.text;
|
|
8024
|
-
tileGroup.appendChild(valueLabel);
|
|
8025
|
-
}
|
|
8026
|
-
g.appendChild(tileGroup);
|
|
8027
|
-
}
|
|
8028
|
-
parent.appendChild(g);
|
|
8029
|
-
}
|
|
8030
|
-
function renderGradientLegend(parent, layout) {
|
|
8031
|
-
if (!layout.gradientLegend) return;
|
|
8032
|
-
const { gradientLegend } = layout;
|
|
8033
|
-
const g = createSVGElement3("g");
|
|
8034
|
-
g.setAttribute("class", "oc-tilemap-legend");
|
|
8035
|
-
const defs = parent.querySelector("defs") || createSVGElement3("defs");
|
|
8036
|
-
const exists = parent.querySelector("defs");
|
|
8037
|
-
if (!exists) {
|
|
8038
|
-
parent.insertBefore(defs, parent.firstChild);
|
|
8039
|
-
}
|
|
8040
|
-
const gradientId = `oc-tilemap-legend-gradient-${gradientIdCounter++}`;
|
|
8041
|
-
const grad = createSVGElement3("linearGradient");
|
|
8042
|
-
grad.id = gradientId;
|
|
8043
|
-
grad.setAttribute("x1", "0%");
|
|
8044
|
-
grad.setAttribute("y1", "0%");
|
|
8045
|
-
grad.setAttribute("x2", "100%");
|
|
8046
|
-
grad.setAttribute("y2", "0%");
|
|
8047
|
-
for (const stop of gradientLegend.colorStops) {
|
|
8048
|
-
const s = createSVGElement3("stop");
|
|
8049
|
-
const attrs = {
|
|
8050
|
-
offset: `${stop.offset * 100}%`,
|
|
8051
|
-
"stop-color": stop.color
|
|
8052
|
-
};
|
|
8053
|
-
if (stop.opacity !== void 0) {
|
|
8054
|
-
attrs["stop-opacity"] = stop.opacity;
|
|
8055
|
-
}
|
|
8056
|
-
setAttrs3(s, attrs);
|
|
8057
|
-
grad.appendChild(s);
|
|
8058
|
-
}
|
|
8059
|
-
defs.appendChild(grad);
|
|
8060
|
-
const barHeight = gradientLegend.bounds.height;
|
|
8061
|
-
const bar = createSVGElement3("rect");
|
|
8062
|
-
setAttrs3(bar, {
|
|
8063
|
-
x: gradientLegend.bounds.x,
|
|
8064
|
-
y: gradientLegend.bounds.y,
|
|
8065
|
-
width: gradientLegend.bounds.width,
|
|
8066
|
-
height: barHeight,
|
|
8067
|
-
rx: barHeight / 2,
|
|
8068
|
-
fill: `url(#${gradientId})`
|
|
8069
|
-
});
|
|
8070
|
-
g.appendChild(bar);
|
|
8071
|
-
const minText = createSVGElement3("text");
|
|
8072
|
-
setAttrs3(minText, {
|
|
8073
|
-
x: gradientLegend.bounds.x,
|
|
8074
|
-
y: gradientLegend.bounds.y + gradientLegend.bounds.height + 14,
|
|
8075
|
-
"text-anchor": "start",
|
|
8076
|
-
"font-family": gradientLegend.labelStyle.fontFamily,
|
|
8077
|
-
"font-size": gradientLegend.labelStyle.fontSize,
|
|
8078
|
-
"font-weight": gradientLegend.labelStyle.fontWeight
|
|
8079
|
-
});
|
|
8080
|
-
minText.style.setProperty(
|
|
8081
|
-
"fill",
|
|
8082
|
-
gradientLegend.labelStyle.fill
|
|
8083
|
-
);
|
|
8084
|
-
minText.textContent = gradientLegend.minLabel;
|
|
8085
|
-
g.appendChild(minText);
|
|
8086
|
-
const maxText = createSVGElement3("text");
|
|
8087
|
-
setAttrs3(maxText, {
|
|
8088
|
-
x: gradientLegend.bounds.x + gradientLegend.bounds.width,
|
|
8089
|
-
y: gradientLegend.bounds.y + gradientLegend.bounds.height + 14,
|
|
8090
|
-
"text-anchor": "end",
|
|
8091
|
-
"font-family": gradientLegend.labelStyle.fontFamily,
|
|
8092
|
-
"font-size": gradientLegend.labelStyle.fontSize,
|
|
8093
|
-
"font-weight": gradientLegend.labelStyle.fontWeight
|
|
8094
|
-
});
|
|
8095
|
-
maxText.style.setProperty(
|
|
8096
|
-
"fill",
|
|
8097
|
-
gradientLegend.labelStyle.fill
|
|
8098
|
-
);
|
|
8099
|
-
maxText.textContent = gradientLegend.maxLabel;
|
|
8100
|
-
g.appendChild(maxText);
|
|
8101
|
-
parent.appendChild(g);
|
|
8102
|
-
}
|
|
8103
|
-
function renderTileMapSVG(layout, opts) {
|
|
8104
|
-
const { width, height, tiles, a11y, watermark, animation } = layout;
|
|
8105
|
-
const animate = opts?.animate && animation?.enabled;
|
|
8106
|
-
const svg = createSVGElement3("svg");
|
|
8107
|
-
svg.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
8108
|
-
svg.setAttribute("role", "img");
|
|
8109
|
-
if (a11y.altText) {
|
|
8110
|
-
svg.setAttribute("aria-label", a11y.altText);
|
|
8111
|
-
}
|
|
8112
|
-
const classes = animate ? "oc-tilemap oc-animate" : "oc-tilemap";
|
|
8113
|
-
svg.setAttribute("class", classes);
|
|
8114
|
-
if (animate && animation) {
|
|
8115
|
-
const stagger = Math.max(5, Math.round(800 / Math.max(tiles.length, 1)));
|
|
8116
|
-
svg.style.setProperty("--oc-animation-duration", `${animation.duration}ms`);
|
|
8117
|
-
svg.style.setProperty("--oc-animation-stagger", `${stagger}ms`);
|
|
8118
|
-
svg.style.setProperty("--oc-annotation-delay", `${animation.annotationDelay}ms`);
|
|
8119
|
-
const easeVar = EASE_VAR_MAP3[animation.ease] || EASE_VAR_MAP3.smooth;
|
|
8120
|
-
svg.style.setProperty("--oc-animation-ease", easeVar);
|
|
8121
|
-
}
|
|
8122
|
-
const defs = createSVGElement3("defs");
|
|
8123
|
-
svg.appendChild(defs);
|
|
8124
|
-
renderChrome3(svg, layout);
|
|
8125
|
-
renderTiles(svg, tiles, animate ? animation : void 0);
|
|
8126
|
-
if (layout.categoricalLegend) {
|
|
8127
|
-
renderLegend(svg, layout.categoricalLegend);
|
|
8128
|
-
} else {
|
|
8129
|
-
renderGradientLegend(svg, layout);
|
|
8130
|
-
}
|
|
8131
|
-
if (watermark) {
|
|
8132
|
-
renderWatermark2(svg, layout);
|
|
8133
|
-
}
|
|
8134
|
-
return svg;
|
|
8135
|
-
}
|
|
8136
|
-
|
|
8137
|
-
// src/tilemap-mount.ts
|
|
8138
7795
|
function resolveDarkMode6(mode) {
|
|
8139
7796
|
if (mode === "force") return true;
|
|
8140
7797
|
if (mode === "off" || mode === void 0) return false;
|