fix: k线图显示正确

master
Lxy 3 months ago
parent c62f044f5d
commit d78837d0b3

@ -120,6 +120,18 @@ const Detail = () => {
]);
}
//
const volumeData = klineData.map(item => {
const isUp = item.close >= item.open;
return [
new Date(item.timestamp * 1000).getTime(), //
item.volume, //
isUp ? 1 : 0 //
];
});
console.log('Volume data for ECharts:', volumeData);
//
const option = {
tooltip: {
@ -129,22 +141,60 @@ const Detail = () => {
}
},
legend: {
data: ['K线', 'MA5', 'MA10']
data: ['K线', 'MA5', 'MA10', '成交量'],
top: '3%',
left: 'center'
},
grid: {
grid: [
{
left: '3%',
right: '4%',
bottom: '3%',
bottom: '15%',
containLabel: true
},
xAxis: {
{
left: '3%',
right: '4%',
bottom: '3%',
height: '10%',
containLabel: true
}
],
xAxis: [
{
type: 'time',
boundaryGap: false
boundaryGap: false,
axisLabel: {
show: true
}
},
yAxis: {
{
type: 'time',
boundaryGap: false,
gridIndex: 1,
axisLabel: {
show: false
}
}
],
yAxis: [
{
type: 'value',
scale: true
scale: true,
splitArea: {
show: true
}
},
{
type: 'value',
scale: true,
gridIndex: 1,
splitNumber: 2,
axisLabel: {
show: true
}
}
],
series: [
{
name: 'K线',
@ -178,6 +228,19 @@ const Detail = () => {
color: '#faad14'
},
showSymbol: false
},
{
name: '成交量',
type: 'bar',
xAxisIndex: 1,
yAxisIndex: 1,
data: volumeData,
itemStyle: {
color: function(params) {
//
return params.data[2] === 1 ? '#52c41a' : '#ff4d4f';
}
}
}
]
};

Loading…
Cancel
Save