st-comp 0.0.175 → 0.0.177

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.177",
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;
@@ -492,7 +485,11 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
492
485
  const interval = Math.abs((max - min) / 10);
493
486
  return round(min - interval);
494
487
  },
495
- max: (value) => round(value.max),
488
+ max: (value) => {
489
+ const { min, max } = value;
490
+ const interval = Math.abs((max - min) / 10);
491
+ return round(max + interval);
492
+ },
496
493
  },
497
494
  {
498
495
  show: false,
@@ -509,8 +506,10 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
509
506
  },
510
507
  ],
511
508
  series: [
509
+ // K线
512
510
  {
513
511
  type: "candlestick",
512
+ name: "kLine",
514
513
  data,
515
514
  markPoint: { data: [...tradePointData] },
516
515
  markLine: { data: [...tradeLineData] },
@@ -522,8 +521,6 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
522
521
  borderWidth: 1,
523
522
  },
524
523
  },
525
- // 指标线
526
- ...indicatorSeries,
527
524
  // 净值曲线
528
525
  {
529
526
  type: "line",
@@ -554,6 +551,8 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
554
551
  width: 2,
555
552
  },
556
553
  },
554
+ // 指标线
555
+ ...indicatorSeries,
557
556
  ],
558
557
  toolbox: {
559
558
  show: false,
@@ -582,6 +581,7 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
582
581
  */
583
582
  {
584
583
  getScreenTimeRange();
584
+ drawScreenMaxPrice();
585
585
  activeIndex.value = endValue;
586
586
  }
587
587
 
@@ -640,6 +640,70 @@ const draw = (params = { startValue: 0, endValue: 0 }) => {
640
640
  });
641
641
  }
642
642
  };
643
+ // 图表: 绘制(当屏最高价)
644
+ const drawScreenMaxPrice = () => {
645
+ const { data } = klineData.value;
646
+ const { startValue, endValue } = mainChartIns.getOption()?.dataZoom[0] ?? {};
647
+ let maxPrice = 0;
648
+ let maxPriceIndex = startValue;
649
+ for (let i = startValue; i <= endValue; i++) {
650
+ if (Number(data[i][3]) >= maxPrice) {
651
+ maxPrice = Number(data[i][3]);
652
+ maxPriceIndex = i;
653
+ }
654
+ }
655
+ const originOption = mainChartIns.getOption();
656
+ const filterSeries = originOption.series?.filter((item) => item.name !== "maxPrice") || [];
657
+ const dataLength = endValue - startValue;
658
+ const positionInView = (maxPriceIndex - startValue) / dataLength;
659
+ let position = "right";
660
+ let formatter = `←${maxPrice}`;
661
+ if (positionInView > 0.7) {
662
+ position = "left";
663
+ formatter = `${maxPrice}→`;
664
+ } else {
665
+ position = "right";
666
+ formatter = `←${maxPrice}`;
667
+ }
668
+ mainChartIns?.setOption(
669
+ {
670
+ ...originOption,
671
+ series: [
672
+ ...filterSeries,
673
+ {
674
+ type: "line",
675
+ name: "maxPrice",
676
+ markPoint: {
677
+ // 点位原本样式通过透明去进行隐藏, 从而仅展示文案
678
+ symbol: "circle",
679
+ symbolSize: 1,
680
+ itemStyle: {
681
+ color: "transparent",
682
+ borderColor: "transparent",
683
+ },
684
+ z: 100, // 设置较高的 z 值,确保在最上层
685
+ zlevel: 10, // 设置较高的 zlevel
686
+ label: {
687
+ show: true,
688
+ position,
689
+ formatter,
690
+ color: "#fff",
691
+ fontSize: 12,
692
+ padding: [4, -4],
693
+ },
694
+ data: [
695
+ {
696
+ name: "最高点",
697
+ coord: [maxPriceIndex, maxPrice],
698
+ },
699
+ ],
700
+ },
701
+ },
702
+ ],
703
+ },
704
+ true
705
+ );
706
+ };
643
707
 
644
708
  // 拖拽轴: 拖拽回调
645
709
  const handleSliderChange = (params) => {
@@ -74,12 +74,12 @@ const cycleOptions = [
74
74
  { label: "1mon", value: "8" },
75
75
  ];
76
76
 
77
- const varietyName = ref("棉花");
78
- const varietyCode = ref("CF");
79
- const varietyStock = ref(0); // 0: 期货, 1: 股票, 2: 期权
77
+ const varietyName = ref("国债指数");
78
+ const varietyCode = ref("Z000012");
79
+ const varietyStock = ref(1); // 0: 期货, 1: 股票, 2: 期权
80
80
  const tradeLog = ref(tradeLogMock);
81
81
  const netPositionData = ref([]);
82
- const cycle = ref("6");
82
+ const cycle = ref("5");
83
83
  const sellBuy = ref(1);
84
84
  const rightType = ref(1);
85
85
  const klineType = ref(0);