@opendata-ai/openchart-vanilla 7.2.2 → 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
|
@@ -6226,26 +6226,31 @@ function renderMarks(parent, layout) {
|
|
|
6226
6226
|
}
|
|
6227
6227
|
|
|
6228
6228
|
// src/renderers/metrics.ts
|
|
6229
|
+
var DELTA_SIZE_RATIO = 12 / 22;
|
|
6229
6230
|
function renderMetrics(parent, layout) {
|
|
6230
6231
|
const bar = layout.metrics;
|
|
6231
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);
|
|
6232
6236
|
const g = createSVGElement2("g");
|
|
6233
6237
|
g.setAttribute("class", "oc-metrics");
|
|
6234
6238
|
for (const cell of bar.cells) {
|
|
6235
6239
|
const label = createSVGElement2("text");
|
|
6236
6240
|
label.setAttribute("class", "oc-metric-label");
|
|
6237
|
-
setAttrs2(label, { x: cell.x, y: cell.labelY });
|
|
6241
|
+
setAttrs2(label, { x: cell.x, y: cell.labelY, "font-size": labelSize });
|
|
6238
6242
|
label.textContent = cell.metric.label.toUpperCase();
|
|
6239
6243
|
g.appendChild(label);
|
|
6240
6244
|
const value = createSVGElement2("text");
|
|
6241
6245
|
value.setAttribute("class", "oc-metric-value");
|
|
6242
|
-
setAttrs2(value, { x: cell.x, y: cell.valueY });
|
|
6246
|
+
setAttrs2(value, { x: cell.x, y: cell.valueY, "font-size": valueSize });
|
|
6243
6247
|
value.textContent = cell.metric.value;
|
|
6244
6248
|
if (cell.metric.delta) {
|
|
6245
6249
|
const delta = createSVGElement2("tspan");
|
|
6246
6250
|
const tone = cell.metric.deltaTone ?? "up";
|
|
6247
6251
|
delta.setAttribute("class", tone === "down" ? "oc-metric-delta-down" : "oc-metric-delta-up");
|
|
6248
6252
|
delta.setAttribute("dx", "8");
|
|
6253
|
+
delta.setAttribute("font-size", String(deltaSize));
|
|
6249
6254
|
delta.textContent = cell.metric.delta;
|
|
6250
6255
|
value.appendChild(delta);
|
|
6251
6256
|
}
|
|
@@ -6253,6 +6258,7 @@ function renderMetrics(parent, layout) {
|
|
|
6253
6258
|
const secondary = createSVGElement2("tspan");
|
|
6254
6259
|
secondary.setAttribute("class", "oc-metric-secondary");
|
|
6255
6260
|
secondary.setAttribute("dx", "6");
|
|
6261
|
+
secondary.setAttribute("font-size", String(deltaSize));
|
|
6256
6262
|
secondary.textContent = cell.metric.secondary;
|
|
6257
6263
|
value.appendChild(secondary);
|
|
6258
6264
|
}
|