@wick-charts/vue 0.3.0 → 0.3.2

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/src/ui/YAxis.vue CHANGED
@@ -8,6 +8,13 @@ import { useChartInstance } from '../context';
8
8
  const props = defineProps<{
9
9
  /** Custom tick-label formatter. Overrides the built-in range-adaptive default. */
10
10
  format?: ValueFormatter;
11
+ /**
12
+ * Desired number of labels (≥ 2). Overrides any chart-level `axis.y.labelCount`.
13
+ * Realized count may differ ±1 after the 1-2-5 snap.
14
+ */
15
+ labelCount?: number;
16
+ /** Minimum pixel gap between adjacent labels (hard floor). Overrides chart-level. */
17
+ minLabelSpacing?: number;
11
18
  }>();
12
19
 
13
20
  interface TrackedTick {
@@ -26,6 +33,18 @@ onMounted(syncFormat);
26
33
  watch(() => props.format, syncFormat);
27
34
  onUnmounted(() => chart.yScale.setFormat(null));
28
35
 
36
+ const applyDensity = () => {
37
+ chart.setYAxisLabelDensity({
38
+ labelCount: props.labelCount ?? null,
39
+ minLabelSpacing: props.minLabelSpacing ?? null,
40
+ });
41
+ };
42
+ // Run during setup (before first paint) to match TimeAxis.vue and avoid a
43
+ // post-mount density change that would cause a visible tick "jump".
44
+ applyDensity();
45
+ watch(() => [props.labelCount, props.minLabelSpacing], applyDensity);
46
+ onUnmounted(() => chart.setYAxisLabelDensity({ labelCount: null, minLabelSpacing: null }));
47
+
29
48
  const tickMap = new Map<number, TrackedTick>();
30
49
 
31
50
  const theme = computed(() => chart.getTheme());