@openpresentation/opf-render 0.32.1 → 0.34.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/README.md +28 -15
- package/dist/chart-options.js +4 -2
- package/dist/charts.js +162 -163
- package/dist/effects.js +302 -0
- package/dist/export-browser.d.ts +7 -0
- package/dist/export-browser.js +18 -6
- package/dist/font-demand.js +673 -0
- package/dist/font-files.js +43 -0
- package/dist/font-registry.js +57 -20
- package/dist/font-selection-metadata.js +21 -0
- package/dist/font-selection.js +6 -0
- package/dist/fonts-browser.d.ts +4 -3
- package/dist/fonts-browser.js +27 -10
- package/dist/fonts-node.d.ts +6 -5
- package/dist/fonts-node.js +27 -7
- package/dist/fonts.d.ts +13 -3
- package/dist/hb-shape.js +4 -4
- package/dist/index.d.ts +6 -0
- package/dist/lazy-fonts.js +209 -44
- package/dist/pdf-fonts.js +1 -1
- package/dist/pdf-text.js +10 -2
- package/dist/pdf-vector.js +2 -31
- package/dist/preview-fonts-cli.js +14 -4
- package/dist/preview-fonts-node.d.ts +18 -0
- package/dist/preview-fonts-node.js +37 -0
- package/dist/raster-markers.js +46 -0
- package/dist/raster.js +7 -4
- package/dist/script-font-pack.js +65 -4
- package/dist/script-fonts.js +6 -90
- package/dist/shapes.js +308 -0
- package/dist/svg.d.ts +6 -0
- package/dist/svg.js +319 -83
- package/dist/text-paths.js +48 -16
- package/package.json +6 -6
package/dist/charts.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// The table below is carried here so the preview stays synchronous and self-contained; test/chart-catalog.mjs checks it
|
|
5
5
|
// against core's CHART_TYPES. Each type renders the construct PowerPoint shows for the exported chart; any other value
|
|
6
6
|
// returns null so the caller keeps its legacy single-series preview.
|
|
7
|
-
import { chartDrawPlan,
|
|
7
|
+
import { chartAxisFraction as axisFraction, chartAxisScale as composedScale, chartBarGeometry, chartBarSeriesOffset, chartDrawPlan, chartSlicePlan, CHART_SLICE_SEPARATOR_PX, histogramBins, paretoPlan, scottBinCount, chartWaterfallColors, waterfallLabelText, markLabelColor, chartEmphasisColors, chartSeriesLabelColor, chartContextColors, chartFocusContextColors, chartSeriesStrokes, chartHighlightColors, chartHighlightMarks, chartLayerDataLabels, chartNumber, chartValueAxisHidden, chartPaletteForFill, chartSchemeSeries, chartSeriesPalette as coreChartSeriesPalette, chartTextSize, CHART_MAX_INTERVALS, chartIntervalsFor, formatDataNumber, groupNumber, groupsAxisTicks, groupsDataRange, groupsThousands, maxIntervalsFor, niceScale, stackCategoryValues, waterfallSteps, numberFormatError, resolveChartData, resolveTextStyle, textColorForFill, textWidthMeasurer, formatNumber, formatPercentNumber, chartNumberLanguage } from "@openpresentation/opf/composition";
|
|
8
8
|
import { drawAxisTitles, drawBarLabel, drawCenteredLabel, drawPointLabel, drawSliceLabel, labelFill, labelString, outsideLabelReserve, reportOptionDiagnostics, reserveAxisTitles, resolveOptions } from "./chart-options.js";
|
|
9
9
|
|
|
10
10
|
// The series colours for a chart panel: core's `chartSeriesPalette` (the deck colour scheme's accents, RR-89, with the chart's own
|
|
@@ -56,7 +56,9 @@ function focusFor(c, layer, spec) {
|
|
|
56
56
|
const series = c.columns.slice(1).map((_, j) => focus.series?.includes(j) === true);
|
|
57
57
|
// A series focus: the unnamed series are the context, in order. A category focus: every series has context marks.
|
|
58
58
|
const rest = series.map((_, j) => j).filter((j) => !series[j]);
|
|
59
|
-
|
|
59
|
+
// A series drawn as a stroke (a line, a combo's line) keeps the ordinary floor even when labeled (core chartFocusContextColors).
|
|
60
|
+
const avoid = series.map((_, j) => j).filter((j) => focus.categories ? true : series[j]).map(strong);
|
|
61
|
+
const grays = chartFocusContextColors(c.surface, c.labelColor, rest, { labeled: focus.labeled === true, strokes: chartSeriesStrokes(spec.kind, series.length, c.combo), avoid });
|
|
60
62
|
const mutedSeries = series.map((_, j) => grays[Math.max(0, rest.indexOf(j))]);
|
|
61
63
|
return { series, categories, accent: strong(0), muted: grays[0], accents: series.map((_, j) => strong(j)), mutedSeries };
|
|
62
64
|
}
|
|
@@ -97,9 +99,9 @@ function markColor(c, j, i) {
|
|
|
97
99
|
return c.highlight ? (c.highlight.series[j] || c.highlight.categories[i] ? c.highlight.accents?.[j] ?? c.highlight.accent : c.highlight.mutedSeries?.[j] ?? c.highlight.muted) : c.colors[j % c.colors.length];
|
|
98
100
|
}
|
|
99
101
|
|
|
100
|
-
/** The
|
|
102
|
+
/** The color of the pie or doughnut slice of row `i`. LH-161: core's slice palette, which moves a last slice that reads as the first off it. */
|
|
101
103
|
function sliceColor(c, i) {
|
|
102
|
-
return c.highlight ? (c.highlight.categories[i] ? c.highlight.sliceAccents?.[i] ?? c.highlight.accent : c.highlight.sliceMuted?.[i] ?? c.highlight.muted) : c.
|
|
104
|
+
return c.highlight ? (c.highlight.categories[i] ? c.highlight.sliceAccents?.[i] ?? c.highlight.accent : c.highlight.sliceMuted?.[i] ?? c.highlight.muted) : c.sliceColors[i % c.sliceColors.length];
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
const bar = (dir, grouping) => ({ kind: "bar", dir, grouping });
|
|
@@ -198,11 +200,14 @@ export function renderCatalogChart(item, box, bound, options, svg) {
|
|
|
198
200
|
// LH-105: direct labels instead of a legend: the series names at the line ends, the category names on the slices.
|
|
199
201
|
c.endLabels = layer?.endLabels;
|
|
200
202
|
if (layer?.endLabels) c.legendManaged = true;
|
|
201
|
-
//
|
|
202
|
-
// reference marks.
|
|
203
|
+
// Shared chart marks: waterfall roles, pie value lists, stacked values/names and explicit references.
|
|
203
204
|
c.waterfall = layer?.waterfall;
|
|
205
|
+
c.histogram = layer?.histogram;
|
|
204
206
|
c.valueList = layer?.valueList;
|
|
207
|
+
// LH-182: a doughnut's square and its hole (core), the hole filled with the surface.
|
|
208
|
+
c.doughnut = layer?.doughnut;
|
|
205
209
|
c.stack = layer?.stack;
|
|
210
|
+
c.references = layer?.references;
|
|
206
211
|
if (layer?.valueList || layer?.stack?.names) c.legendManaged = true;
|
|
207
212
|
// LH-93: sibling charts sharing one value axis share one plot height; core gives each its inner plot as an inset from the chart box.
|
|
208
213
|
const inset = layer?.plot;
|
|
@@ -211,6 +216,10 @@ export function renderCatalogChart(item, box, bound, options, svg) {
|
|
|
211
216
|
// from the top of the chart box, taken before the header row narrows c.box.
|
|
212
217
|
c.alignedRows = layer?.rows && { top: box.y + layer.rows.top, bottom: box.y + layer.rows.bottom, centers: layer.rows.centers.map((center) => box.y + center) };
|
|
213
218
|
if (layer?.header) drawHeader(c, spec, layer.header);
|
|
219
|
+
// RR-105: a radar whose web is larger with its legend under it (core chart-radar.ts) draws the legend as a bottom row; the PPTX export
|
|
220
|
+
// writes c:legendPos b. Its value axis is core's too.
|
|
221
|
+
c.radar = layer?.radar;
|
|
222
|
+
if (layer?.radar?.legend === "bottom" && resolved.legend === undefined) placeLegend(c, spec, "bottom");
|
|
214
223
|
if (!resolved.active) reportOptionDiagnostics(c, resolved);
|
|
215
224
|
if (resolved.active) {
|
|
216
225
|
reportOptionDiagnostics(c, resolved);
|
|
@@ -235,8 +244,7 @@ export function renderCatalogChart(item, box, bound, options, svg) {
|
|
|
235
244
|
c.dataLabels = { content: ["value"], position: "outside-end", separator: ", " };
|
|
236
245
|
c.waterfallSigned = true;
|
|
237
246
|
}
|
|
238
|
-
//
|
|
239
|
-
for (const band of layer?.references?.bands ?? []) c.mark("rect", { ...band.box, fill: chartBandColor(c.surface, c.labelColor) }, `${c.path}.data.rows.${band.row}.0`);
|
|
247
|
+
// Explicit reference lines are drawn over the data.
|
|
240
248
|
render(c, spec);
|
|
241
249
|
drawReferenceLines(c, layer?.references?.lines);
|
|
242
250
|
drawStackNames(c, layer?.stack?.names);
|
|
@@ -254,7 +262,7 @@ export function chartData(item, bound) {
|
|
|
254
262
|
const resolved = resolveChartData(chart, bound?.presentation, { path: item.path });
|
|
255
263
|
if (!resolved.ok) return null;
|
|
256
264
|
// LH-60: core's draw plan (the fallback construct and the data as drawn), shared with the PPTX export.
|
|
257
|
-
const language = bound?.
|
|
265
|
+
const language = bound?.scriptFonts?.profile?.bcp47;
|
|
258
266
|
const plan = chartDrawPlan(chart, resolved, { language: typeof language === "string" ? language : undefined });
|
|
259
267
|
const formats = plan.formats.map((format) => typeof format === "string" && format !== "" && !numberFormatError(format) ? format : undefined);
|
|
260
268
|
return { type: plan.type, fallback: plan.fallback, columns: plan.columns, hasX: plan.hasX, rows: plan.rows, formats, trace: tracePaths(item, bound, { ...resolved, columns: plan.columns, regrouped: plan.columns.length !== resolved.columns.length }), ...(resolved.combo ? { combo: resolved.combo } : {}) };
|
|
@@ -337,6 +345,9 @@ const neutrals = bound.design.roles.neutrals;
|
|
|
337
345
|
strongColors: chartSeriesPalette(surface, bound.design.colorScheme, item.value?.colors, { accents: bound.design.roles.map.accents, roles: bound.design.colors, variables: bound.design.variables }),
|
|
338
346
|
// RR-92: the value axis core composed for a column, bar, line or area chart ({ min, max, majorUnit }); absent for the other types.
|
|
339
347
|
valueAxis: item.chart?.valueAxis,
|
|
348
|
+
secondaryValueAxis:item.chart?.secondaryValueAxis,
|
|
349
|
+
resolveColorRef:svg.resolveColorRef,
|
|
350
|
+
numericAxes: item.chart?.layer?.numericAxes,
|
|
340
351
|
gridColor: neutrals.gridline.hex,
|
|
341
352
|
axisColor: neutrals.axisLine.hex,
|
|
342
353
|
outlineColor: neutrals.outline.hex,
|
|
@@ -351,7 +362,7 @@ const neutrals = bound.design.roles.neutrals;
|
|
|
351
362
|
},
|
|
352
363
|
textElement(value, rect, path, align = "center", fill = chartTextColor, weight = 400) {
|
|
353
364
|
if (!(rect.width > 0 && rect.height > 0)) return "";
|
|
354
|
-
return svg.renderTextBox(String(value), rect, bound, {
|
|
365
|
+
return svg.renderTextBox(isolateNumerals(String(value)), rect, bound, {
|
|
355
366
|
path: tracePath(path), fontSize: requested, fontFamily: bound.design.fonts.body, fontWeight: weight,
|
|
356
367
|
fill, options, align, verticalAlign: "middle"
|
|
357
368
|
});
|
|
@@ -362,7 +373,8 @@ const neutrals = bound.design.roles.neutrals;
|
|
|
362
373
|
},
|
|
363
374
|
// LH-141: whether the default value labels of column `column` group their thousands (no format of its own, whole numbers, one of four digits).
|
|
364
375
|
group: (column) => (formats[column] === undefined || formats[column] === "") && groupsThousands(rows.map((row) => chartNumber(row[column]))),
|
|
365
|
-
|
|
376
|
+
// LH-106: a chartex chart (waterfall, histogram, ...) draws Latin digits, as PowerPoint does (core chartNumberLanguage).
|
|
377
|
+
language: chartNumberLanguage(item.value, bound.scriptFonts?.profile?.bcp47),
|
|
366
378
|
series(first = 1) {
|
|
367
379
|
return columns.slice(first).map((name, offset) => ({
|
|
368
380
|
name: c.label(name), column: first + offset, index: offset,
|
|
@@ -372,6 +384,11 @@ const neutrals = bound.design.roles.neutrals;
|
|
|
372
384
|
}));
|
|
373
385
|
}
|
|
374
386
|
};
|
|
387
|
+
// LH-161: a pie's or doughnut's slices: the series colors, the last slice moved off the first (at most 20 L*) when they would read as one tone,
|
|
388
|
+
// else every slice bordered in the surface color.
|
|
389
|
+
const slicePlan = chartSlicePlan(surface, c.colors, rows.length, { legible: chartSchemeSeries(item.value?.colors, bound.design.colorScheme, { accents: bound.design.roles.map.accents, roles: bound.design.colors, variables: bound.design.variables }) });
|
|
390
|
+
c.sliceColors = slicePlan.colors;
|
|
391
|
+
c.sliceBordered = slicePlan.bordered;
|
|
375
392
|
return c;
|
|
376
393
|
}
|
|
377
394
|
|
|
@@ -380,32 +397,23 @@ const neutrals = bound.design.roles.neutrals;
|
|
|
380
397
|
export { chartNumber };
|
|
381
398
|
|
|
382
399
|
/** A number as its column's format shows it (core's formatDataNumber); without a format, the General form the preview always drew. */
|
|
383
|
-
export function formatChartValue(value, format) {
|
|
384
|
-
|
|
385
|
-
return
|
|
400
|
+
export function formatChartValue(value, format, language = undefined) {
|
|
401
|
+
// LH-106: in the language's numbering system (core formatNumber and formatDataNumber).
|
|
402
|
+
if (format === undefined) return formatNumber(clean(value), language);
|
|
403
|
+
return formatDataNumber(clean(value), format, language);
|
|
386
404
|
}
|
|
387
405
|
|
|
388
|
-
//
|
|
389
|
-
//
|
|
390
|
-
|
|
391
|
-
//
|
|
392
|
-
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
const distance = reverse ? scale.max - value : value - scale.min;
|
|
396
|
-
if (Number.isFinite(range) && Number.isFinite(distance)) return distance / (range || 1);
|
|
397
|
-
const unit = Math.max(Math.abs(scale.min), Math.abs(scale.max));
|
|
398
|
-
const min = scale.min / unit, max = scale.max / unit, position = value / unit;
|
|
399
|
-
return (reverse ? max - position : position - min) / (max - min);
|
|
406
|
+
// LH-106: a chart number in another script's digits (٢٥%, -٣٢٠.٨, ۱٬۰۰۰) is laid out left to right as one unit wherever it is drawn:
|
|
407
|
+
// digits, then the percent sign, a sign before the digits, as PowerPoint draws its chart labels. Arabic-Indic digits are Arabic
|
|
408
|
+
// numbers in the bidi algorithm, which leave a percent or minus sign to the right-to-left paragraph; a left-to-right isolate keeps
|
|
409
|
+
// them together. The text is measured without the isolates, which take no width, so SVG, PNG and PDF agree.
|
|
410
|
+
const NUMERAL_RUN = /(?<![\p{L}\p{N}])[+\-\u2212\u00b1]?[\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef](?:[\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef]|[,.\u066b\u066c](?=[\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef]))*[%\u066a]?/gu;
|
|
411
|
+
export function isolateNumerals(text) {
|
|
412
|
+
return /[\u0660-\u0669\u06f0-\u06f9\u0966-\u096f\u09e6-\u09ef]/.test(text) ? text.replace(NUMERAL_RUN, run => `\u2066${run}\u2069`) : text;
|
|
400
413
|
}
|
|
401
414
|
|
|
402
|
-
//
|
|
403
|
-
|
|
404
|
-
const ticks = [];
|
|
405
|
-
const count = Math.floor((max - min) / step + 1e-9);
|
|
406
|
-
for (let index = 0; index <= count; index++) ticks.push(clean(min + index * step));
|
|
407
|
-
return { min, max, step, ticks };
|
|
408
|
-
}
|
|
415
|
+
// ---------------------------------------------------------------------------
|
|
416
|
+
// Shared axis and legend helpers
|
|
409
417
|
|
|
410
418
|
function clean(value) {
|
|
411
419
|
const rounded = Number(value.toPrecision(12));
|
|
@@ -416,10 +424,19 @@ function clean(value) {
|
|
|
416
424
|
* Office General / 0% tick labels; a value axis takes its first plotted series' number format (RR-54). LH-141: `group` ({ language }, an axis
|
|
417
425
|
* with no format whose ticks are whole numbers of four digits, core `groupsAxisTicks`) groups the thousands by the deck language.
|
|
418
426
|
*/
|
|
419
|
-
export function formatTick(value, percent = false, format = undefined, group = undefined) {
|
|
420
|
-
|
|
421
|
-
if (
|
|
422
|
-
return
|
|
427
|
+
export function formatTick(value, percent = false, format = undefined, group = undefined, language = group?.language) {
|
|
428
|
+
// LH-106: every tick is in the language's numbering system, grouped or not.
|
|
429
|
+
if (percent) return formatPercentNumber(clean(value * 100), language);
|
|
430
|
+
if (format === undefined) return group ? groupNumber(clean(value), group.language) : formatNumber(clean(value), language);
|
|
431
|
+
return formatChartValue(value, format, language);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* LH-153: the tick grouping of a value axis core does not compose (combo, scatter, the chartex constructs), decided from the values it
|
|
436
|
+
* plots (core `groupsDataRange`) so PowerPoint, which picks its own ticks, agrees: no format of its own, whole numbers, one of four digits.
|
|
437
|
+
*/
|
|
438
|
+
function dataGroup(c, format, values, options) {
|
|
439
|
+
return format === undefined && groupsDataRange(values, options) ? { language: typeof c.language === "string" ? c.language : undefined } : undefined;
|
|
423
440
|
}
|
|
424
441
|
|
|
425
442
|
// RR-54: a formatted horizontal axis (horizontal bars, the scatter X axis) can have end tick labels far wider than the margin the layout
|
|
@@ -432,7 +449,7 @@ function insetForEndLabels(c, x, width, format, scaleFor) {
|
|
|
432
449
|
for (let pass = 0; pass < 3; pass++) {
|
|
433
450
|
const ticks = scale.ticks;
|
|
434
451
|
if (!ticks.length) break;
|
|
435
|
-
const first = c.width(formatTick(ticks[0], false, format)) / 2, last = c.width(formatTick(ticks[ticks.length - 1], false, format)) / 2;
|
|
452
|
+
const first = c.width(formatTick(ticks[0], false, format, undefined, c.language)) / 2, last = c.width(formatTick(ticks[ticks.length - 1], false, format, undefined, c.language)) / 2;
|
|
436
453
|
const nextX = Math.max(x, left + first), nextWidth = Math.max(1, Math.min(x + width, right - last) - nextX);
|
|
437
454
|
if (nextX === x && nextWidth === width) break;
|
|
438
455
|
x = nextX; width = nextWidth; scale = scaleFor(width);
|
|
@@ -755,15 +772,9 @@ function chartAggregateError(path, aggregate) {
|
|
|
755
772
|
|
|
756
773
|
// RR-92: a column, bar, line or area chart draws the value axis core composed for its box (c.valueAxis), the one the PPTX export
|
|
757
774
|
// writes. Without it (a chart the composition has no axis for) the scale is fitted to the plot's length as before.
|
|
758
|
-
//
|
|
759
|
-
// three numbers; it takes the saturating scale `niceScale` computes.
|
|
775
|
+
// Shared reconstruction handles finite endpoints whose span or intermediate tick product exceeds Number's range.
|
|
760
776
|
function categoryScale(c, dataMin, dataMax, length, labelExtent, percent) {
|
|
761
|
-
|
|
762
|
-
if (axis && Number.isFinite(axis.max - axis.min) && (axis.max - axis.min) / axis.majorUnit <= 1000) {
|
|
763
|
-
const scale = scaleFrom(axis.min, axis.max, axis.majorUnit);
|
|
764
|
-
if (scale.ticks.every(Number.isFinite)) return scale;
|
|
765
|
-
}
|
|
766
|
-
return niceScale(dataMin, dataMax, chartIntervalsFor(length, labelExtent, c.u), { percent });
|
|
777
|
+
return composedScale(c.valueAxis) ?? niceScale(dataMin, dataMax, chartIntervalsFor(length, labelExtent, c.u), { percent });
|
|
767
778
|
}
|
|
768
779
|
|
|
769
780
|
function renderCategoryChart(c, spec) {
|
|
@@ -802,7 +813,7 @@ function renderCategoryChart(c, spec) {
|
|
|
802
813
|
let x = box.x + pad + categoryWidth + c.pad / 2;
|
|
803
814
|
const bottom = box.y + box.height - pad - (hidden ? 0 : c.lineHeight);
|
|
804
815
|
let width = Math.max(1, right - x - fontPx - labelRoom);
|
|
805
|
-
const tickWidth = Math.max(c.width(formatTick(dataMax, percent, valueFormat, tickGroup)), c.width(formatTick(dataMin, percent, valueFormat, tickGroup)), c.width("100%")) + fontPx;
|
|
816
|
+
const tickWidth = Math.max(c.width(formatTick(dataMax, percent, valueFormat, tickGroup, c.language)), c.width(formatTick(dataMin, percent, valueFormat, tickGroup, c.language)), c.width("100%")) + fontPx;
|
|
806
817
|
const scaleFor = (w) => categoryScale(c, dataMin, dataMax, w, tickWidth, percent);
|
|
807
818
|
scale = scaleFor(width);
|
|
808
819
|
// RR-54: a formatted value axis keeps its end labels inside the chart.
|
|
@@ -810,7 +821,7 @@ function renderCategoryChart(c, spec) {
|
|
|
810
821
|
const aligned = c.alignedRows?.centers.length === count ? c.alignedRows : undefined;
|
|
811
822
|
plot = aligned ? { x, y: aligned.top, width, height: Math.max(1, aligned.bottom - aligned.top) } : { x, y: top, width, height: Math.max(1, bottom - top) };
|
|
812
823
|
// LH-125: a horizontal stacked bar chart draws its plot where core pinned it (its names stand in a row above); the PPTX export pins the same.
|
|
813
|
-
if (c.plotBox && !aligned) { plot = { ...c.plotBox }; scale = scaleFor(plot.width); }
|
|
824
|
+
if (c.plotBox && (!aligned || c.references)) { plot = { ...c.plotBox }; scale = scaleFor(plot.width); }
|
|
814
825
|
// LH-59: the categories read top to bottom in data order (PowerPoint's reversed category axis, which the export writes).
|
|
815
826
|
const entries = categories.map((name, i) => ({ name, path: `${c.path}.data.rows.${i}.0` }));
|
|
816
827
|
const rowBand = plot.height / count;
|
|
@@ -834,7 +845,7 @@ function renderCategoryChart(c, spec) {
|
|
|
834
845
|
} : planCategoryAxis(c, entries, (reserve) => {
|
|
835
846
|
const height = Math.max(1, box.y + box.height - pad - reserve - top);
|
|
836
847
|
const fitted = categoryScale(c, dataMin, dataMax, height, c.lineHeight * 1.2, percent);
|
|
837
|
-
const tickWidth = hidden ? fontPx / 2 : Math.max(...fitted.ticks.map((tick) => c.width(formatTick(tick, percent, valueFormat, tickGroup)))) + fontPx * 0.5;
|
|
848
|
+
const tickWidth = hidden ? fontPx / 2 : Math.max(...fitted.ticks.map((tick) => c.width(formatTick(tick, percent, valueFormat, tickGroup, c.language)))) + fontPx * 0.5;
|
|
838
849
|
if (rtl) {
|
|
839
850
|
const x = box.x + pad + fontPx / 2;
|
|
840
851
|
return { scale: fitted, plot: { x, y: top, width: Math.max(1, right - tickWidth - x), height }, tickWidth };
|
|
@@ -852,7 +863,7 @@ function renderCategoryChart(c, spec) {
|
|
|
852
863
|
// Category axis crosses at zero when zero is on the axis (autoZero).
|
|
853
864
|
const crossing = at(Math.min(scale.max, Math.max(scale.min, 0)));
|
|
854
865
|
for (const tick of hidden ? [] : scale.ticks) {
|
|
855
|
-
const position = at(tick), label = formatTick(tick, percent, valueFormat, tickGroup);
|
|
866
|
+
const position = at(tick), label = formatTick(tick, percent, valueFormat, tickGroup, c.language);
|
|
856
867
|
if (horizontal) {
|
|
857
868
|
gridline(c, position, plot.y, position, plot.y + plot.height);
|
|
858
869
|
const width = c.width(label) + fontPx;
|
|
@@ -878,26 +889,17 @@ function renderCategoryChart(c, spec) {
|
|
|
878
889
|
}
|
|
879
890
|
}
|
|
880
891
|
|
|
881
|
-
// PptxGenJS gap widths: clustered 150%, stacked 50% (overlap 100).
|
|
882
|
-
export function barGeometry(band, seriesCount, grouping) {
|
|
883
|
-
if (grouping === "clustered") {
|
|
884
|
-
const group = band / 2.5;
|
|
885
|
-
return { group, width: group / seriesCount, offset: (band - group) / 2, clustered: true };
|
|
886
|
-
}
|
|
887
|
-
const width = band / 1.5;
|
|
888
|
-
return { group: width, width, offset: (band - width) / 2, clustered: false };
|
|
889
|
-
}
|
|
890
|
-
|
|
891
892
|
function drawBars(c, spec, series, stacks, { plot, band, at, horizontal, scale, categorySlot = (i) => i, rowTop = (i) => plot.y + i * band }) {
|
|
892
893
|
// Bars grow from zero, or from the axis minimum (maximum, for all-negative data) when zero is off the axis.
|
|
893
894
|
const base = (value) => Math.min(scale.max, Math.max(scale.min, value));
|
|
894
|
-
|
|
895
|
+
// LH-176: core's bar geometry, PowerPoint's gap width (clustered 150%, stacked 50%) and overlap, as the PPTX export writes them.
|
|
896
|
+
const geometry = chartBarGeometry(band, series.length, spec.grouping);
|
|
895
897
|
const labels = [];
|
|
896
898
|
series.forEach((s, j) => {
|
|
897
899
|
stacks[j].forEach((point, i) => {
|
|
898
900
|
if (!point) return;
|
|
899
901
|
const color = markColor(c, j, i);
|
|
900
|
-
const slot = geometry
|
|
902
|
+
const slot = chartBarSeriesOffset(geometry, j, series.length, !horizontal && rtl(c));
|
|
901
903
|
const a = at(base(point.from)), b = at(point.to);
|
|
902
904
|
const path = `${c.path}.data.rows.${i}.${s.column}`;
|
|
903
905
|
let rect;
|
|
@@ -949,7 +951,7 @@ function drawLines(c, spec, series, stacks, { plot, band, at, categorySlot = (i)
|
|
|
949
951
|
const s = series[entry.series];
|
|
950
952
|
if (!s) continue;
|
|
951
953
|
const fill = chartSeriesLabelColor(c.surface, c.highlight ? seriesColor(c, entry.series) : c.strongColors[entry.series % c.strongColors.length]);
|
|
952
|
-
const element = c.svg.renderTextBox(entry.text ?? entry.name, entry.box, c.bound, {
|
|
954
|
+
const element = c.svg.renderTextBox(isolateNumerals(entry.text ?? entry.name), entry.box, c.bound, {
|
|
953
955
|
path: c.tracePath(`${c.path}.data.columns.${s.column}`), fontSize: c.fontPx / c.u, fontFamily: c.bound.design.fonts.body, fontWeight: entry.bold ? 700 : 400,
|
|
954
956
|
fill, options: c.options, align: rtl(c) ? "right" : "left", verticalAlign: "middle"
|
|
955
957
|
});
|
|
@@ -964,25 +966,39 @@ function drawAreas(c, series, stacks, { plot, band, at, crossing, categorySlot =
|
|
|
964
966
|
const pointX = edge ? (i) => plot.x + categorySlot(i) * plot.width / (stacks[0].length - 1) : (i) => plot.x + (categorySlot(i) + 0.5) * band;
|
|
965
967
|
for (let j = 0; j < series.length; j++) {
|
|
966
968
|
const s = series[j];
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
const
|
|
970
|
-
|
|
969
|
+
// RR-105: a gap (null, core's stackCategoryValues) splits an unstacked area into runs of points; each run stands on the axis at its
|
|
970
|
+
// own first and last point, as PowerPoint draws a blank with c:dispBlanksAs "gap" (a lone point between gaps is a zero-width run).
|
|
971
|
+
const runs = [];
|
|
972
|
+
let run = [];
|
|
973
|
+
stacks[j].forEach((point, i) => {
|
|
974
|
+
if (!point) { if (run.length) runs.push(run); run = []; return; }
|
|
975
|
+
run.push({ x: pointX(i), from: point.from, to: point.to });
|
|
976
|
+
});
|
|
977
|
+
if (run.length) runs.push(run);
|
|
978
|
+
const d = runs.map((points) => {
|
|
979
|
+
const upper = points.map((p) => `${c.num(p.x)} ${c.num(at(p.to))}`);
|
|
980
|
+
const lower = points.slice().reverse().map((p) => `${c.num(p.x)} ${c.num(p.from === 0 ? crossing : at(p.from))}`);
|
|
981
|
+
return `M ${upper.join(" L ")} L ${lower.join(" L ")} Z`;
|
|
982
|
+
}).join(" ");
|
|
983
|
+
if (d) c.mark("path", { d, fill: seriesColor(c, j) }, `${c.path}.data.columns.${s.column}`);
|
|
971
984
|
}
|
|
972
|
-
// RR-35: an area's label sits in the area at each category, halfway between its lower and upper edge.
|
|
985
|
+
// RR-35: an area's label sits in the area at each category, halfway between its lower and upper edge. A gap has no label (RR-105).
|
|
973
986
|
if (c.dataLabels) series.forEach((s, j) => stacks[j].forEach((point, i) => {
|
|
974
|
-
if (!point || c.stackValues?.[j]?.[i] === false) return;
|
|
987
|
+
if (!point || s.values[i] === null || c.stackValues?.[j]?.[i] === false) return;
|
|
975
988
|
const lowerEdge = point.from === 0 ? crossing : at(point.from);
|
|
976
989
|
drawCenteredLabel(c, labelString(c, { category: c.rows[i][0] === null || c.rows[i][0] === undefined ? "" : String(c.rows[i][0]), value: s.values[i], format: s.format, group: s.group }), pointX(i), (lowerEdge + at(point.to)) / 2, `${c.path}.data.rows.${i}.${s.column}`, seriesColor(c, j));
|
|
977
990
|
}));
|
|
978
991
|
}
|
|
979
992
|
|
|
980
|
-
//
|
|
981
|
-
// where core placed the label (the plot's start, under or over the line).
|
|
993
|
+
// Explicit reference values and independent strokes, with optional labels at the endpoints core placed.
|
|
982
994
|
function drawReferenceLines(c, lines) {
|
|
983
995
|
for (const line of lines ?? []) {
|
|
984
|
-
|
|
985
|
-
|
|
996
|
+
const color=line.stroke.color===undefined?c.chartTextColor:c.resolveColorRef(line.stroke.color,c.chartTextColor);
|
|
997
|
+
const width=line.strokeWidth,dash=line.stroke.dash==='dash'?[4*width,3*width]:line.stroke.dash==='dot'?[width,3*width]:undefined;
|
|
998
|
+
if(width>0)c.mark('line',{x1:line.x1,y1:line.y1,x2:line.x2,y2:line.y2,stroke:color,'stroke-width':width,...(dash?{'stroke-dasharray':dash.map(c.num).join(' ')}:{})},c.path+'.referenceLines.'+line.index);
|
|
999
|
+
// RR-105: a label core could not keep off the marks stands on a plate of the chart's surface (the PPTX export fills its label so).
|
|
1000
|
+
if(line.label!==undefined&&line.labelBox&&line.labelPlate)c.mark('rect',{...line.labelBox,fill:c.surface},c.path+'.referenceLines.'+line.index+'.label');
|
|
1001
|
+
if(line.label!==undefined&&line.labelBox)c.text(line.label,line.labelBox,c.path+'.referenceLines.'+line.index+'.label',line.labelAlign??'center',c.labelColor);
|
|
986
1002
|
}
|
|
987
1003
|
}
|
|
988
1004
|
|
|
@@ -1032,7 +1048,7 @@ function drawValueList(c, list) {
|
|
|
1032
1048
|
// its category under it in the chart text color.
|
|
1033
1049
|
const hole = list.hole;
|
|
1034
1050
|
if (hole) {
|
|
1035
|
-
const element = c.svg.renderTextBox(hole.value.text, hole.value.box, c.bound, {
|
|
1051
|
+
const element = c.svg.renderTextBox(isolateNumerals(hole.value.text), hole.value.box, c.bound, {
|
|
1036
1052
|
path: c.tracePath(`${c.path}.data.rows.${hole.row}.1`), fontSize: hole.value.size / c.u, fontFamily: c.bound.design.fonts.body, fontWeight: 700,
|
|
1037
1053
|
fill: chartSeriesLabelColor(c.surface, sliceColor(c, hole.row)), options: c.options, align: "center", verticalAlign: "middle"
|
|
1038
1054
|
});
|
|
@@ -1079,6 +1095,9 @@ function renderComboChart(c, spec) {
|
|
|
1079
1095
|
const [primaryMin, primaryMax] = extent([...bars, ...primaryLines]);
|
|
1080
1096
|
const [secondaryMin, secondaryMax] = extent(secondaryLines);
|
|
1081
1097
|
const primaryFormat = (bars[0] ?? primaryLines[0])?.format, secondaryFormat = secondaryLines[0]?.format;
|
|
1098
|
+
// LH-153: each value axis groups its thousands when it has no format and its series are whole numbers of four digits (core `groupsDataRange`).
|
|
1099
|
+
const primaryGroup = dataGroup(c, primaryFormat, [...bars, ...primaryLines].flatMap((s) => s.values), { zeroBased: bars.length > 0 });
|
|
1100
|
+
const secondaryGroup = dataGroup(c, secondaryFormat, secondaryLines.flatMap((s) => s.values), { zeroBased: false });
|
|
1082
1101
|
// The default legend sits at the far right, outside a right axis title (the secondary axis title, or right to left the primary
|
|
1083
1102
|
// one), as PowerPoint places it: the legend is laid out against the box before the title band was carved, and the title moves in.
|
|
1084
1103
|
const rightTitle = c.axisTitleBands?.some((band) => band.side === "right") && !c.legendManaged;
|
|
@@ -1094,21 +1113,23 @@ function renderComboChart(c, spec) {
|
|
|
1094
1113
|
const top = box.y + pad + c.lineHeight / 2;
|
|
1095
1114
|
const entries = categories.map((name, i) => ({ name, path: `${c.path}.data.rows.${i}.0` }));
|
|
1096
1115
|
if (rtl) entries.reverse();
|
|
1097
|
-
const tickWidthOf = (scale, format) => Math.max(...scale.ticks.map((tick) => c.width(formatTick(tick, false, format)))) + fontPx * 0.5;
|
|
1116
|
+
const tickWidthOf = (scale, format, group) => Math.max(...scale.ticks.map((tick) => c.width(formatTick(tick, false, format, group, c.language)))) + fontPx * 0.5;
|
|
1098
1117
|
const axis = planCategoryAxis(c, entries, (reserve) => {
|
|
1099
1118
|
const height = Math.max(1, box.y + box.height - pad - reserve - top);
|
|
1100
1119
|
const intervals = chartIntervalsFor(height, c.lineHeight * 1.2, c.u);
|
|
1101
1120
|
// The two axes share the gridlines, so each ends on a tick (LH-59 endOnTick).
|
|
1102
|
-
const scale = niceScale(primaryMin, primaryMax, intervals, { endOnTick: true });
|
|
1103
|
-
const secondary = secondaryLines.length ? niceScale(secondaryMin, secondaryMax, intervals, { endOnTick: true }) : null;
|
|
1104
|
-
const primaryWidth = tickWidthOf(scale, primaryFormat), secondaryWidth = secondary ? tickWidthOf(secondary, secondaryFormat) : 0;
|
|
1121
|
+
const scale = composedScale(c.valueAxis) ?? niceScale(primaryMin, primaryMax, intervals, { endOnTick: true });
|
|
1122
|
+
const secondary = secondaryLines.length ? composedScale(c.secondaryValueAxis) ?? niceScale(secondaryMin, secondaryMax, intervals, { endOnTick: true }) : null;
|
|
1123
|
+
const primaryWidth = tickWidthOf(scale, primaryFormat, primaryGroup), secondaryWidth = secondary ? tickWidthOf(secondary, secondaryFormat, secondaryGroup) : 0;
|
|
1105
1124
|
const leftWidth = rtl ? secondaryWidth : primaryWidth, rightWidth = rtl ? primaryWidth : secondaryWidth;
|
|
1106
1125
|
const x = box.x + pad + (leftWidth || fontPx / 2);
|
|
1107
1126
|
const plotRight = right - (rightWidth || fontPx / 2);
|
|
1108
1127
|
return { scale, secondary, primaryWidth, secondaryWidth, plot: { x, y: top, width: Math.max(1, plotRight - x), height } };
|
|
1109
1128
|
});
|
|
1110
|
-
const {
|
|
1111
|
-
|
|
1129
|
+
const { scale, secondary } = axis;
|
|
1130
|
+
const plot=c.plotBox??axis.plot;
|
|
1131
|
+
const categoryLabels=c.plotBox?planBottomLabels(c,entries,plot,Math.max(c.lineHeight+c.textHeight,c.box.height*0.4),{minX:plot.x-fontPx*0.5,maxX:plot.x+plot.width+fontPx*0.5,rotatedMinX:c.box.x+c.pad}):axis.plan;
|
|
1132
|
+
drawBottomLabels(c, categoryLabels, plot, entries);
|
|
1112
1133
|
c.plotArea = plot;
|
|
1113
1134
|
const valueAt = (axisScale) => (value) => plot.y + axisFraction(value, axisScale, true) * plot.height;
|
|
1114
1135
|
const at = valueAt(scale), atSecondary = secondary ? valueAt(secondary) : at;
|
|
@@ -1119,9 +1140,9 @@ function renderComboChart(c, spec) {
|
|
|
1119
1140
|
for (const tick of scale.ticks) {
|
|
1120
1141
|
const position = at(tick);
|
|
1121
1142
|
gridline(c, plot.x, position, plot.x + plot.width, position);
|
|
1122
|
-
tickLabel(formatTick(tick, false, primaryFormat), position, rtl ? "right" : "left", axis.primaryWidth);
|
|
1143
|
+
tickLabel(formatTick(tick, false, primaryFormat, primaryGroup, c.language), position, rtl ? "right" : "left", axis.primaryWidth);
|
|
1123
1144
|
}
|
|
1124
|
-
if (secondary) for (const tick of secondary.ticks) tickLabel(formatTick(tick, false, secondaryFormat), atSecondary(tick), rtl ? "left" : "right", axis.secondaryWidth);
|
|
1145
|
+
if (secondary) for (const tick of secondary.ticks) tickLabel(formatTick(tick, false, secondaryFormat, secondaryGroup, c.language), atSecondary(tick), rtl ? "left" : "right", axis.secondaryWidth);
|
|
1125
1146
|
const band = plot.width / count;
|
|
1126
1147
|
// Column series come first in core's order, so a column's palette index is its series index.
|
|
1127
1148
|
if (bars.length) drawBars(c, spec, bars, stackCategoryValues(bars, count, "bar", "clustered", c.path), { plot, band, at, horizontal: false, scale, categorySlot });
|
|
@@ -1174,7 +1195,8 @@ function renderCircularChart(c, spec) {
|
|
|
1174
1195
|
})));
|
|
1175
1196
|
// LH-108: with a value list, the pie fills the square core gave it.
|
|
1176
1197
|
const list = c.valueList;
|
|
1177
|
-
|
|
1198
|
+
// LH-182: a doughnut in core's square (the PPTX export pins its plot there too).
|
|
1199
|
+
const area = c.plotBox ?? (list ? list.pie : spec.kind === "doughnut" && c.doughnut ? c.doughnut.pie : { x: box.x + pad, y: box.y + pad, width: Math.max(1, box.width - 2 * pad - legendWidth), height: Math.max(1, box.height - 2 * pad) });
|
|
1178
1200
|
const cx = area.x + area.width / 2, cy = area.y + area.height / 2;
|
|
1179
1201
|
// RR-35: a slice's label text (category, the signed value, the share of the total); outside-end labels shrink the pie to leave room.
|
|
1180
1202
|
const ringTexts = c.dataLabels ? rings.map((ring) => ring.values.map((value, i) => labelString(c, { category: categories[i], value: chartNumber(c.rows[i][ring.column]) ?? 0, share: ring.total ? value / ring.total : 0, format: c.formats[ring.column], group: c.group(ring.column) }))) : null;
|
|
@@ -1183,14 +1205,17 @@ function renderCircularChart(c, spec) {
|
|
|
1183
1205
|
const outsideTexts = !ringTexts || spec.kind !== "pie" ? [] : c.sliceLabels ? ringTexts[0].filter((_, i) => c.sliceLabels.get(i) === "outside") : (c.dataLabels.position ?? "outside-end") === "outside-end" ? ringTexts[0] : [];
|
|
1184
1206
|
const outside = outsideTexts.length > 0;
|
|
1185
1207
|
const reserve = outside ? outsideLabelReserve(c, outsideTexts) : { x: 0, y: 0 };
|
|
1186
|
-
const r = list ? Math.max(1, Math.min(area.width, area.height) / 2) : outside ? Math.max(1, Math.min(area.width / 2 - reserve.x, area.height / 2 - reserve.y)) : Math.max(1, Math.min(area.width, area.height) / 2 * 0.9);
|
|
1208
|
+
const r = c.plotBox || list || (spec.kind === "doughnut" && c.doughnut) ? Math.max(1, Math.min(area.width, area.height) / 2) : outside ? Math.max(1, Math.min(area.width / 2 - reserve.x, area.height / 2 - reserve.y)) : Math.max(1, Math.min(area.width, area.height) / 2 * 0.9);
|
|
1187
1209
|
const hole = spec.kind === "doughnut" ? r * 0.5 : 0;
|
|
1188
1210
|
if (rings.every((ring) => !ring.total)) {
|
|
1189
1211
|
c.text("No positive chart values", area, c.path);
|
|
1190
1212
|
return;
|
|
1191
1213
|
}
|
|
1192
|
-
|
|
1214
|
+
// LH-161: a bordered pie separates its slices (the last from the first) by a surface-colored line.
|
|
1215
|
+
const border = c.sliceBordered ? { stroke: c.surface, "stroke-width": CHART_SLICE_SEPARATOR_PX * c.u } : { stroke: c.outlineColor, "stroke-width": 0.75 * c.pt };
|
|
1193
1216
|
const thickness = (r - hole) / rings.length;
|
|
1217
|
+
// LH-182: the hole takes the surface the chart stands on, so a watermark or motif behind the chart does not show through it.
|
|
1218
|
+
if (hole && c.doughnut) c.mark("circle", { cx, cy, r: hole, fill: c.surface });
|
|
1194
1219
|
rings.forEach((ring, j) => {
|
|
1195
1220
|
const inner = hole + j * thickness, outer = inner + thickness;
|
|
1196
1221
|
let angle = -Math.PI / 2;
|
|
@@ -1277,28 +1302,31 @@ function renderScatterChart(c) {
|
|
|
1277
1302
|
const yFormat = series[0]?.format, xFormat = c.hasX ? c.formats[1] : undefined;
|
|
1278
1303
|
const points = series.flatMap((s) => s.points);
|
|
1279
1304
|
const xs = points.map((p) => p.x), ys = points.map((p) => p.y);
|
|
1305
|
+
// LH-153: both value axes group their thousands (no format, whole numbers, one of four digits); the X axis only over a span of 1000 or more, so a column of years never reads "1,990".
|
|
1306
|
+
const yGroup = dataGroup(c, yFormat, ys, { zeroBased: false }), xGroup = c.hasX ? dataGroup(c, xFormat, xs, { zeroBased: false, minRange: 1000 }) : undefined;
|
|
1280
1307
|
const legendWidth = seriesLegend(c, series, "marker");
|
|
1281
1308
|
const top = box.y + pad + c.lineHeight / 2, bottom = box.y + box.height - pad - c.lineHeight;
|
|
1282
1309
|
const height = Math.max(1, bottom - top);
|
|
1283
|
-
const yScale = niceScale(ys.length ? Math.min(...ys) : 0, ys.length ? Math.max(...ys) : 1, chartIntervalsFor(height, c.lineHeight * 1.2, c.u));
|
|
1284
|
-
const tickWidth = Math.max(...yScale.ticks.map((tick) => c.width(formatTick(tick, false, yFormat)))) + fontPx * 0.5;
|
|
1310
|
+
const yScale = composedScale(c.numericAxes?.value) ?? niceScale(ys.length ? Math.min(...ys) : 0, ys.length ? Math.max(...ys) : 1, chartIntervalsFor(height, c.lineHeight * 1.2, c.u));
|
|
1311
|
+
const tickWidth = Math.max(...yScale.ticks.map((tick) => c.width(formatTick(tick, false, yFormat, yGroup, c.language)))) + fontPx * 0.5;
|
|
1285
1312
|
const plot = { x: box.x + pad + tickWidth, y: top, height };
|
|
1286
1313
|
plot.width = Math.max(1, box.x + box.width - pad - legendWidth - fontPx - plot.x);
|
|
1287
|
-
const xLabelWidth = Math.max(c.width(formatTick(xs.length ? Math.max(...xs) : 1, false, xFormat)), c.width(formatTick(xs.length ? Math.min(...xs) : 0, false, xFormat))) + fontPx;
|
|
1314
|
+
const xLabelWidth = Math.max(c.width(formatTick(xs.length ? Math.max(...xs) : 1, false, xFormat, xGroup, c.language)), c.width(formatTick(xs.length ? Math.min(...xs) : 0, false, xFormat, xGroup, c.language))) + fontPx;
|
|
1288
1315
|
const scaleForX = (w) => niceScale(xs.length ? Math.min(...xs) : 0, xs.length ? Math.max(...xs) : 1, chartIntervalsFor(w, xLabelWidth, c.u));
|
|
1289
|
-
let xScale = scaleForX(plot.width);
|
|
1316
|
+
let xScale = composedScale(c.numericAxes?.category) ?? scaleForX(plot.width);
|
|
1290
1317
|
// RR-54: a formatted X axis keeps its end labels inside the chart.
|
|
1291
|
-
if (xFormat !== undefined) ({ x: plot.x, width: plot.width, scale: xScale } = insetForEndLabels(c, plot.x, plot.width, xFormat, scaleForX));
|
|
1318
|
+
if (xFormat !== undefined) ({ x: plot.x, width: plot.width, scale: xScale } = insetForEndLabels(c, plot.x, plot.width, xFormat, w => composedScale(c.numericAxes?.category) ?? scaleForX(w)));
|
|
1319
|
+
if (c.plotBox) Object.assign(plot, c.plotBox);
|
|
1292
1320
|
c.plotArea = plot;
|
|
1293
1321
|
const xAt = (v) => plot.x + axisFraction(v, xScale) * plot.width;
|
|
1294
1322
|
const yAt = (v) => plot.y + axisFraction(v, yScale, true) * plot.height;
|
|
1295
1323
|
for (const tick of yScale.ticks) {
|
|
1296
1324
|
const y = yAt(tick);
|
|
1297
1325
|
gridline(c, plot.x, y, plot.x + plot.width, y);
|
|
1298
|
-
c.text(formatTick(tick, false, yFormat), { x: box.x + pad, y: y - c.lineHeight / 2, width: plot.x - box.x - pad - fontPx * 0.35, height: c.lineHeight }, c.path, "right");
|
|
1326
|
+
c.text(formatTick(tick, false, yFormat, yGroup, c.language), { x: box.x + pad, y: y - c.lineHeight / 2, width: plot.x - box.x - pad - fontPx * 0.35, height: c.lineHeight }, c.path, "right");
|
|
1299
1327
|
}
|
|
1300
1328
|
for (const tick of xScale.ticks) {
|
|
1301
|
-
const label = formatTick(tick, false, xFormat), width = c.width(label) + fontPx;
|
|
1329
|
+
const label = formatTick(tick, false, xFormat, xGroup, c.language), width = c.width(label) + fontPx;
|
|
1302
1330
|
c.text(label, { x: xAt(tick) - width / 2, y: plot.y + plot.height, width, height: c.lineHeight }, c.path);
|
|
1303
1331
|
}
|
|
1304
1332
|
const yCross = yAt(Math.min(yScale.max, Math.max(yScale.min, 0))), xCross = xAt(Math.min(xScale.max, Math.max(xScale.min, 0)));
|
|
@@ -1310,7 +1338,7 @@ function renderScatterChart(c) {
|
|
|
1310
1338
|
}
|
|
1311
1339
|
// RR-35: a scatter label shows the Y value, and the X value as its category.
|
|
1312
1340
|
if (c.dataLabels) series.forEach((s) => {
|
|
1313
|
-
for (const point of s.points) drawPointLabel(c, labelString(c, { category: formatChartValue(point.x, xFormat), value: point.y, format: s.format, group: s.
|
|
1341
|
+
for (const point of s.points) drawPointLabel(c, labelString(c, { category: formatChartValue(point.x, xFormat, c.language), value: point.y, format: s.format, group: c.group(s.column) }), [xAt(point.x), yAt(point.y)], `${c.path}.data.rows.${point.row}.${s.column}`);
|
|
1314
1342
|
});
|
|
1315
1343
|
}
|
|
1316
1344
|
|
|
@@ -1334,7 +1362,7 @@ function renderRadarChart(c, spec) {
|
|
|
1334
1362
|
const area = { x: box.x + pad, y: box.y + pad, width: Math.max(1, box.width - 2 * pad - legendWidth), height: Math.max(1, box.height - 2 * pad) };
|
|
1335
1363
|
const cx = area.x + area.width / 2, cy = area.y + area.height / 2;
|
|
1336
1364
|
const radius = Math.max(1, Math.min(area.width / 2 - labelWidth, area.height / 2 - c.lineHeight - (wraps ? c.textHeight : 0)));
|
|
1337
|
-
const scale = niceScale(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, maxIntervalsFor(radius, c.lineHeight), { endOnTick: true });
|
|
1365
|
+
const scale = (c.radar && composedScale(c.radar.axis)) ?? niceScale(values.length ? Math.min(...values) : 0, values.length ? Math.max(...values) : 1, maxIntervalsFor(radius, c.lineHeight), { endOnTick: true });
|
|
1338
1366
|
const angle = (i) => -Math.PI / 2 + i / count * Math.PI * 2;
|
|
1339
1367
|
const rAt = (v) => axisFraction(Math.min(scale.max, Math.max(scale.min, v)), scale) * radius;
|
|
1340
1368
|
const point = (i, v) => polar(cx, cy, rAt(v), angle(i));
|
|
@@ -1399,7 +1427,7 @@ function renderRadarChart(c, spec) {
|
|
|
1399
1427
|
}
|
|
1400
1428
|
// Value axis labels sit on top of filled series, as in PowerPoint.
|
|
1401
1429
|
for (const tick of scale.ticks) {
|
|
1402
|
-
const label = formatTick(tick, false, valueFormat), width = c.width(label) + fontPx * 0.5;
|
|
1430
|
+
const label = formatTick(tick, false, valueFormat, undefined, c.language), width = c.width(label) + fontPx * 0.5;
|
|
1403
1431
|
c.text(label, { x: cx - width - fontPx * 0.2, y: cy - rAt(tick) - c.lineHeight / 2, width, height: c.lineHeight }, c.path, "right");
|
|
1404
1432
|
}
|
|
1405
1433
|
// RR-35: radar data labels sit above each point (PowerPoint has no position choice for a radar).
|
|
@@ -1427,47 +1455,8 @@ export function chartexValues(rows, columns) {
|
|
|
1427
1455
|
return { hasCategories, column, values, categories };
|
|
1428
1456
|
}
|
|
1429
1457
|
|
|
1430
|
-
//
|
|
1431
|
-
|
|
1432
|
-
// exporter writes the same count as cx:binCount.
|
|
1433
|
-
export function scottBinCount(values) {
|
|
1434
|
-
const n = values.length;
|
|
1435
|
-
if (n === 0) return 1;
|
|
1436
|
-
let min = Infinity, max = -Infinity, mean = 0;
|
|
1437
|
-
for (const value of values) { if (value < min) min = value; if (value > max) max = value; mean += value / n; }
|
|
1438
|
-
if (!(max > min) || n < 2) return 1;
|
|
1439
|
-
let variance = 0;
|
|
1440
|
-
for (const value of values) variance += (value - mean) * (value - mean) / (n - 1);
|
|
1441
|
-
const width = 3.49 * Math.sqrt(variance) * Math.cbrt(n) ** -1;
|
|
1442
|
-
if (!(width > 0) || !Number.isFinite(width)) return 1;
|
|
1443
|
-
const count = Math.ceil((max - min) / width - 1e-9);
|
|
1444
|
-
return Number.isFinite(count) && count >= 1 ? count : 1;
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
/**
|
|
1448
|
-
* Equal-width bins from the minimum, closed on the right like PowerPoint's
|
|
1449
|
-
* ("[min, e1]", then "(e1, e2]"): each value falls in the last bin whose upper
|
|
1450
|
-
* edge it does not exceed. Labels carry six significant digits, and more when
|
|
1451
|
-
* two bins would read alike.
|
|
1452
|
-
*/
|
|
1453
|
-
export function histogramBins(values) {
|
|
1454
|
-
const finite = values.filter((value) => value !== null && Number.isFinite(value));
|
|
1455
|
-
if (!finite.length) return [];
|
|
1456
|
-
const min = finite.reduce((a, b) => Math.min(a, b)), max = finite.reduce((a, b) => Math.max(a, b));
|
|
1457
|
-
const count = scottBinCount(finite);
|
|
1458
|
-
const edge = (index) => index === 0 ? min : index === count ? max : min / count * (count - index) + max / count * index;
|
|
1459
|
-
const bins = Array.from({ length: count }, (_, index) => ({ low: edge(index), high: edge(index + 1), count: 0 }));
|
|
1460
|
-
for (const value of finite) {
|
|
1461
|
-
let index = 0;
|
|
1462
|
-
while (index + 1 < count && value > bins[index].high) index++;
|
|
1463
|
-
bins[index].count++;
|
|
1464
|
-
}
|
|
1465
|
-
for (let precision = 6; ; precision++) {
|
|
1466
|
-
const format = (value) => String(Number(value.toPrecision(precision)));
|
|
1467
|
-
const labels = bins.map((bin, index) => count === 1 && min === max ? format(min) : `${index === 0 ? "[" : "("}${format(bin.low)}, ${format(bin.high)}]`);
|
|
1468
|
-
if (new Set(labels).size === labels.length || precision === 17) return bins.map((bin, index) => ({ ...bin, label: labels[index] }));
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1458
|
+
// LH-160: the bins (Scott's count, capped so their labels fit) and their edge labels are core's (chart-histogram.ts), shared with the PPTX export.
|
|
1459
|
+
export { histogramBins, scottBinCount };
|
|
1471
1460
|
|
|
1472
1461
|
// WI-5: the plot is laid out before its axis is fitted, so the tick-label column is sized from the labels any of the axes the plot could end up with
|
|
1473
1462
|
// (one to CHART_MAX_INTERVALS intervals) would draw, not from a ten-interval scale that the final, sparser axis may exceed ("100" after "90").
|
|
@@ -1492,12 +1481,12 @@ function chartexPlot(c, { categories, legendWidth = 0, tickLabels = [], percentA
|
|
|
1492
1481
|
return { plot, band: plot.width / Math.max(1, categories.length) };
|
|
1493
1482
|
}
|
|
1494
1483
|
|
|
1495
|
-
function valueAxis(c, plot, scale, format) {
|
|
1484
|
+
function valueAxis(c, plot, scale, format, group) {
|
|
1496
1485
|
const at = (value) => plot.y + axisFraction(value, scale, true) * plot.height;
|
|
1497
1486
|
for (const tick of scale.ticks) {
|
|
1498
1487
|
const y = at(tick);
|
|
1499
1488
|
gridline(c, plot.x, y, plot.x + plot.width, y);
|
|
1500
|
-
c.text(formatTick(tick, false, format), { x: c.box.x + c.pad, y: y - c.lineHeight / 2, width: plot.x - c.box.x - c.pad - c.fontPx * 0.35, height: c.lineHeight }, c.path, "right");
|
|
1489
|
+
c.text(formatTick(tick, false, format, group, c.language), { x: c.box.x + c.pad, y: y - c.lineHeight / 2, width: plot.x - c.box.x - c.pad - c.fontPx * 0.35, height: c.lineHeight }, c.path, "right");
|
|
1501
1490
|
}
|
|
1502
1491
|
const crossing = at(Math.min(scale.max, Math.max(scale.min, 0)));
|
|
1503
1492
|
axisLine(c, plot.x, plot.y, plot.x, plot.y + plot.height);
|
|
@@ -1515,39 +1504,43 @@ function renderHistogramChart(c, spec) {
|
|
|
1515
1504
|
if (hasCategories) {
|
|
1516
1505
|
bars = values.map((value, i) => ({ value, name: categories[i], path: `${c.path}.data.rows.${i}.${column}`, labelPath: `${c.path}.data.rows.${i}.0` })).filter((bar) => bar.value !== null);
|
|
1517
1506
|
} else {
|
|
1518
|
-
bars = histogramBins(values).map((bin) => ({ value: bin.count, name: bin.label, path: `${c.path}.data.columns.${column}`, labelPath: c.path }));
|
|
1507
|
+
bars = histogramBins(values, { count: c.histogram?.bins, decimals: c.histogram?.decimals }).map((bin) => ({ value: bin.count, name: bin.label, path: `${c.path}.data.columns.${column}`, labelPath: c.path }));
|
|
1519
1508
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1509
|
+
const cumulative = pareto ? paretoPlan(bars) : undefined;
|
|
1510
|
+
if (cumulative) bars = cumulative.bars;
|
|
1511
|
+
const total = cumulative?.total ?? bars.reduce((sum, bar) => sum + Math.max(0, bar.value), 0);
|
|
1522
1512
|
if (!Number.isFinite(total)) throw chartAggregateError(c.path, "cumulative total");
|
|
1523
1513
|
const dataMax = bars.length ? Math.max(...bars.map((bar) => bar.value)) : 1, dataMin = bars.length ? Math.min(0, ...bars.map((bar) => bar.value)) : 0;
|
|
1524
|
-
|
|
1525
|
-
const
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1514
|
+
// RR-105: the value axis core composed (layer.histogram.valueAxis), which the PPTX export writes as the chartex cx:valScaling.
|
|
1515
|
+
const composed = composedScale(c.histogram?.valueAxis);
|
|
1516
|
+
const probe = { ticks: composed ? composed.ticks : probeTicks(dataMin, dataMax) };
|
|
1517
|
+
// LH-153: the labels and the value axis group their thousands (a histogram's bin counts too) unless the column has a format.
|
|
1518
|
+
const labelGroup = format === undefined && groupsThousands(bars.map((bar) => bar.value)), tickGroup = dataGroup(c, format, bars.map((bar) => bar.value), { zeroBased: true });
|
|
1519
|
+
const { plot, band } = chartexPlot(c, { categories: bars.map((bar) => ({ name: bar.name, path: bar.labelPath })), tickLabels: probe.ticks.map((tick) => formatTick(tick, false, format, tickGroup, c.language)), percentAxis: pareto });
|
|
1520
|
+
const scale = composed ?? niceScale(dataMin, dataMax, chartIntervalsFor(plot.height, c.lineHeight * 1.2, c.u));
|
|
1521
|
+
const { at, crossing } = valueAxis(c, plot, scale, format, tickGroup);
|
|
1528
1522
|
const width = band / 1.06, offset = (band - width) / 2;
|
|
1529
1523
|
bars.forEach((bar, i) => {
|
|
1530
1524
|
const y = at(bar.value);
|
|
1531
1525
|
c.mark("rect", { x: plot.x + i * band + offset, y: Math.min(y, crossing), width, height: Math.abs(crossing - y), fill: c.colors[0] }, bar.path);
|
|
1532
1526
|
});
|
|
1533
|
-
// RR-35: data labels on the columns (a histogram label is the bin's count).
|
|
1534
|
-
if (c.dataLabels) bars.forEach((bar, i) => {
|
|
1527
|
+
// RR-35: data labels on the columns (a histogram label is the bin's count). LH-160: not where they would not fit beside each other (core).
|
|
1528
|
+
if (c.dataLabels && c.histogram?.valueLabels !== false) bars.forEach((bar, i) => {
|
|
1535
1529
|
const y = at(bar.value);
|
|
1536
|
-
drawBarLabel(c, labelString(c, { category: bar.name, value: bar.value, format }), { x: plot.x + i * band + offset, y: Math.min(y, crossing), width, height: Math.abs(crossing - y) }, bar.value >= 0 ? "up" : "down", bar.path, c.colors[0]);
|
|
1530
|
+
drawBarLabel(c, labelString(c, { category: bar.name, value: bar.value, format, group: labelGroup }), { x: plot.x + i * band + offset, y: Math.min(y, crossing), width, height: Math.abs(crossing - y) }, bar.value >= 0 ? "up" : "down", bar.path, c.colors[0]);
|
|
1537
1531
|
});
|
|
1538
1532
|
if (pareto && bars.length) {
|
|
1539
1533
|
// Percentage axis on the right, 0-100%, and the cumulative line through the bar centres.
|
|
1540
|
-
|
|
1534
|
+
// RR-105: the percentage step core composed (layer.histogram.percentUnit), which the PPTX export writes on the secondary axis.
|
|
1535
|
+
const percent = (c.histogram?.percentUnit > 0 ? composedScale({ min: 0, max: 1, majorUnit: c.histogram.percentUnit }) : undefined) ?? niceScale(0, 1, chartIntervalsFor(plot.height, c.lineHeight * 1.2, c.u), { percent: true });
|
|
1541
1536
|
const right = plot.x + plot.width;
|
|
1542
1537
|
axisLine(c, right, plot.y, right, plot.y + plot.height);
|
|
1543
1538
|
for (const tick of percent.ticks) {
|
|
1544
1539
|
const y = plot.y + axisFraction(tick, percent, true) * plot.height;
|
|
1545
|
-
c.text(formatTick(tick, true), { x: right + c.fontPx * 0.35, y: y - c.lineHeight / 2, width: c.box.x + c.box.width - c.pad - right - c.fontPx * 0.35, height: c.lineHeight }, c.path, "left");
|
|
1540
|
+
c.text(formatTick(tick, true, undefined, undefined, c.language), { x: right + c.fontPx * 0.35, y: y - c.lineHeight / 2, width: c.box.x + c.box.width - c.pad - right - c.fontPx * 0.35, height: c.lineHeight }, c.path, "left");
|
|
1546
1541
|
}
|
|
1547
|
-
let running = 0;
|
|
1548
1542
|
const points = bars.map((bar, i) => {
|
|
1549
|
-
|
|
1550
|
-
const fraction = total ? running / total : 0;
|
|
1543
|
+
const fraction = cumulative.cumulative[i];
|
|
1551
1544
|
return `${c.num(plot.x + (i + 0.5) * band)},${c.num(plot.y + axisFraction(fraction, percent, true) * plot.height)}`;
|
|
1552
1545
|
});
|
|
1553
1546
|
c.mark("polyline", { points: points.join(" "), fill: "none", stroke: c.colors[1 % c.colors.length], "stroke-width": 2 * c.pt, "stroke-linejoin": "round", "stroke-linecap": "round" }, `${c.path}.data.columns.${column}`);
|
|
@@ -1571,15 +1564,17 @@ function renderWaterfallChart(c) {
|
|
|
1571
1564
|
const extents = bars.flatMap((bar) => [bar.from, bar.to]);
|
|
1572
1565
|
const dataMin = extents.length ? Math.min(0, ...extents) : 0, dataMax = extents.length ? Math.max(0, ...extents) : 1;
|
|
1573
1566
|
const probe = { ticks: hidden ? [] : probeTicks(dataMin, dataMax) };
|
|
1574
|
-
|
|
1575
|
-
const
|
|
1567
|
+
// LH-153: the labels group their thousands by the deck language (no format, whole numbers, one of four digits), and so does the axis.
|
|
1568
|
+
const labelGroup = c.group(column), tickGroup = dataGroup(c, format, extents, { zeroBased: true });
|
|
1569
|
+
const { plot, band } = chartexPlot(c, { categories: categories.map((name, i) => ({ name, path: `${c.path}.data.rows.${i}.0` })), tickLabels: probe.ticks.map((tick) => formatTick(tick, false, format, tickGroup, c.language)), labelRoom: hidden });
|
|
1570
|
+
const scale = composedScale(c.numericAxes?.value) ?? niceScale(dataMin, dataMax, chartIntervalsFor(plot.height, c.lineHeight * 1.2, c.u));
|
|
1576
1571
|
let at;
|
|
1577
1572
|
if (hidden) {
|
|
1578
1573
|
// The category axis line stays, at zero; the labels carry the values.
|
|
1579
1574
|
at = (value) => plot.y + axisFraction(value, scale, true) * plot.height;
|
|
1580
1575
|
const crossing = at(Math.min(scale.max, Math.max(scale.min, 0)));
|
|
1581
1576
|
axisLine(c, plot.x, crossing, plot.x + plot.width, crossing);
|
|
1582
|
-
} else ({ at } = valueAxis(c, plot, scale, format));
|
|
1577
|
+
} else ({ at } = valueAxis(c, plot, scale, format, tickGroup));
|
|
1583
1578
|
const width = band / 1.5, offset = (band - width) / 2;
|
|
1584
1579
|
bars.forEach((bar, k) => {
|
|
1585
1580
|
const a = at(bar.from), b = at(bar.to);
|
|
@@ -1591,7 +1586,7 @@ function renderWaterfallChart(c) {
|
|
|
1591
1586
|
// RR-35: data labels show each step's value (not the running total) on the floating bars.
|
|
1592
1587
|
if (c.dataLabels) bars.forEach((bar) => {
|
|
1593
1588
|
const a = at(bar.from), b = at(bar.to);
|
|
1594
|
-
const text = c.waterfallSigned ? waterfallLabelText(bar.value, format, bar.role) : labelString(c, { category: categories[bar.i], value: bar.value, format });
|
|
1589
|
+
const text = c.waterfallSigned ? waterfallLabelText(bar.value, format, bar.role, labelGroup ? { language: typeof c.language === "string" ? c.language : undefined } : undefined, c.language) : labelString(c, { category: categories[bar.i], value: bar.value, format, group: labelGroup });
|
|
1595
1590
|
drawBarLabel(c, text, { x: plot.x + bar.i * band + offset, y: Math.min(a, b), width, height: Math.abs(b - a) }, bar.value >= 0 ? "up" : "down", `${c.path}.data.rows.${bar.i}.${column}`, colorOf(bar), c.waterfallSigned && bar.role === "total" ? 700 : 400);
|
|
1596
1591
|
});
|
|
1597
1592
|
}
|
|
@@ -1602,6 +1597,8 @@ function renderFunnelChart(c) {
|
|
|
1602
1597
|
const { column, values, categories } = chartexValues(c.rows, c.columns);
|
|
1603
1598
|
const format = c.formats[column];
|
|
1604
1599
|
const count = categories.length;
|
|
1600
|
+
// LH-153: the bar values group their thousands by the deck language (no format, whole numbers, one of four digits).
|
|
1601
|
+
const group = c.group(column), grouping = group ? { language: typeof c.language === "string" ? c.language : undefined } : undefined;
|
|
1605
1602
|
const max = Math.max(0, ...values.filter((value) => value !== null));
|
|
1606
1603
|
const labelWidth = Math.min(box.width * 0.3, Math.max(0, ...categories.map((name) => c.width(flatLabel(name)))) + fontPx * 0.5);
|
|
1607
1604
|
const plot = { x: box.x + pad + labelWidth + pad / 2, y: box.y + pad, width: Math.max(1, box.width - 2 * pad - labelWidth - pad / 2), height: Math.max(1, box.height - 2 * pad) };
|
|
@@ -1618,7 +1615,7 @@ function renderFunnelChart(c) {
|
|
|
1618
1615
|
c.mark("rect", { x, y: y + offset, width, height, fill: c.colors[0] }, `${c.path}.data.rows.${i}.${column}`);
|
|
1619
1616
|
// RR-35: the funnel labels its bars with values by default; dataLabels picks the content, false removes them.
|
|
1620
1617
|
if (c.dataLabelsOff) return;
|
|
1621
|
-
insideText(c, c.dataLabels ? labelString(c, { category: name, value, format }) : formatTick(value, false, format), { x: plot.x, y: y + offset, width: plot.width, height }, `${c.path}.data.rows.${i}.${column}`, c.colors[0]);
|
|
1618
|
+
insideText(c, c.dataLabels ? labelString(c, { category: name, value, format, group }) : formatTick(value, false, format, grouping, c.language), { x: plot.x, y: y + offset, width: plot.width, height }, `${c.path}.data.rows.${i}.${column}`, c.colors[0]);
|
|
1622
1619
|
});
|
|
1623
1620
|
}
|
|
1624
1621
|
|
|
@@ -1688,7 +1685,7 @@ function renderTreemapChart(c) {
|
|
|
1688
1685
|
// RR-35: the treemap labels its tiles with category names by default; dataLabels picks the content, false removes them. PowerPoint
|
|
1689
1686
|
// draws the label at the bottom left of its tile whatever the position attribute says (native check 2026-10-01), so the preview does.
|
|
1690
1687
|
if (!c.dataLabelsOff && rect.width >= fontPx * 2 && rect.height >= c.lineHeight) {
|
|
1691
|
-
insideText(c, c.dataLabels ? labelString(c, { category: categories[i], value: values[i], format }) : categories[i], { x: rect.x + fontPx * 0.25, y: rect.y + rect.height - c.lineHeight - fontPx * 0.2, width: rect.width - fontPx * 0.5, height: c.lineHeight }, `${c.path}.data.rows.${i}.0`, c.colors[i % c.colors.length], "left");
|
|
1688
|
+
insideText(c, c.dataLabels ? labelString(c, { category: categories[i], value: values[i], format, group: c.group(column) }) : categories[i], { x: rect.x + fontPx * 0.25, y: rect.y + rect.height - c.lineHeight - fontPx * 0.2, width: rect.width - fontPx * 0.5, height: c.lineHeight }, `${c.path}.data.rows.${i}.0`, c.colors[i % c.colors.length], "left");
|
|
1692
1689
|
}
|
|
1693
1690
|
});
|
|
1694
1691
|
}
|
|
@@ -1736,9 +1733,11 @@ function renderBoxWhiskerChart(c) {
|
|
|
1736
1733
|
const dataMin = all.length ? Math.min(...all) : 0, dataMax = all.length ? Math.max(...all) : 1;
|
|
1737
1734
|
const legendWidth = seriesLegend(c, series);
|
|
1738
1735
|
const probe = { ticks: probeTicks(dataMin, dataMax) };
|
|
1739
|
-
|
|
1740
|
-
const
|
|
1741
|
-
const {
|
|
1736
|
+
// LH-153: the value axis groups its thousands when the plotted values are whole numbers of four digits (the statistics between them do not decide).
|
|
1737
|
+
const tickGroup = dataGroup(c, format, series.flatMap((s) => s.values), { zeroBased: false });
|
|
1738
|
+
const { plot, band } = chartexPlot(c, { categories: groups.map((group) => ({ name: group.name, path: lone ? c.path : `${c.path}.data.rows.${group.first}.0` })), legendWidth, tickLabels: probe.ticks.map((tick) => formatTick(tick, false, format, tickGroup, c.language)) });
|
|
1739
|
+
const scale = composedScale(c.numericAxes?.value) ?? niceScale(dataMin, dataMax, chartIntervalsFor(plot.height, c.lineHeight * 1.2, c.u));
|
|
1740
|
+
const { at } = valueAxis(c, plot, scale, format, tickGroup);
|
|
1742
1741
|
const group = band / 2, width = group / series.length, offset = (band - group) / 2;
|
|
1743
1742
|
series.forEach((s, j) => {
|
|
1744
1743
|
const color = c.colors[j % c.colors.length], path = `${c.path}.data.columns.${s.column}`;
|
|
@@ -1802,7 +1801,7 @@ function renderRegionMapChart(c) {
|
|
|
1802
1801
|
const inset = { x: x + fontPx * 0.25, width: Math.max(1, tileWidth - fontPx * 0.5) };
|
|
1803
1802
|
if (tileHeight >= c.lineHeight * 2) {
|
|
1804
1803
|
insideText(c, name, { ...inset, y: y + tileHeight / 2 - c.lineHeight, height: c.lineHeight }, `${c.path}.data.rows.${i}.0`, tile);
|
|
1805
|
-
if (value !== null) insideText(c, formatTick(value, false, format), { ...inset, y: y + tileHeight / 2, height: c.lineHeight }, `${c.path}.data.rows.${i}.${column}`, tile);
|
|
1804
|
+
if (value !== null) insideText(c, formatTick(value, false, format, undefined, c.language), { ...inset, y: y + tileHeight / 2, height: c.lineHeight }, `${c.path}.data.rows.${i}.${column}`, tile);
|
|
1806
1805
|
} else if (tileHeight >= c.lineHeight) {
|
|
1807
1806
|
insideText(c, name, { ...inset, y: y + (tileHeight - c.lineHeight) / 2, height: c.lineHeight }, `${c.path}.data.rows.${i}.0`, tile);
|
|
1808
1807
|
}
|