@wick-charts/vue 0.4.0 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wick-charts/vue",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "High-performance canvas timeseries charts for Vue — candlestick, line, bar, pie. Tree-shakeable, zero runtime deps.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -45,7 +45,7 @@
45
45
  "vue": ">=3.3.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@wick-charts/core": "^0.4.0"
48
+ "@wick-charts/core": "^0.4.2"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "vite build"
@@ -22,10 +22,20 @@ export function useYRange(chart: ChartInstance): Ref<YRange> {
22
22
  }
23
23
 
24
24
  export function useLastYValue(chart: ChartInstance, seriesId: string): Ref<{ value: number; isLive: boolean } | null> {
25
- const val = ref<{ value: number; isLive: boolean } | null>(chart.getLastValue(seriesId));
25
+ let snapshot = chart.getLastValue(seriesId);
26
+ // Track the pixel Y the snapshot maps to so a pan/zoom/resize that leaves the
27
+ // value unchanged but shifts the badge still re-emits — a consumer-positioned
28
+ // badge reads `yScale.valueToY` off this ref. Comparing prev/next against the
29
+ // live yScale alone would always be equal.
30
+ let lastY = snapshot ? chart.yScale.valueToY(snapshot.value) : null;
31
+ const val = ref<{ value: number; isLive: boolean } | null>(snapshot);
26
32
  const handler = () => {
27
33
  const next = chart.getLastValue(seriesId);
28
- if (val.value?.value === next?.value && val.value?.isLive === next?.isLive) return;
34
+ const nextY = next ? chart.yScale.valueToY(next.value) : null;
35
+ if (snapshot?.value === next?.value && snapshot?.isLive === next?.isLive && lastY === nextY) return;
36
+
37
+ snapshot = next;
38
+ lastY = nextY;
29
39
  val.value = next;
30
40
  };
31
41
  onMounted(() => {
package/src/index.ts CHANGED
@@ -11,17 +11,25 @@
11
11
  export type {
12
12
  AxisBound,
13
13
  AxisConfig,
14
+ BarPaintArgs,
15
+ BarPainter,
14
16
  BarSeriesOptions,
15
17
  /** @deprecated Use {@link StackingMode} instead. */
16
18
  BuildHoverSnapshotsArgs,
17
19
  BuildLastSnapshotsArgs,
20
+ CandlePaintArgs,
21
+ CandlePainter,
18
22
  CandlestickSeriesOptions,
19
23
  ChartLayout,
20
24
  ChartOptions,
21
25
  ChartTheme,
26
+ CornerMask,
22
27
  CrosshairPosition,
28
+ CurveKind,
23
29
  HoverInfo,
24
30
  LegendItem,
31
+ LinePaintArgs,
32
+ LinePainter,
25
33
  /** @deprecated Use {@link TimePoint} instead. */
26
34
  LineSeriesOptions,
27
35
  NavigatorCandlePoint,
@@ -32,8 +40,10 @@ export type {
32
40
  NavigatorSeriesType,
33
41
  OHLCData,
34
42
  OHLCInput,
43
+ PaintEnv,
35
44
  PieSeriesOptions,
36
45
  PieSliceData,
46
+ RoundedRectArgs,
37
47
  SeriesSnapshot,
38
48
  SeriesType,
39
49
  SliceInfo,
@@ -48,6 +58,7 @@ export type {
48
58
  TooltipFormatter,
49
59
  TooltipPosition,
50
60
  TooltipPositionArgs,
61
+ TracePathArgs,
51
62
  Typography,
52
63
  ValueFormatter,
53
64
  VisibleRange,
@@ -55,6 +66,7 @@ export type {
55
66
  YAxisConfig,
56
67
  YRange,
57
68
  } from '@wick-charts/core';
69
+ // Painters — custom per-element drawing for bar / candle / line series.
58
70
  export {
59
71
  ChartInstance,
60
72
  NavigatorController,
@@ -68,6 +80,7 @@ export {
68
80
  createTheme,
69
81
  detectInterval,
70
82
  dracula,
83
+ fillRoundedRect,
71
84
  formatCompact,
72
85
  formatDate,
73
86
  formatPriceAdaptive,
@@ -92,8 +105,14 @@ export {
92
105
  resolveAxisTextColor,
93
106
  resolveCandlestickBodyColor,
94
107
  rosePineDawn,
108
+ roundedBarFill,
109
+ roundedCandleFill,
95
110
  sandDune,
111
+ smoothCurve,
96
112
  solarizedLight,
113
+ steppedCurve,
114
+ straightCurve,
115
+ tracePath,
97
116
  } from '@wick-charts/core';
98
117
 
99
118
  export { default as BarSeries } from './BarSeries.vue';
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { formatTime } from '@wick-charts/core';
3
- import { computed } from 'vue';
3
+ import { computed, onMounted, onUnmounted, ref } from 'vue';
4
4
 
5
5
  import { useCrosshairPosition } from '../composables';
6
6
  import { useChartInstance } from '../context';
@@ -8,8 +8,33 @@ import { useChartInstance } from '../context';
8
8
  const chart = useChartInstance();
9
9
  const position = useCrosshairPosition(chart);
10
10
 
11
- const theme = computed(() => chart.getTheme());
11
+ // `setTheme` fires `overlayChange`; bump re-runs the theme computed so the
12
+ // label colors track a runtime theme swap instead of freezing on the
13
+ // first-render snapshot (matches Tooltip/PieTooltip).
14
+ const bump = ref(0);
15
+ const onOverlayChange = () => {
16
+ bump.value++;
17
+ };
18
+ onMounted(() => chart.on('overlayChange', onOverlayChange));
19
+ onUnmounted(() => chart.off('overlayChange', onOverlayChange));
20
+
21
+ const theme = computed(() => {
22
+ void bump.value;
23
+
24
+ return chart.getTheme();
25
+ });
12
26
  const dataInterval = computed(() => chart.getDataInterval());
27
+ // Format the time pill at the axis's *resolved* tick granularity, not the raw
28
+ // data interval — otherwise a time-of-day badge floats among date labels when
29
+ // zoomed out. `niceTickValues` reads the live visible range, which Vue can't
30
+ // track reactively, so depend on `position` (a wheel-zoom re-emits the
31
+ // crosshair) to re-resolve on zoom — matching React, which recomputes this on
32
+ // every render. Falls back to dataInterval on a degenerate range.
33
+ const tickInterval = computed(() => {
34
+ void position.value;
35
+
36
+ return chart.timeScale.niceTickValues(dataInterval.value).tickInterval || dataInterval.value;
37
+ });
13
38
 
14
39
  const labelStyle = computed(() => ({
15
40
  // Blend the theme's labelBackground at 80% opacity so the axis grid
@@ -54,7 +79,7 @@ const labelStyle = computed(() => ({
54
79
  ...labelStyle,
55
80
  }"
56
81
  >
57
- {{ formatTime(position.time, dataInterval) }}
82
+ {{ formatTime(position.time, tickInterval) }}
58
83
  </div>
59
84
  </template>
60
85
  </template>