@opendata-ai/openchart-engine 6.25.3 → 6.25.4
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 +26 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +17 -8
- package/src/compiler/normalize.ts +17 -6
package/dist/index.js
CHANGED
|
@@ -6651,6 +6651,16 @@ function normalizeAnnotations(annotations) {
|
|
|
6651
6651
|
}
|
|
6652
6652
|
});
|
|
6653
6653
|
}
|
|
6654
|
+
function normalizeLabels(labels) {
|
|
6655
|
+
if (labels === false) return { density: "none", format: "", prefix: "" };
|
|
6656
|
+
if (labels === true || labels === void 0) return { density: "auto", format: "", prefix: "" };
|
|
6657
|
+
return {
|
|
6658
|
+
density: labels.density ?? "auto",
|
|
6659
|
+
format: labels.format ?? "",
|
|
6660
|
+
prefix: labels.prefix ?? "",
|
|
6661
|
+
offsets: labels.offsets
|
|
6662
|
+
};
|
|
6663
|
+
}
|
|
6654
6664
|
function normalizeChartSpec(spec, warnings) {
|
|
6655
6665
|
const encoding = inferEncodingTypes(spec.encoding, spec.data, warnings);
|
|
6656
6666
|
const markType = resolveMarkType(spec.mark);
|
|
@@ -6662,12 +6672,7 @@ function normalizeChartSpec(spec, warnings) {
|
|
|
6662
6672
|
encoding,
|
|
6663
6673
|
chrome: normalizeChrome(spec.chrome),
|
|
6664
6674
|
annotations: normalizeAnnotations(spec.annotations),
|
|
6665
|
-
labels:
|
|
6666
|
-
density: spec.labels?.density ?? "auto",
|
|
6667
|
-
format: spec.labels?.format ?? "",
|
|
6668
|
-
prefix: spec.labels?.prefix ?? "",
|
|
6669
|
-
offsets: spec.labels?.offsets
|
|
6670
|
-
},
|
|
6675
|
+
labels: normalizeLabels(spec.labels),
|
|
6671
6676
|
legend: spec.legend,
|
|
6672
6677
|
responsive: spec.responsive ?? true,
|
|
6673
6678
|
theme: spec.theme ?? {},
|
|
@@ -11410,14 +11415,21 @@ function compileChart(spec, options) {
|
|
|
11410
11415
|
}
|
|
11411
11416
|
};
|
|
11412
11417
|
}
|
|
11413
|
-
if (bp.labels) {
|
|
11414
|
-
|
|
11415
|
-
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11418
|
+
if (bp.labels !== void 0) {
|
|
11419
|
+
if (typeof bp.labels === "boolean") {
|
|
11420
|
+
chartSpec = {
|
|
11421
|
+
...chartSpec,
|
|
11422
|
+
labels: bp.labels ? { density: "auto", format: "", prefix: "" } : { density: "none", format: "", prefix: "" }
|
|
11423
|
+
};
|
|
11424
|
+
} else {
|
|
11425
|
+
chartSpec = {
|
|
11426
|
+
...chartSpec,
|
|
11427
|
+
labels: {
|
|
11428
|
+
...chartSpec.labels,
|
|
11429
|
+
...bp.labels
|
|
11430
|
+
}
|
|
11431
|
+
};
|
|
11432
|
+
}
|
|
11421
11433
|
}
|
|
11422
11434
|
if (bp.legend) {
|
|
11423
11435
|
chartSpec = {
|