@qfo/qfchart 0.8.2 → 0.8.5

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.
@@ -40,6 +40,8 @@ export class ShapeRenderer implements SeriesRenderer {
40
40
  // Positioning based on location
41
41
  let yValue = val; // Default to absolute value
42
42
  let symbolOffset: (string | number)[] = [0, 0];
43
+ const isLabelUp = shape.includes('label_up') || shape === 'labelup';
44
+ const isLabelDown = shape.includes('label_down') || shape === 'labeldown';
43
45
 
44
46
  if (location === 'abovebar' || location === 'AboveBar' || location === 'ab') {
45
47
  // Shape above the candle
@@ -83,6 +85,15 @@ export class ShapeRenderer implements SeriesRenderer {
83
85
  }
84
86
  }
85
87
 
88
+ // Anchor labelup/labeldown so the arrow tip sits at the data point.
89
+ // labelup: arrow tip points up (at top of shape) → shift shape down
90
+ // labeldown: arrow tip points down (at bottom of shape) → shift shape up
91
+ if (isLabelUp) {
92
+ symbolOffset = [symbolOffset[0], '50%'];
93
+ } else if (isLabelDown) {
94
+ symbolOffset = [symbolOffset[0], '-50%'];
95
+ }
96
+
86
97
  // Get label configuration based on location
87
98
  const labelConfig = ShapeUtils.getLabelConfig(shape, location);
88
99
 
@@ -115,6 +126,7 @@ export class ShapeRenderer implements SeriesRenderer {
115
126
  type: 'scatter',
116
127
  xAxisIndex: xAxisIndex,
117
128
  yAxisIndex: yAxisIndex,
129
+ z: 10, // Render shapes in front of candles (z: 5)
118
130
  data: shapeData,
119
131
  };
120
132
  }
@@ -1,39 +1,39 @@
1
- import { SeriesRenderer, RenderContext } from './SeriesRenderer';
2
-
3
- export class StepRenderer implements SeriesRenderer {
4
- render(context: RenderContext): any {
5
- const { seriesName, xAxisIndex, yAxisIndex, dataArray, colorArray, plotOptions } = context;
6
- const defaultColor = '#2962ff';
7
-
8
- return {
9
- name: seriesName,
10
- type: 'custom',
11
- xAxisIndex: xAxisIndex,
12
- yAxisIndex: yAxisIndex,
13
- renderItem: (params: any, api: any) => {
14
- const x = api.value(0);
15
- const y = api.value(1);
16
- if (isNaN(y) || y === null) return;
17
-
18
- const coords = api.coord([x, y]);
19
- const width = api.size([1, 0])[0];
20
-
21
- return {
22
- type: 'line',
23
- shape: {
24
- x1: coords[0] - width / 2,
25
- y1: coords[1],
26
- x2: coords[0] + width / 2,
27
- y2: coords[1],
28
- },
29
- style: {
30
- stroke: colorArray[params.dataIndex] || plotOptions.color || defaultColor,
31
- lineWidth: plotOptions.linewidth || 1,
32
- },
33
- silent: true,
34
- };
35
- },
36
- data: dataArray.map((val, i) => [i, val]),
37
- };
38
- }
39
- }
1
+ import { SeriesRenderer, RenderContext } from './SeriesRenderer';
2
+
3
+ export class StepRenderer implements SeriesRenderer {
4
+ render(context: RenderContext): any {
5
+ const { seriesName, xAxisIndex, yAxisIndex, dataArray, colorArray, plotOptions } = context;
6
+ const defaultColor = '#2962ff';
7
+
8
+ return {
9
+ name: seriesName,
10
+ type: 'custom',
11
+ xAxisIndex: xAxisIndex,
12
+ yAxisIndex: yAxisIndex,
13
+ renderItem: (params: any, api: any) => {
14
+ const x = api.value(0);
15
+ const y = api.value(1);
16
+ if (isNaN(y) || y === null) return;
17
+
18
+ const coords = api.coord([x, y]);
19
+ const width = api.size([1, 0])[0];
20
+
21
+ return {
22
+ type: 'line',
23
+ shape: {
24
+ x1: coords[0] - width / 2,
25
+ y1: coords[1],
26
+ x2: coords[0] + width / 2,
27
+ y2: coords[1],
28
+ },
29
+ style: {
30
+ stroke: colorArray[params.dataIndex] || plotOptions.color || defaultColor,
31
+ lineWidth: plotOptions.linewidth || 1,
32
+ },
33
+ silent: true,
34
+ };
35
+ },
36
+ data: dataArray.map((val, i) => [i, val]),
37
+ };
38
+ }
39
+ }
@@ -47,6 +47,11 @@ export class ShapeUtils {
47
47
  case 'shape_label_up':
48
48
  return 'path://M12 1l2 3h8a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-20a1 1 0 0 1-1-1v-14a1 1 0 0 1 1-1h8z';
49
49
 
50
+ case 'labelcenter':
51
+ case 'shape_label_center':
52
+ // Rounded rectangle with no pointer — centered at anchor
53
+ return 'path://M1 1h22a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-22a1 1 0 0 1-1-1v-16a1 1 0 0 1 1-1z';
54
+
50
55
  case 'square':
51
56
  case 'shape_square':
52
57
  return 'rect';