@pushwoosh/kit-charts 0.0.17 → 0.0.18
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.
|
@@ -81,6 +81,9 @@ const emptyExtent = () => ({
|
|
|
81
81
|
min: Infinity,
|
|
82
82
|
max: -Infinity
|
|
83
83
|
});
|
|
84
|
+
// Below four intervals the nice step jumps a whole magnitude and a count axis
|
|
85
|
+
// degenerates to two labels; a short card asks for fewer than that.
|
|
86
|
+
const MIN_Y_TICK_HINT = 4;
|
|
84
87
|
const grow = (extent, value) => {
|
|
85
88
|
if (value === null || !Number.isFinite(value)) {
|
|
86
89
|
return;
|
|
@@ -561,7 +564,7 @@ export function buildChartModel({
|
|
|
561
564
|
stacks
|
|
562
565
|
});
|
|
563
566
|
const yAxisModels = yAxes.reduce((built, axis, index) => {
|
|
564
|
-
const hint = axis.tickAmount ?? 5;
|
|
567
|
+
const hint = axis.tickAmount ?? (axis.tickPixelInterval ? Math.max(MIN_Y_TICK_HINT, Math.round(plot.height / axis.tickPixelInterval)) : 5);
|
|
565
568
|
const target = axis.linkedTo === undefined ? undefined : built[axis.linkedTo];
|
|
566
569
|
const range = axis.categories?.length ? [plot.y, plot.y + plot.height] : [plot.y + plot.height, plot.y];
|
|
567
570
|
const scale = buildYScale(axis, yDomains[index] ?? emptyExtent(), range, hint, target?.scale);
|
package/core/types/options.d.ts
CHANGED
|
@@ -150,6 +150,7 @@ export interface AxisOptions {
|
|
|
150
150
|
tickLength?: number;
|
|
151
151
|
tickAmount?: number;
|
|
152
152
|
tickInterval?: number | TimeUnit;
|
|
153
|
+
/** Space a tick asks for: across the plot on an x axis, down it on a y one. */
|
|
153
154
|
tickPixelInterval?: number;
|
|
154
155
|
tickPositions?: readonly number[];
|
|
155
156
|
gridLineWidth?: number;
|