st-comp 0.0.175 → 0.0.176

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,7 +1,7 @@
1
1
  {
2
2
  "name": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.175",
4
+ "version": "0.0.176",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -27,6 +27,7 @@ export const getDefaultUserKlineConfig = () => {
27
27
  */
28
28
  enable_tradeLogBrush: true, // 高亮交易范围
29
29
  enable_showScreenTimeRange: true, // 展示当屏时间范围
30
+ enable_showScreenMaxPrice: true, // 展示当屏最高价
30
31
  enable_dbClickOpenSingel: true, // 多周期双击图表切换至单周期
31
32
 
32
33
  /**
@@ -183,6 +183,10 @@ defineExpose({
183
183
  <span class="label">展示当屏时间: </span>
184
184
  <el-switch v-model="form.enable_showScreenTimeRange" />
185
185
  </div>
186
+ <div class="setting-item">
187
+ <span class="label">展示当屏最高价: </span>
188
+ <el-switch v-model="form.enable_showScreenMaxPrice" />
189
+ </div>
186
190
  <div class="setting-item">
187
191
  <span class="label">多周期双击图表切换至单周期: </span>
188
192
  <el-switch v-model="form.enable_dbClickOpenSingel" />
@@ -4,16 +4,7 @@ import dayjs from "dayjs";
4
4
  import * as echarts from "echarts";
5
5
  import { stMath, debounce, addResizeListener } from "st-func";
6
6
  import { ref, watch, computed, onMounted, onUnmounted, inject } from "vue";
7
- import {
8
- loadKlineConfig,
9
- checkTimeInterval,
10
- getSubOptions,
11
- mergeklineData,
12
- handleMarkPointTradeLog,
13
- handleNetPositionLine,
14
- handleTradeIncomeRateLine,
15
- normalizeToKlineTimeByMatch,
16
- } from "./utils.js";
7
+ import { loadKlineConfig, checkTimeInterval, getSubOptions, mergeklineData, handleMarkPointTradeLog, handleNetPositionLine, handleTradeIncomeRateLine, normalizeToKlineTimeByMatch } from "./utils.js";
17
8
  import Tips from "./components/Tips.vue";
18
9
  import SliderChart from "./components/SliderChart.vue";
19
10
 
@@ -145,6 +136,7 @@ const initChart = () => {
145
136
  // 当前结束索引 > 阈值边界, 触发加载更多数据
146
137
  if (isLoadNew === false && isloadAllNew === false && endValue > klineData.value.time.length - loadCheckCount) await getMoreData("new");
147
138
  getScreenTimeRange();
139
+ drawScreenMaxPrice();
148
140
  })
149
141
  );
150
142
  mainChartIns.on("globalout", () => {
@@ -317,7 +309,8 @@ const getScreenTimeRange = () => {
317
309
  screenTimeRange.value = [startTime, endTime];
318
310
  }
319
311
  };
320
- // 图表: 绘制
312
+
313
+ // 图表: 绘制(主流程)
321
314
  const draw = (params = { startValue: 0, endValue: 0 }) => {
322
315
  initChart();
323
316
  const { maxValueSpan } = loadKlineConfig;
@@ -509,8 +502,10 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
509
502
  },
510
503
  ],
511
504
  series: [
505
+ // K线
512
506
  {
513
507
  type: "candlestick",
508
+ name: "kLine",
514
509
  data,
515
510
  markPoint: { data: [...tradePointData] },
516
511
  markLine: { data: [...tradeLineData] },
@@ -522,8 +517,6 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
522
517
  borderWidth: 1,
523
518
  },
524
519
  },
525
- // 指标线
526
- ...indicatorSeries,
527
520
  // 净值曲线
528
521
  {
529
522
  type: "line",
@@ -554,6 +547,8 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
554
547
  width: 2,
555
548
  },
556
549
  },
550
+ // 指标线
551
+ ...indicatorSeries,
557
552
  ],
558
553
  toolbox: {
559
554
  show: false,
@@ -582,6 +577,7 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
582
577
  */
583
578
  {
584
579
  getScreenTimeRange();
580
+ drawScreenMaxPrice();
585
581
  activeIndex.value = endValue;
586
582
  }
587
583
 
@@ -640,6 +636,71 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
640
636
  });
641
637
  }
642
638
  };
639
+ // 图表: 绘制(当屏最高价)
640
+ const drawScreenMaxPrice = () => {
641
+ const { data } = klineData.value;
642
+ const { startValue, endValue } = mainChartIns.getOption()?.dataZoom[0] ?? {};
643
+ let maxPrice = 0;
644
+ let maxPriceIndex = startValue;
645
+ for (let i = startValue; i <= endValue; i++) {
646
+ if (Number(data[i][3]) >= maxPrice) {
647
+ maxPrice = Number(data[i][3]);
648
+ maxPriceIndex = i;
649
+ }
650
+ }
651
+
652
+ const originOption = mainChartIns.getOption();
653
+ const filterSeries = originOption.series?.filter((item) => item.name !== "maxPrice") || [];
654
+ const dataLength = endValue - startValue;
655
+ const positionInView = (maxPriceIndex - startValue) / dataLength;
656
+ let position = "right";
657
+ let formatter = `←${maxPrice}`;
658
+ if (positionInView > 0.7) {
659
+ position = "left";
660
+ formatter = `${maxPrice}→`;
661
+ } else {
662
+ position = "right";
663
+ formatter = `←${maxPrice}`;
664
+ }
665
+ mainChartIns?.setOption(
666
+ {
667
+ ...originOption,
668
+ series: [
669
+ ...filterSeries,
670
+ {
671
+ type: "line",
672
+ name: "maxPrice",
673
+ markPoint: {
674
+ // 点位原本样式通过透明去进行隐藏, 从而仅展示文案
675
+ symbol: "circle",
676
+ symbolSize: 1,
677
+ itemStyle: {
678
+ color: "transparent",
679
+ borderColor: "transparent",
680
+ },
681
+ z: 100, // 设置较高的 z 值,确保在最上层
682
+ zlevel: 10, // 设置较高的 zlevel
683
+ label: {
684
+ show: true,
685
+ position,
686
+ formatter,
687
+ color: "#fff",
688
+ fontSize: 12,
689
+ padding: [4, -4],
690
+ },
691
+ data: [
692
+ {
693
+ name: "最高点",
694
+ coord: [maxPriceIndex, maxPrice],
695
+ },
696
+ ],
697
+ },
698
+ },
699
+ ],
700
+ },
701
+ true
702
+ );
703
+ };
643
704
 
644
705
  // 拖拽轴: 拖拽回调
645
706
  const handleSliderChange = (params) => {