@opendata-ai/openchart-vanilla 7.2.1 → 7.2.3

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 CHANGED
@@ -5259,7 +5259,7 @@ function renderAnnotations(parent, layout) {
5259
5259
 
5260
5260
  // src/renderers/axes.ts
5261
5261
  import {
5262
- AXIS_TITLE_GAP,
5262
+ axisTitleOffset,
5263
5263
  estimateTextWidth as estimateTextWidth2,
5264
5264
  getAxisTitleOffset,
5265
5265
  TICK_LABEL_OFFSET
@@ -5318,7 +5318,8 @@ function renderAxis(parent, axis, orientation, layout) {
5318
5318
  setAttrs2(label, {
5319
5319
  x: tick.position,
5320
5320
  y: area.y + area.height + xLabelPad,
5321
- "text-anchor": "middle"
5321
+ "text-anchor": "middle",
5322
+ "dominant-baseline": "hanging"
5322
5323
  });
5323
5324
  }
5324
5325
  applyTextStyle(label, axis.tickLabelStyle);
@@ -5484,8 +5485,11 @@ function renderAxis(parent, axis, orientation, layout) {
5484
5485
  );
5485
5486
  return Math.max(max, w);
5486
5487
  }, 0);
5487
- const dynamicOffset = TICK_LABEL_OFFSET + maxTickLabelWidth + AXIS_TITLE_GAP;
5488
- const titleOffset = Math.max(dynamicOffset, getAxisTitleOffset(layout.dimensions.width));
5488
+ const titleOffset = axisTitleOffset(
5489
+ maxTickLabelWidth,
5490
+ axis.labelStyle.fontSize,
5491
+ layout.dimensions.width
5492
+ );
5489
5493
  setAttrs2(axisLabel, {
5490
5494
  x: area.x - titleOffset,
5491
5495
  y: area.y + area.height / 2,
@@ -6222,26 +6226,31 @@ function renderMarks(parent, layout) {
6222
6226
  }
6223
6227
 
6224
6228
  // src/renderers/metrics.ts
6229
+ var DELTA_SIZE_RATIO = 12 / 22;
6225
6230
  function renderMetrics(parent, layout) {
6226
6231
  const bar = layout.metrics;
6227
6232
  if (!bar || bar.cells.length === 0) return;
6233
+ const labelSize = layout.theme.fonts.sizes.metricLabel;
6234
+ const valueSize = layout.theme.fonts.sizes.metricValue;
6235
+ const deltaSize = Math.round(valueSize * DELTA_SIZE_RATIO);
6228
6236
  const g = createSVGElement2("g");
6229
6237
  g.setAttribute("class", "oc-metrics");
6230
6238
  for (const cell of bar.cells) {
6231
6239
  const label = createSVGElement2("text");
6232
6240
  label.setAttribute("class", "oc-metric-label");
6233
- setAttrs2(label, { x: cell.x, y: cell.labelY });
6241
+ setAttrs2(label, { x: cell.x, y: cell.labelY, "font-size": labelSize });
6234
6242
  label.textContent = cell.metric.label.toUpperCase();
6235
6243
  g.appendChild(label);
6236
6244
  const value = createSVGElement2("text");
6237
6245
  value.setAttribute("class", "oc-metric-value");
6238
- setAttrs2(value, { x: cell.x, y: cell.valueY });
6246
+ setAttrs2(value, { x: cell.x, y: cell.valueY, "font-size": valueSize });
6239
6247
  value.textContent = cell.metric.value;
6240
6248
  if (cell.metric.delta) {
6241
6249
  const delta = createSVGElement2("tspan");
6242
6250
  const tone = cell.metric.deltaTone ?? "up";
6243
6251
  delta.setAttribute("class", tone === "down" ? "oc-metric-delta-down" : "oc-metric-delta-up");
6244
6252
  delta.setAttribute("dx", "8");
6253
+ delta.setAttribute("font-size", String(deltaSize));
6245
6254
  delta.textContent = cell.metric.delta;
6246
6255
  value.appendChild(delta);
6247
6256
  }
@@ -6249,6 +6258,7 @@ function renderMetrics(parent, layout) {
6249
6258
  const secondary = createSVGElement2("tspan");
6250
6259
  secondary.setAttribute("class", "oc-metric-secondary");
6251
6260
  secondary.setAttribute("dx", "6");
6261
+ secondary.setAttribute("font-size", String(deltaSize));
6252
6262
  secondary.textContent = cell.metric.secondary;
6253
6263
  value.appendChild(secondary);
6254
6264
  }