mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 14:24:15 +08:00
fix(intraday): hide unavailable average line
This commit is contained in:
@@ -63,7 +63,7 @@ function getLimitPrices(prevClose: number, priceLimit?: PriceLimitInfo): {
|
||||
return { limitUp, limitDown, upPct, downPct }
|
||||
}
|
||||
|
||||
function buildOption(data: MinuteKlineRow[], prevClose: number | undefined, avgPrices: number[], lineColor: string, areaColor: string, yMode: YMode, ct: ChartTheme, priceLimit?: PriceLimitInfo, showLimitLines = true, showAvgLine = true, priceLines: Props['priceLines'] = []): EChartsOption {
|
||||
function buildOption(data: MinuteKlineRow[], prevClose: number | undefined, avgPrices: (number | null)[], lineColor: string, areaColor: string, yMode: YMode, ct: ChartTheme, priceLimit?: PriceLimitInfo, showLimitLines = true, showAvgLine = true, priceLines: Props['priceLines'] = []): EChartsOption {
|
||||
// 将数据映射到全天时间轴上的正确位置
|
||||
const timeIndexMap = new Map(FULL_DAY_TIMES.map((t, i) => [t, i]))
|
||||
const closes = new Array(FULL_DAY_TIMES.length).fill(null) as (number | null)[]
|
||||
@@ -601,7 +601,7 @@ export function EChartsIntraday({
|
||||
</span>
|
||||
{showAvgLine && <span className="flex items-center gap-x-1">
|
||||
<span style={{ display: 'inline-block', width: 14, height: 2, background: THEME.avgLine }} />
|
||||
<span style={{ color: THEME.avgLine }}>{avg?.toFixed(2)}</span>
|
||||
<span style={{ color: THEME.avgLine }}>{avg != null ? avg.toFixed(2) : '—'}</span>
|
||||
</span>}
|
||||
<span className="text-muted">量</span>
|
||||
<span className="text-secondary">{d.volume.toFixed(0)}</span>
|
||||
|
||||
@@ -25,7 +25,7 @@ interface Props {
|
||||
interface InfoPoint {
|
||||
date: string
|
||||
row: MinuteKlineRow
|
||||
average: number
|
||||
average: number | null
|
||||
prevClose: number | null
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ function buildModel(sessions: MinuteKlineSession[]) {
|
||||
}
|
||||
|
||||
const averagePrices = computeIntradayAverage(session.rows)
|
||||
const rowsByTime = new Map<string, { row: MinuteKlineRow; average: number }>()
|
||||
const rowsByTime = new Map<string, { row: MinuteKlineRow; average: number | null }>()
|
||||
session.rows.forEach((row, index) => {
|
||||
rowsByTime.set(formatMinuteTime(row.datetime), {
|
||||
row,
|
||||
@@ -105,7 +105,8 @@ function buildModel(sessions: MinuteKlineSession[]) {
|
||||
},
|
||||
})
|
||||
prevRef = row.close
|
||||
priceValues.push(row.low, row.high, average)
|
||||
priceValues.push(row.low, row.high)
|
||||
if (average != null) priceValues.push(average)
|
||||
pointByIndex.set(index, {
|
||||
date: session.date,
|
||||
row,
|
||||
@@ -422,7 +423,7 @@ export function EChartsMultiDayIntraday({
|
||||
{changePct != null && (
|
||||
<span style={{ color: infoColor }}>{changePct >= 0 ? '+' : ''}{changePct.toFixed(2)}%</span>
|
||||
)}
|
||||
<span className="text-muted">均价</span><span style={{ color: COLORS.average }}>{info.average.toFixed(2)}</span>
|
||||
<span className="text-muted">均价</span><span style={{ color: COLORS.average }}>{info.average != null ? info.average.toFixed(2) : '—'}</span>
|
||||
<span className="text-muted">量</span><span className="text-secondary">{info.row.volume.toFixed(0)}</span>
|
||||
<span className="text-muted">额</span><span className="text-secondary">{formatAmount(info.row.amount)}</span>
|
||||
</>
|
||||
|
||||
@@ -7,8 +7,8 @@ export function formatMinuteTime(datetime: string): string {
|
||||
return `${match[1]}:${match[2]}`
|
||||
}
|
||||
|
||||
export function computeIntradayAverage(data: MinuteKlineRow[]): number[] {
|
||||
const result: number[] = []
|
||||
export function computeIntradayAverage(data: MinuteKlineRow[]): (number | null)[] {
|
||||
const result: (number | null)[] = []
|
||||
let amount = 0
|
||||
let volume = 0
|
||||
let hasAmount = true
|
||||
@@ -19,7 +19,7 @@ export function computeIntradayAverage(data: MinuteKlineRow[]): number[] {
|
||||
hasAmount = false
|
||||
}
|
||||
volume += row.volume * 100
|
||||
result.push(hasAmount && volume > 0 ? amount / volume : row.close)
|
||||
result.push(hasAmount && volume > 0 ? amount / volume : null)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user