@opendata-ai/openchart-vanilla 8.4.0 → 8.4.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.
@@ -3,7 +3,7 @@ import {
3
3
  renderChromeElement,
4
4
  renderLegend,
5
5
  stampAnimationVars
6
- } from "./chunk-YGYMB7KB.js";
6
+ } from "./chunk-KANNWAEA.js";
7
7
 
8
8
  // src/tilemap-renderer.ts
9
9
  var SVG_NS = "http://www.w3.org/2000/svg";
@@ -327,4 +327,4 @@ function renderTileMapSVG(layout, opts) {
327
327
  export {
328
328
  renderTileMapSVG
329
329
  };
330
- //# sourceMappingURL=chunk-LNPRDSK3.js.map
330
+ //# sourceMappingURL=chunk-3UIUANPI.js.map
@@ -4,9 +4,10 @@ import {
4
4
  exportPNG,
5
5
  exportSVG,
6
6
  exportSVGWithFonts
7
- } from "./chunk-UOB422LY.js";
7
+ } from "./chunk-6B5OBGIO.js";
8
8
  import {
9
9
  buildGradientDefs,
10
+ buildPatternDefs,
10
11
  nextSvgId,
11
12
  rectPathWithCorners,
12
13
  renderChartSVG,
@@ -14,13 +15,16 @@ import {
14
15
  renderLegend,
15
16
  renderSingleMark,
16
17
  resolveMarkFill,
17
- stampAnimationVars
18
- } from "./chunk-YGYMB7KB.js";
18
+ resolvePatternFill,
19
+ resolvedSurface,
20
+ stampAnimationVars,
21
+ stampThemeProperties
22
+ } from "./chunk-KANNWAEA.js";
19
23
  import {
20
24
  SVG_NS,
21
25
  createSVGElement,
22
26
  setAttrs
23
- } from "./chunk-HGRNXLDF.js";
27
+ } from "./chunk-5RX6ZQGZ.js";
24
28
 
25
29
  // src/resize-observer.ts
26
30
  var DEBOUNCE_MS = 16;
@@ -3564,7 +3568,7 @@ function createYouDrawIt(options) {
3564
3568
  }
3565
3569
 
3566
3570
  // src/mount.ts
3567
- import { cssTokenDefault as cssTokenDefault2, isGraphSpec, isLayerSpec } from "@opendata-ai/openchart-core";
3571
+ import { cssTokenDefault, isGraphSpec, isLayerSpec } from "@opendata-ai/openchart-core";
3568
3572
  import {
3569
3573
  compileChart,
3570
3574
  compileLayer,
@@ -6036,64 +6040,11 @@ function createSeriesSearch(options) {
6036
6040
  };
6037
6041
  }
6038
6042
 
