@codeauradev/ngx-wind-charts 1.0.4 → 1.0.8
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.
|
@@ -180,7 +180,7 @@ function box(width, height, pad) {
|
|
|
180
180
|
}
|
|
181
181
|
function yTicks(values, format, plot) {
|
|
182
182
|
const y = scale(values[0] ?? 0, values[values.length - 1] ?? 1, plot.bottom, plot.top);
|
|
183
|
-
|
|
183
|
+
const marks = values.map((value) => {
|
|
184
184
|
const py = round(y(value));
|
|
185
185
|
return {
|
|
186
186
|
x1: plot.left,
|
|
@@ -193,6 +193,9 @@ function yTicks(values, format, plot) {
|
|
|
193
193
|
anchor: "end"
|
|
194
194
|
};
|
|
195
195
|
});
|
|
196
|
+
const kept = [];
|
|
197
|
+
for (const tick of marks) if (kept.every((item) => Math.abs(item.labelY - tick.labelY) >= 14)) kept.push(tick);
|
|
198
|
+
return kept.length > 0 ? kept : marks.slice(0, 1);
|
|
196
199
|
}
|
|
197
200
|
function xValueTicks(values, format, plot) {
|
|
198
201
|
const x = scale(values[0] ?? 0, values[values.length - 1] ?? 1, plot.left, plot.right);
|
|
@@ -224,7 +227,19 @@ function layoutBars(input) {
|
|
|
224
227
|
const palette = input.palette ?? DEFAULT_PALETTE;
|
|
225
228
|
const categories = input.categories;
|
|
226
229
|
const series = input.series;
|
|
227
|
-
const
|
|
230
|
+
const stacked = input.mode === "stacked";
|
|
231
|
+
const values = [];
|
|
232
|
+
if (stacked) categories.forEach((_, index) => {
|
|
233
|
+
let positive = 0;
|
|
234
|
+
let negative = 0;
|
|
235
|
+
for (const item of series) {
|
|
236
|
+
const value = num(item.data[index] ?? 0);
|
|
237
|
+
if (value >= 0) positive += value;
|
|
238
|
+
else negative += value;
|
|
239
|
+
}
|
|
240
|
+
values.push(positive, negative);
|
|
241
|
+
});
|
|
242
|
+
else series.forEach((item) => item.data.forEach((value) => values.push(num(value))));
|
|
228
243
|
const empty = categories.length === 0 || series.length === 0;
|
|
229
244
|
const domain = domainOf(values, true, input.max);
|
|
230
245
|
const longest = domain.ticks.reduce((max, tick) => Math.max(max, input.format(tick).length), 2);
|
|
@@ -241,8 +256,12 @@ function layoutBars(input) {
|
|
|
241
256
|
bottom: 28,
|
|
242
257
|
left: Math.min(96, Math.max(40, longest * 7 + 14))
|
|
243
258
|
};
|
|
244
|
-
const width = Math.max(input.width,
|
|
245
|
-
const height = Math.max(input.height,
|
|
259
|
+
const width = Math.max(input.width, 1);
|
|
260
|
+
const height = Math.max(input.height, 1);
|
|
261
|
+
pad.left = Math.min(pad.left, Math.max(16, width * .46));
|
|
262
|
+
pad.right = Math.min(pad.right, Math.max(8, width * .2));
|
|
263
|
+
pad.top = Math.min(pad.top, Math.max(4, height * .16));
|
|
264
|
+
pad.bottom = Math.min(pad.bottom, Math.max(8, height * .34));
|
|
246
265
|
const plot = box(width, height, pad);
|
|
247
266
|
const legend = series.length > 1 || series.some((item) => item.name !== "Value") ? legendOf(series, palette) : legendOf(series, palette);
|
|
248
267
|
if (empty) return {
|
|
@@ -962,7 +981,7 @@ var NgxChartFrame = class NgxChartFrame {
|
|
|
962
981
|
</figure>
|
|
963
982
|
`,
|
|
964
983
|
isInline: true,
|
|
965
|
-
styles: [":host{display:
|
|
984
|
+
styles: [":host{display:flex;flex-direction:column;box-sizing:border-box;width:100%;max-width:100%;min-width:0;min-height:0;height:100%}\n"],
|
|
966
985
|
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
967
986
|
});
|
|
968
987
|
};
|
|
@@ -1034,7 +1053,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1034
1053
|
</table>
|
|
1035
1054
|
</figure>
|
|
1036
1055
|
`,
|
|
1037
|
-
styles: [":host{display:
|
|
1056
|
+
styles: [":host{display:flex;flex-direction:column;box-sizing:border-box;width:100%;max-width:100%;min-width:0;min-height:0;height:100%}\n"]
|
|
1038
1057
|
}]
|
|
1039
1058
|
}],
|
|
1040
1059
|
propDecorators: {
|
|
@@ -1141,16 +1160,22 @@ function chartBox(preferred, initialWidth = 640) {
|
|
|
1141
1160
|
const destroyRef = inject(DestroyRef);
|
|
1142
1161
|
const width = signal(initialWidth, ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
|
|
1143
1162
|
const height = signal(Math.max(1, preferred()), ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
|
|
1144
|
-
|
|
1163
|
+
let measure = () => height.set(Math.max(1, preferred()));
|
|
1164
|
+
effect(() => {
|
|
1165
|
+
preferred();
|
|
1166
|
+
measure();
|
|
1167
|
+
});
|
|
1145
1168
|
afterNextRender(() => {
|
|
1146
1169
|
const root = host.nativeElement;
|
|
1147
|
-
|
|
1170
|
+
measure = () => {
|
|
1171
|
+
const preferredH = Math.max(1, preferred());
|
|
1148
1172
|
const nextW = root.clientWidth;
|
|
1149
1173
|
if (nextW > 0) width.set(Math.round(nextW));
|
|
1174
|
+
height.set(preferredH);
|
|
1150
1175
|
};
|
|
1151
1176
|
measure();
|
|
1152
1177
|
if (typeof ResizeObserver === "undefined") return;
|
|
1153
|
-
const observer = new ResizeObserver(measure);
|
|
1178
|
+
const observer = new ResizeObserver(() => measure());
|
|
1154
1179
|
observer.observe(root);
|
|
1155
1180
|
destroyRef.onDestroy(() => observer.disconnect());
|
|
1156
1181
|
});
|
|
@@ -1881,7 +1906,7 @@ var NgxBarChart = class NgxBarChart {
|
|
|
1881
1906
|
[attr.width]="mark.width"
|
|
1882
1907
|
[attr.height]="mark.height"
|
|
1883
1908
|
[attr.fill]="mark.color"
|
|
1884
|
-
rx="3"
|
|
1909
|
+
[attr.rx]="mode() === 'stacked' ? 0 : 3"
|
|
1885
1910
|
class="cursor-pointer"
|
|
1886
1911
|
[class.ngx-grow-y]="animate() && orientation() !== 'horizontal'"
|
|
1887
1912
|
[class.ngx-grow-x]="animate() && orientation() === 'horizontal'"
|
|
@@ -1916,7 +1941,7 @@ var NgxBarChart = class NgxBarChart {
|
|
|
1916
1941
|
</ngx-chart-frame>
|
|
1917
1942
|
`,
|
|
1918
1943
|
isInline: true,
|
|
1919
|
-
styles: [":host{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0}\n"],
|
|
1944
|
+
styles: [":host{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0}\n", ":host{display:block;min-height:var(--ngx-chart-height,320px)}\n"],
|
|
1920
1945
|
dependencies: [{
|
|
1921
1946
|
kind: "component",
|
|
1922
1947
|
type: NgxChartFrame,
|
|
@@ -1985,7 +2010,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1985
2010
|
[attr.width]="mark.width"
|
|
1986
2011
|
[attr.height]="mark.height"
|
|
1987
2012
|
[attr.fill]="mark.color"
|
|
1988
|
-
rx="3"
|
|
2013
|
+
[attr.rx]="mode() === 'stacked' ? 0 : 3"
|
|
1989
2014
|
class="cursor-pointer"
|
|
1990
2015
|
[class.ngx-grow-y]="animate() && orientation() !== 'horizontal'"
|
|
1991
2016
|
[class.ngx-grow-x]="animate() && orientation() === 'horizontal'"
|
|
@@ -2019,7 +2044,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2019
2044
|
}
|
|
2020
2045
|
</ngx-chart-frame>
|
|
2021
2046
|
`,
|
|
2022
|
-
styles: [":host{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0}\n"]
|
|
2047
|
+
styles: [":host{display:block;box-sizing:border-box;width:100%;max-width:100%;min-width:0}\n", ":host{display:block;min-height:var(--ngx-chart-height,320px)}\n"]
|
|
2023
2048
|
}]
|
|
2024
2049
|
}],
|
|
2025
2050
|
propDecorators: {
|