@opendata-ai/openchart-engine 6.15.0 → 6.15.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 +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/charts/bar/compute.ts +28 -5
- package/src/compiler/validate.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -727,6 +727,13 @@ function getSequentialColor(scales, value2, fallback = DEFAULT_COLOR) {
|
|
|
727
727
|
}
|
|
728
728
|
|
|
729
729
|
// src/charts/bar/compute.ts
|
|
730
|
+
function orientGradientForHorizontalBar(grad) {
|
|
731
|
+
if (grad.gradient !== "linear") return grad;
|
|
732
|
+
const lg = grad;
|
|
733
|
+
const isDefaultVertical = (lg.x1 === void 0 || lg.x1 === 0) && (lg.y1 === void 0 || lg.y1 === 0) && (lg.x2 === void 0 || lg.x2 === 0) && (lg.y2 === void 0 || lg.y2 === 1);
|
|
734
|
+
if (!isDefaultVertical) return grad;
|
|
735
|
+
return { ...lg, x1: 0, y1: 0, x2: 1, y2: 0 };
|
|
736
|
+
}
|
|
730
737
|
var MIN_BAR_WIDTH = 1;
|
|
731
738
|
function formatBarValue(value2) {
|
|
732
739
|
if (Math.abs(value2) >= 1e3) return abbreviateNumber(value2);
|
|
@@ -837,7 +844,7 @@ function computeStackedBars(data, valueField, categoryField, colorField, xScale,
|
|
|
837
844
|
y: bandY,
|
|
838
845
|
width: barWidth,
|
|
839
846
|
height: bandwidth,
|
|
840
|
-
fill: color2,
|
|
847
|
+
fill: isGradientDef(color2) ? orientGradientForHorizontalBar(color2) : color2,
|
|
841
848
|
cornerRadius: 0,
|
|
842
849
|
data: row,
|
|
843
850
|
aria,
|
|
@@ -884,7 +891,7 @@ function computeGroupedBars(data, valueField, categoryField, colorField, xScale,
|
|
|
884
891
|
y: subY,
|
|
885
892
|
width: barWidth,
|
|
886
893
|
height: subBandHeight,
|
|
887
|
-
fill: color2,
|
|
894
|
+
fill: isGradientDef(color2) ? orientGradientForHorizontalBar(color2) : color2,
|
|
888
895
|
cornerRadius: 2,
|
|
889
896
|
data: row,
|
|
890
897
|
aria,
|
|
@@ -915,7 +922,7 @@ function computeColoredBars(data, valueField, categoryField, colorField, xScale,
|
|
|
915
922
|
y: bandY,
|
|
916
923
|
width: barWidth,
|
|
917
924
|
height: bandwidth,
|
|
918
|
-
fill: color2,
|
|
925
|
+
fill: isGradientDef(color2) ? orientGradientForHorizontalBar(color2) : color2,
|
|
919
926
|
cornerRadius: 2,
|
|
920
927
|
data: row,
|
|
921
928
|
aria,
|
|
@@ -956,7 +963,7 @@ function computeSimpleBars(data, valueField, categoryField, xScale, yScale, band
|
|
|
956
963
|
y: bandY,
|
|
957
964
|
width: barWidth,
|
|
958
965
|
height: bandwidth,
|
|
959
|
-
fill: color2,
|
|
966
|
+
fill: isGradientDef(color2) ? orientGradientForHorizontalBar(color2) : color2,
|
|
960
967
|
cornerRadius: 2,
|
|
961
968
|
data: row,
|
|
962
969
|
aria,
|
|
@@ -6748,7 +6755,7 @@ function validateChartSpec(spec, errors) {
|
|
|
6748
6755
|
message: `Spec error: encoding.${channel} must have a "field" string`,
|
|
6749
6756
|
path: `encoding.${channel}.field`,
|
|
6750
6757
|
code: "MISSING_FIELD",
|
|
6751
|
-
suggestion: `
|
|
6758
|
+
suggestion: `For constant colors, use mark.fill (e.g., mark: { type: "bar", fill: "#1b7fa3" }) instead of encoding.${channel}. Encoding channels require a data field: ${availableColumns}`
|
|
6752
6759
|
});
|
|
6753
6760
|
continue;
|
|
6754
6761
|
}
|