Volume Profile
Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码
预览
BTC / USD
Volume by price · Demo data
Total volume 2,271POC $65,050Value area $64,700–$65,400
用法
vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { VolumeProfile, Tabs } from 'beui-vue'
const sessions = [
{ value: 'today', label: 'Today', volumes: [18,27,36,52,70,96,135,172,205,241,278,225,192,146,108,79,56,42,31,22,16,11,8,5] },
{ value: 'previous', label: 'Previous', volumes: [6,9,13,18,27,40,56,74,95,114,146,188,242,286,253,208,165,126,92,65,42,30,21,14] },
{ value: 'week', label: 'Week', volumes: [75,104,143,214,305,382,494,626,795,902,1028,1182,1097,973,825,695,589,481,372,289,195,154,119,84] },
]
const session = ref('today')
const data = computed(() => sessions.find(item => item.value === session.value)!.volumes.map((volume, index) => ({
id: `price-${64000 + index * 100}`, priceLow: 64000 + index * 100, priceHigh: 64100 + index * 100, volume,
})))
const usd = (value: number) => value.toLocaleString('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 })
</script>
<template><div class="chart-demo" style="max-width:36rem"><header><div><strong>BTC / USD</strong><p>Volume by price · Demo data</p></div><Tabs v-model="session" :items="sessions" :labels="{ list: 'Profile session' }" /></header>
<VolumeProfile label="BTC volume profile" unit="BTC" :data="data" :format-price="usd" :format-volume="value => value.toLocaleString('en-US', { maximumFractionDigits: 2 })" />
</div></template>
<style scoped>
.chart-demo { width: 100%; min-width: 0; margin-inline: auto; }
.chart-demo > header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 20px; }
.chart-demo header strong { font-size: 14px; font-weight: 500; }
.chart-demo header p, .chart-demo > p { margin: 4px 0 0; color: var(--beui-muted-foreground); font-size: 12px; line-height: 16px; }
.chart-demo header button,.chart-demo fieldset button { padding: 6px 12px; background: transparent; border: 0; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }
.chart-demo header button:hover,.chart-demo fieldset button[aria-pressed=true] { background: var(--beui-muted); }
.chart-demo > footer { margin-top: 24px; text-align: center; color: var(--beui-muted-foreground); font-size: 11px; }
.chart-demo .sim { margin-left: 6px; border: 1px solid var(--beui-border); padding: 2px 5px; border-radius: 3px; text-transform: uppercase; font-size: 9px; letter-spacing: .05em; color: var(--beui-muted-foreground); }
</style>API
data 提供互不重叠的价格区间与成交量,valueArea 设置价值区间覆盖比例或 false。v-model:active-id 同步选中区间。