@json-to-office/core-docx 7.3.0 → 7.3.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.
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/dist/ir/chartValues.d.ts +7 -5
- package/dist/ir/chartValues.d.ts.map +1 -1
- package/dist/plugin/example/index.js +29 -3
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/ir/chartValues.d.ts
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
* The docx `chart` component spells every series as labels and values, the
|
|
5
5
|
* vocabulary it shares with the pptx component. A scatter chart has no
|
|
6
6
|
* categories, though: each point needs an x. The label is that x when it reads
|
|
7
|
-
* as a number;
|
|
8
|
-
*
|
|
9
|
-
* renderers write the x values as numbers. The compiler
|
|
10
|
-
*
|
|
7
|
+
* as a finite number; text is placed at its position, 1, 2, 3… in order.
|
|
8
|
+
* A numeric label outside the finite range is refused rather than moved to a
|
|
9
|
+
* different x. Both renderers write the x values as numbers. The compiler
|
|
10
|
+
* warns about text labels once, so both renderers say the same thing about it.
|
|
11
11
|
*/
|
|
12
|
-
/** Whether a label reads as a number
|
|
12
|
+
/** Whether a label reads as a finite number. */
|
|
13
13
|
export declare function isNumericLabel(label: string): boolean;
|
|
14
|
+
/** Whether a numeric label exceeds the range a chart can plot. */
|
|
15
|
+
export declare function isOutOfRangeNumericLabel(label: string): boolean;
|
|
14
16
|
/** The x of a scatter chart's point `index`: its label, or its position. */
|
|
15
17
|
export declare function scatterX(labels: readonly string[], index: number): number;
|
|
16
18
|
//# sourceMappingURL=chartValues.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chartValues.d.ts","sourceRoot":"","sources":["../../src/ir/chartValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"chartValues.d.ts","sourceRoot":"","sources":["../../src/ir/chartValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,gDAAgD;AAChD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED,kEAAkE;AAClE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAUzE"}
|
|
@@ -2848,12 +2848,28 @@ var init_units = __esm({
|
|
|
2848
2848
|
});
|
|
2849
2849
|
|
|
2850
2850
|
// src/ir/chartValues.ts
|
|
2851
|
+
function numericLabelValue(label) {
|
|
2852
|
+
const value = label.trim();
|
|
2853
|
+
return NUMERIC_LABEL.test(value) ? Number(value) : void 0;
|
|
2854
|
+
}
|
|
2851
2855
|
function isNumericLabel(label) {
|
|
2852
|
-
|
|
2856
|
+
const value = numericLabelValue(label);
|
|
2857
|
+
return value !== void 0 && Number.isFinite(value);
|
|
2858
|
+
}
|
|
2859
|
+
function isOutOfRangeNumericLabel(label) {
|
|
2860
|
+
const value = numericLabelValue(label);
|
|
2861
|
+
return value !== void 0 && !Number.isFinite(value);
|
|
2853
2862
|
}
|
|
2854
2863
|
function scatterX(labels, index) {
|
|
2855
2864
|
const label = labels[index];
|
|
2856
|
-
|
|
2865
|
+
const value = label === void 0 ? void 0 : numericLabelValue(label);
|
|
2866
|
+
if (value === void 0) return index + 1;
|
|
2867
|
+
if (!Number.isFinite(value)) {
|
|
2868
|
+
throw new RangeError(
|
|
2869
|
+
`Scatter x label ${JSON.stringify(label)} is not finite.`
|
|
2870
|
+
);
|
|
2871
|
+
}
|
|
2872
|
+
return value;
|
|
2857
2873
|
}
|
|
2858
2874
|
var NUMERIC_LABEL;
|
|
2859
2875
|
var init_chartValues = __esm({
|
|
@@ -12703,11 +12719,21 @@ function compileChart(component, scope) {
|
|
|
12703
12719
|
);
|
|
12704
12720
|
}
|
|
12705
12721
|
}
|
|
12722
|
+
if (props.type === "scatter") {
|
|
12723
|
+
for (const [index, entry] of series.entries()) {
|
|
12724
|
+
const at = entry.labels.findIndex(isOutOfRangeNumericLabel);
|
|
12725
|
+
if (at !== -1) {
|
|
12726
|
+
throw new Error(
|
|
12727
|
+
`Chart series "${entry.name ?? `series ${index}`}" at ${path3} has an x label ${JSON.stringify(entry.labels[at])} outside the finite number range.`
|
|
12728
|
+
);
|
|
12729
|
+
}
|
|
12730
|
+
}
|
|
12731
|
+
}
|
|
12706
12732
|
if (props.type === "scatter" && series.some((entry) => entry.labels.some((label) => !isNumericLabel(label)))) {
|
|
12707
12733
|
warnOnce(
|
|
12708
12734
|
ctx,
|
|
12709
12735
|
"chart",
|
|
12710
|
-
`Chart at ${path3} is a scatter chart whose labels are not all numbers;
|
|
12736
|
+
`Chart at ${path3} is a scatter chart whose labels are not all finite numbers; labels that do not read as finite numbers use their 1-based positions for x.`
|
|
12711
12737
|
);
|
|
12712
12738
|
}
|
|
12713
12739
|
if ((props.type === "pie" || props.type === "doughnut") && (typeof props.catAxisTitle === "string" || typeof props.valAxisTitle === "string")) {
|