mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(stock):优化分时图展示效果
- 重新设计分时图布局和样式,增加更多图表元素 - 添加开盘价、收盘价等关键信息显示 - 实现分时图自动刷新功能 - 优化模态框样式,调整图表尺寸 - 重构相关函数,提高代码可维护性
This commit is contained in:
parent
df989b706b
commit
58d93c76f6
@ -119,7 +119,9 @@ const data = reactive({
|
|||||||
loading: true,
|
loading: true,
|
||||||
enableDanmu: false,
|
enableDanmu: false,
|
||||||
darkTheme:false,
|
darkTheme:false,
|
||||||
|
changePercent:0
|
||||||
})
|
})
|
||||||
|
const feishiInterval= ref(null)
|
||||||
const currentGroupId=ref(0)
|
const currentGroupId=ref(0)
|
||||||
const theme=computed(() => {
|
const theme=computed(() => {
|
||||||
return data.darkTheme ? 'dark' : 'light'
|
return data.darkTheme ? 'dark' : 'light'
|
||||||
@ -246,6 +248,7 @@ onBeforeUnmount(() => {
|
|||||||
ws.value.close()
|
ws.value.close()
|
||||||
message.destroyAll()
|
message.destroyAll()
|
||||||
notify.destroyAll()
|
notify.destroyAll()
|
||||||
|
clearInterval(feishiInterval.value)
|
||||||
})
|
})
|
||||||
|
|
||||||
EventsOn("refresh",(data)=>{
|
EventsOn("refresh",(data)=>{
|
||||||
@ -587,60 +590,62 @@ function setStock(code,name){
|
|||||||
formModel.value.cron=res[0].Cron
|
formModel.value.cron=res[0].Cron
|
||||||
modalShow.value=true
|
modalShow.value=true
|
||||||
}
|
}
|
||||||
|
function clearFeishi(){
|
||||||
function showFenshi(code,name){
|
console.log("clearFeishi")
|
||||||
data.code=code
|
clearInterval(feishiInterval.value)
|
||||||
data.name=name
|
}
|
||||||
data.fenshiURL='http://image.sinajs.cn/newchart/min/n/'+data.code+'.gif'+"?t="+Date.now()
|
function showFsChart(code, name) {
|
||||||
|
data.name = name
|
||||||
if(code.startsWith('hk')){
|
data.code = code
|
||||||
data.fenshiURL='http://image.sinajs.cn/newchart/hk_stock/min/'+data.code.replace("hk","")+'.gif'+"?t="+Date.now()
|
const chart = echarts.init(kLineChartRef2.value);
|
||||||
}
|
GetStockMinutePriceLineData(code, name).then(result => {
|
||||||
if(code.startsWith('gb_')){
|
// console.log("GetStockMinutePriceLineData", result)
|
||||||
data.fenshiURL='http://image.sinajs.cn/newchart/usstock/min/'+data.code.replace("gb_","")+'.gif'+"?t="+Date.now()
|
const priceData = result.priceData
|
||||||
}
|
let category = []
|
||||||
|
let price = []
|
||||||
modalShow2.value=true
|
let openprice=0
|
||||||
|
let closeprice=0
|
||||||
GetStockMinutePriceLineData(code,name).then(result => {
|
let volume = []
|
||||||
console.log("GetStockMinutePriceLineData",result)
|
let volumeRate = []
|
||||||
const priceData=result.priceData
|
let min = 0
|
||||||
const chart = echarts.init(kLineChartRef2.value);
|
let max = 0
|
||||||
let category=[]
|
openprice=priceData[0].price
|
||||||
let price=[]
|
closeprice=priceData[priceData.length-1].price
|
||||||
let volume=[]
|
|
||||||
let min=0
|
|
||||||
let max=0
|
|
||||||
for (let i = 0; i < priceData.length; i++) {
|
for (let i = 0; i < priceData.length; i++) {
|
||||||
category.push(priceData[i].time)
|
category.push(priceData[i].time)
|
||||||
price.push(priceData[i].price)
|
price.push(priceData[i].price)
|
||||||
if(min===0||min>priceData[i].price){
|
if (min === 0 || min > priceData[i].price) {
|
||||||
min=priceData[i].price
|
min = priceData[i].price
|
||||||
}
|
}
|
||||||
if(max<priceData[i].price){
|
if (max < priceData[i].price) {
|
||||||
max=priceData[i].price
|
max = priceData[i].price
|
||||||
}
|
}
|
||||||
if(i>0){
|
if (i > 0) {
|
||||||
volume.push(priceData[i].volume-priceData[i-1].volume)
|
let b=priceData[i].volume - priceData[i - 1].volume
|
||||||
}else{
|
volumeRate.push(((b-volume[i-1])/volume[i-1]*100).toFixed(2))
|
||||||
|
volume.push(b)
|
||||||
|
} else {
|
||||||
volume.push(priceData[i].volume)
|
volume.push(priceData[i].volume)
|
||||||
|
volumeRate.push(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let option = {
|
let option = {
|
||||||
title: {
|
title: {
|
||||||
text: result.date,
|
subtext: "["+result.date+"] 开盘:"+openprice+" 收盘:"+closeprice+" 最高:"+max+" 最低:"+min,
|
||||||
left: 'center',
|
left: 'center',
|
||||||
|
top: '10',
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: data.darkTheme?'#ccc':'#456'
|
color: data.darkTheme ? '#ccc' : '#456'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
data: ['股价', '成交量'],
|
data: ['股价', '成交量'],
|
||||||
|
//orient: 'vertical',
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: data.darkTheme?'#ccc':'#456'
|
color: data.darkTheme ? '#ccc' : '#456'
|
||||||
},
|
},
|
||||||
right: 20,
|
right: 50,
|
||||||
},
|
},
|
||||||
darkMode: data.darkTheme,
|
darkMode: data.darkTheme,
|
||||||
tooltip: {
|
tooltip: {
|
||||||
@ -653,51 +658,191 @@ function showFenshi(code,name){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
xAxis: {
|
axisPointer: {
|
||||||
type: 'category',
|
link: [
|
||||||
data: category
|
|
||||||
},
|
|
||||||
yAxis: [
|
|
||||||
{
|
{
|
||||||
name:"股价",
|
xAxisIndex: 'all'
|
||||||
min: min-1,
|
}
|
||||||
max: max+1,
|
],
|
||||||
minInterval:0.01,
|
label: {
|
||||||
type: 'value'
|
backgroundColor: '#888'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xAxis: [
|
||||||
|
{
|
||||||
|
type: 'category',
|
||||||
|
data: category,
|
||||||
|
axisLabel: {
|
||||||
|
show: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"成交量",
|
gridIndex: 1,
|
||||||
type: 'value',
|
type: 'category',
|
||||||
}
|
data: category,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
grid: [
|
||||||
|
{
|
||||||
|
left: '8%',
|
||||||
|
right: '8%',
|
||||||
|
height: '50%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
left: '8%',
|
||||||
|
right: '8%',
|
||||||
|
top: '70%',
|
||||||
|
height: '15%'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
yAxis: [
|
||||||
|
{
|
||||||
|
axisLine: {
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
name: "股价",
|
||||||
|
min: min - 1,
|
||||||
|
max: max + 1,
|
||||||
|
minInterval: 0.01,
|
||||||
|
type: 'value'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gridIndex: 1,
|
||||||
|
axisLine: {
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
splitLine: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
name: "成交量",
|
||||||
|
type: 'value',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
visualMap: {
|
||||||
|
type: 'piecewise',
|
||||||
|
seriesIndex:0,
|
||||||
|
top: 0,
|
||||||
|
left: 10,
|
||||||
|
orient: 'horizontal',
|
||||||
|
textStyle: {
|
||||||
|
color: data.darkTheme ? '#fff' : '#456'
|
||||||
|
},
|
||||||
|
pieces: [
|
||||||
|
{
|
||||||
|
text: '低于开盘价',
|
||||||
|
gt: 0,
|
||||||
|
lte: openprice,
|
||||||
|
color: '#31F113',
|
||||||
|
textStyle: {
|
||||||
|
color: data.darkTheme ? '#fff' : '#456'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '大于开盘价小于收盘价',
|
||||||
|
gt: openprice,
|
||||||
|
lte: closeprice,
|
||||||
|
color: '#1651EF',
|
||||||
|
textStyle: {
|
||||||
|
color: data.darkTheme ? '#fff' : '#456'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '大于收盘价',
|
||||||
|
gt: closeprice,
|
||||||
|
color: '#AC3B2A',
|
||||||
|
textStyle: {
|
||||||
|
color: data.darkTheme ? '#fff' : '#456'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
name:"股价",
|
name: "股价",
|
||||||
data: price,
|
data: price,
|
||||||
type: 'line',
|
type: 'line',
|
||||||
smooth: false,
|
smooth: false,
|
||||||
showSymbol: false,
|
showSymbol: false,
|
||||||
|
lineStyle: {
|
||||||
|
width: 3
|
||||||
|
},
|
||||||
markPoint: {
|
markPoint: {
|
||||||
|
symbol: 'arrow',
|
||||||
|
symbolRotate:90,
|
||||||
|
symbolSize: [10,20],
|
||||||
|
symbolOffset: [10, 0],
|
||||||
|
itemStyle: {
|
||||||
|
color: '#FC290D'
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
position: 'right',
|
||||||
|
},
|
||||||
data: [
|
data: [
|
||||||
{ type: 'max', name: 'Max' },
|
{type: 'max', name: 'Max'},
|
||||||
{ type: 'min', name: 'Min' }
|
{type: 'min', name: 'Min'}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
markLine: {
|
markLine: {
|
||||||
data: [{ type: 'average', name: 'Avg' }]
|
symbol: 'none',
|
||||||
}
|
data: [
|
||||||
|
{ type: 'average', name: 'Average' },
|
||||||
|
{
|
||||||
|
lineStyle:{
|
||||||
|
color: '#FFCB00',
|
||||||
|
width: 0.5
|
||||||
|
},
|
||||||
|
yAxis: openprice,
|
||||||
|
name: '开盘价'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
yAxis: closeprice ,
|
||||||
|
symbol: 'none',
|
||||||
|
lineStyle:{
|
||||||
|
color: 'red',
|
||||||
|
width: 0.5
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
xAxisIndex: 1,
|
||||||
yAxisIndex: 1,
|
yAxisIndex: 1,
|
||||||
name:"成交量",
|
name: "成交量",
|
||||||
data: volume,
|
data: volume,
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
}
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
chart.setOption(option);
|
chart.setOption(option);
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function showFenshi(code,name,changePercent){
|
||||||
|
data.code=code
|
||||||
|
data.name=name
|
||||||
|
data.changePercent=changePercent
|
||||||
|
data.fenshiURL='http://image.sinajs.cn/newchart/min/n/'+data.code+'.gif'+"?t="+Date.now()
|
||||||
|
|
||||||
|
if(code.startsWith('hk')){
|
||||||
|
data.fenshiURL='http://image.sinajs.cn/newchart/hk_stock/min/'+data.code.replace("hk","")+'.gif'+"?t="+Date.now()
|
||||||
|
}
|
||||||
|
if(code.startsWith('gb_')){
|
||||||
|
data.fenshiURL='http://image.sinajs.cn/newchart/usstock/min/'+data.code.replace("gb_","")+'.gif'+"?t="+Date.now()
|
||||||
|
}
|
||||||
|
|
||||||
|
modalShow2.value=true
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleFeishi(){
|
||||||
|
showFsChart(data.code, data.name);
|
||||||
|
feishiInterval.value=setInterval(() => {
|
||||||
|
showFsChart(data.code, data.name);
|
||||||
|
}, 1000*10)
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateMA(dayCount,values) {
|
function calculateMA(dayCount,values) {
|
||||||
@ -1526,7 +1671,7 @@ function delStockGroup(code,name,groupId){
|
|||||||
<n-flex justify="space-between">
|
<n-flex justify="space-between">
|
||||||
<n-text :type="'info'">{{result["日期"]+" "+result["时间"]}}</n-text>
|
<n-text :type="'info'">{{result["日期"]+" "+result["时间"]}}</n-text>
|
||||||
<n-button size="tiny" type="info" @click="setStock(result['股票代码'],result['股票名称'])"> 成本 </n-button>
|
<n-button size="tiny" type="info" @click="setStock(result['股票代码'],result['股票名称'])"> 成本 </n-button>
|
||||||
<n-button size="tiny" type="success" @click="showFenshi(result['股票代码'],result['股票名称'])"> 分时 </n-button>
|
<n-button size="tiny" type="success" @click="showFenshi(result['股票代码'],result['股票名称'],result.changePercent)"> 分时 </n-button>
|
||||||
<n-button size="tiny" type="error" @click="showK(result['股票代码'],result['股票名称'])"> 日K </n-button>
|
<n-button size="tiny" type="error" @click="showK(result['股票代码'],result['股票名称'])"> 日K </n-button>
|
||||||
<n-button size="tiny" type="warning" @click="search(result['股票代码'],result['股票名称'])"> 详情 </n-button>
|
<n-button size="tiny" type="warning" @click="search(result['股票代码'],result['股票名称'])"> 详情 </n-button>
|
||||||
<n-dropdown trigger="click" :options="groupList" key-field="ID" label-field="name" @select="(groupId) => AddStockGroupInfo(groupId,result['股票代码'],result['股票名称'])">
|
<n-dropdown trigger="click" :options="groupList" key-field="ID" label-field="name" @select="(groupId) => AddStockGroupInfo(groupId,result['股票代码'],result['股票名称'])">
|
||||||
@ -1635,13 +1780,13 @@ function delStockGroup(code,name,groupId){
|
|||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
<n-modal v-model:show="modalShow2" :title="data.name" style="width: 900px" :preset="'card'">
|
<n-modal v-model:show="modalShow2" :title="data.name" style="width: 1000px" :preset="'card'" @after-enter="handleFeishi" @after-leave="clearFeishi">
|
||||||
<!-- <n-image :src="data.fenshiURL" />-->
|
<!-- <n-image :src="data.fenshiURL" />-->
|
||||||
<div ref="kLineChartRef2" style="width: 850px; height: 500px;"></div>
|
<div ref="kLineChartRef2" style="width: 1000px; height: 500px;"></div>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
<n-modal v-model:show="modalShow3" :title="data.name" style="width: 900px" :preset="'card'" @after-enter="handleKLine">
|
<n-modal v-model:show="modalShow3" :title="data.name" style="width: 1000px" :preset="'card'" @after-enter="handleKLine">
|
||||||
<!-- <n-image :src="data.kURL" />-->
|
<!-- <n-image :src="data.kURL" />-->
|
||||||
<div ref="kLineChartRef" style="width: 850px; height: 500px;"></div>
|
<div ref="kLineChartRef" style="width: 1000px; height: 500px;"></div>
|
||||||
</n-modal>
|
</n-modal>
|
||||||
|
|
||||||
<n-modal transform-origin="center" v-model:show="modalShow4" preset="card" style="width: 800px;" :title="'['+data.name+']AI分析结果'" >
|
<n-modal transform-origin="center" v-model:show="modalShow4" preset="card" style="width: 800px;" :title="'['+data.name+']AI分析结果'" >
|
||||||
|
Loading…
x
Reference in New Issue
Block a user