6039
- // src/theme-tokens.ts
6040
- import { adaptForLightLineStroke, cssTokenDefault } from "@opendata-ai/openchart-core";
6041
- function resolvedSurface(theme) {
6042
- return theme.colors.neutral.surface;
6043
- }
6044
- function stampThemeProperties(el, theme) {
6045
- const accent = theme.colors.categorical[0] ?? cssTokenDefault("--oc-accent", "light");
6046
- const bg = resolvedSurface(theme);
6047
- const n = theme.colors.neutral;
6048
- const props = [
6049
- ["--oc-font-family", theme.fonts.family],
6050
- ["--oc-font-mono", theme.fonts.mono],
6051
- ["--oc-title-size", `${theme.chrome.title.fontSize}px`],
6052
- ["--oc-title-weight", `${theme.chrome.title.fontWeight}`],
6053
- ["--oc-subtitle-size", `${theme.chrome.subtitle.fontSize}px`],
6054
- ["--oc-subtitle-weight", `${theme.chrome.subtitle.fontWeight}`],
6055
- ["--oc-source-size", `${theme.chrome.source.fontSize}px`],
6056
- ["--oc-source-weight", `${theme.chrome.source.fontWeight}`],
6057
- ["--oc-body-size", `${theme.fonts.sizes.body}px`],
6058
- ["--oc-eyebrow-size", `${theme.chrome.eyebrow.fontSize}px`],
6059
- ["--oc-eyebrow-weight", `${theme.chrome.eyebrow.fontWeight}`],
6060
- ["--oc-bg", bg],
6061
- ["--oc-text", theme.colors.text],
6062
- ["--oc-text-muted", theme.colors.axis],
6063
- // Secondary grays are derived from the theme's own text/background pair
6064
- // (ResolvedTheme.colors.neutral), so a warm or cool theme gets warm or
6065
- // cool grays instead of zinc. One direction only: theme -> CSS.
6066
- ["--oc-text-secondary", n.secondary],
6067
- ["--oc-text-faint", n.faint],
6068
- ["--oc-border", n.border],
6069
- ["--oc-gray-100", n[100]],
6070
- ["--oc-gray-200", n[200]],
6071
- ["--oc-gray-300", n[300]],
6072
- ["--oc-gray-400", n[400]],
6073
- ["--oc-gray-600", n[600]],
6074
- ["--oc-gray-800", n[800]],
6075
- ["--oc-gridline", theme.colors.gridline],
6076
- // --oc-axis is the hairline the axis line is drawn with, not the ink its
6077
- // tick labels take (that is --oc-text-muted, above).
6078
- ["--oc-axis", theme.colors.hairline],
6079
- ["--oc-border-radius", `${theme.borderRadius}px`],
6080
- ["--oc-accent", accent],
6081
- ["--oc-accent-strong", adaptForLightLineStroke(accent)],
6082
- ["--oc-positive", theme.colors.positive],
6083
- ["--oc-negative", theme.colors.negative],
6084
- ["--oc-space-2", `${theme.spacing.chromeGap * 2}px`],
6085
- ["--oc-space-4", `${theme.spacing.padding}px`]
6086
- ];
6087
- for (const [name, value] of props) {
6088
- el.style.setProperty(name, value);
6089
- }
6090
- }
6091
-
6092
6043
  // src/mount.ts
6093
6044
  var FALLBACK_HEIGHT = 400;
