10.10综合交易所原始源码_移动端
1
2026-05-26 0dbc7465447164fef24327b5d494870832d798dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
  <div class="mini-kline-chart">
    <svg
      v-if="linePoints"
      class="mini-kline-svg"
      viewBox="0 0 100 40"
      preserveAspectRatio="none"
    >
      <!-- 折线:用收盘价连成线 -->{{ linePoints }}
      <polyline
        :points="linePoints"
        fill="none"
        :stroke="lineColor"
        stroke-width="1.2"
        stroke-linecap="round"
        stroke-linejoin="round"
      />
    </svg>
  </div>
</template>
 
<script setup>
import { computed } from 'vue'
 
const props = defineProps({
  /** K线/行情数据,每项 [open, close, low, high],折线取 close */
  data: {
    type: Array,
    default: () => []
  },
  /** 涨跌,用于颜色:true 红涨绿跌,false 绿涨红跌 */
  up: {
    type: Boolean,
    default: true
  }
})
 
const upColor = '#E35561'
const downColor = '#11caa1'
 
const lineColor = computed(() => (props.up ? upColor : downColor))
 
const linePoints = computed(() => {
  const list = props.data || []
  if (!list.length) return ''
  const closes = list.map((d) => d[1])
  const min = Math.min(...closes)
  const max = Math.max(...closes)
  const range = max - min || 1
  const n = list.length
  const pad = 2
  const chartH = 40 - pad * 2
  const stepX = n > 1 ? 100 / (n - 1) : 0
 
  return list
    .map((d, i) => {
      const close = d[1]
      const x = n === 1 ? 50 : stepX * i
      const y = pad + (1 - (close - min) / range) * chartH
      return `${x},${y}`
    })
    .join(' ')
})
</script>
 
<style lang="scss" scoped>
.mini-kline-chart {
  width: 100%;
  height: 2.5rem;
  min-height: 2rem;
}
 
.mini-kline-svg {
  width: 100%;
  height: 100%;
  display: block;
}
</style>