6094
6045
  var EDITABLE_HOVER_CSS = `
6095
6046
  .oc-editable-hover {
6096
- outline: 1.5px solid ${cssTokenDefault2("--oc-editable-hover", "light")};
6047
+ outline: 1.5px solid ${cssTokenDefault("--oc-editable-hover", "light")};
6097
6048
  outline-offset: 2px;
6098
6049
  border-radius: 2px;
6099
6050
  }
@@ -7411,7 +7362,7 @@ function renderBorders(parent, borders) {
7411
7362
  }
7412
7363
  parent.appendChild(g);
7413
7364
  }
7414
- function renderFeatures(parent, features, animation, staggerBudget = 0, focusIds) {
7365
+ function renderFeatures(parent, features, animation, staggerBudget = 0, focusIds, patternMap) {
7415
7366
  const g = createSVGElement2("g");
7416
7367
  g.setAttribute("class", "oc-map-features");
7417
7368
  g.setAttribute("role", "list");
@@ -7440,13 +7391,17 @@ function renderFeatures(parent, features, animation, staggerBudget = 0, focusIds
7440
7391
  const path = createSVGElement2("path");
7441
7392
  path.setAttribute("class", "oc-map-feature");
7442
7393
  path.setAttribute("role", "listitem");
7394
+ const fill = feature.pattern && patternMap ? resolvePatternFill(feature.pattern, patternMap) : feature.fill;
7443
7395
  setAttrs2(path, {
7444
7396
  d: feature.path,
7445
- fill: feature.fill,
7397
+ fill,
7446
7398
  stroke: feature.stroke,
7447
7399
  "stroke-width": feature.strokeWidth
7448
7400
  });
7449
7401
  path.setAttribute("data-feature-id", String(feature.id));
7402
+ if (feature.noData) {
7403
+ path.setAttribute("data-nodata", "true");
7404
+ }
7450
7405
  path.setAttribute("data-key", String(feature.id));
7451
7406
  if (feature.binIndex !== void 0) {
7452
7407
  path.setAttribute("data-bin-index", String(feature.binIndex));
@@ -7466,7 +7421,7 @@ function renderFeatures(parent, features, animation, staggerBudget = 0, focusIds
7466
7421
  const idx = feature.animationIndex ?? i;
7467
7422
  path.setAttribute("data-animation-index", String(idx));
7468
7423
  s.setProperty("--oc-mark-index", String(idx));
7469
- s.setProperty("--oc-feature-fill", feature.fill);
7424
+ s.setProperty("--oc-feature-fill", fill);
7470
7425
  if (dimmed) {
7471
7426
  s.setProperty("--oc-feature-target-opacity", String(FOCUS_DIM_OPACITY));
7472
7427
  }
@@ -7539,6 +7494,8 @@ function renderMapSVG(layout, opts) {
7539
7494
  }
7540
7495
  const defs = createSVGElement2("defs");
7541
7496
  svg.appendChild(defs);
7497
+ const noDataSwatch = layout.continuousLegend?.noData ?? layout.categoricalLegend?.noData;
7498
+ const patternMap = buildPatternDefs(noDataSwatch ? [...features, noDataSwatch] : features, defs);
7542
7499
  const mapGroup = createSVGElement2("g");
7543
7500
  mapGroup.setAttribute("class", "oc-map-group");
7544
7501
  mapGroup.setAttribute("transform", `translate(${layout.area.x},${layout.area.y})`);
@@ -7551,7 +7508,8 @@ function renderMapSVG(layout, opts) {
7551
7508
  features,
7552
7509
  animate ? animation : void 0,
7553
7510
  mapStaggerBudget,
7554
- focusIdSet
7511
+ focusIdSet,
7512
+ patternMap
7555
7513
  );
7556
7514
  renderBorders(cameraGroup, borders);
7557
7515
  if (animate && animation?.enter && layout.pointMarks.length > 1) {
@@ -7564,9 +7522,23 @@ function renderMapSVG(layout, opts) {
7564
7522
  svg.appendChild(mapGroup);
7565
7523
  renderChrome(svg, layout);
7566
7524
  if (layout.continuousLegend) {
7567
- renderLegend(svg, layout.continuousLegend);
7525
+ const contNoData = layout.continuousLegend.noData;
7526
+ renderLegend(
7527
+ svg,
7528
+ contNoData?.pattern ? {
7529
+ ...layout.continuousLegend,
7530
+ noData: { ...contNoData, fill: resolvePatternFill(contNoData.pattern, patternMap) }
7531
+ } : layout.continuousLegend
7532
+ );
7568
7533
  } else if (layout.categoricalLegend) {
7569
- renderLegend(svg, layout.categoricalLegend);
7534
+ const catNoData = layout.categoricalLegend.noData;
7535
+ renderLegend(
7536
+ svg,
7537
+ catNoData?.pattern ? {
7538
+ ...layout.categoricalLegend,
7539
+ noData: { ...catNoData, fill: resolvePatternFill(catNoData.pattern, patternMap) }
7540
+ } : layout.categoricalLegend
7541
+ );
7570
7542
  }
7571
7543
  const ptLegend = layout.pointCategoricalLegend ?? layout.pointContinuousLegend;
7572
7544
  if (ptLegend) {
@@ -8321,7 +8293,6 @@ export {
8321
8293
  prefersReducedMotion,
8322
8294
  createTween,
8323
8295
  createTextEditOverlay,
8324
- resolvedSurface,
8325
8296
  DEFAULT_UPDATE_MAX_MARKS,
8326
8297
  CANVAS_DEFAULT_UPDATE_MAX_MARKS,
8327
8298
  canTransitionSpecShape,
@@ -8340,4 +8311,4 @@ export {
8340
8311
  scrubCamera,
8341
8312
  createGeoMap
8342
8313
  };
8343
- //# sourceMappingURL=chunk-45XZOWYC.js.map
8314
+ //# sourceMappingURL=chunk-5A2NLYUW.js.map