Browse Source

Merge branch 'zhaowenkang/feature-20250701110203-情绪量能转化器优化' into milestone-20250710-上线前优化

dongqian/feature-20250702094358-小财神适配
zhaowenkang 9 hours ago
parent
commit
7db3f10ab8
  1. 212
      src/views/components/emoEnergyConverter.vue

212
src/views/components/emoEnergyConverter.vue

@ -12,7 +12,7 @@ let qxnlzhqEchartsRef = ref(null);
let qxnlzhqEchartsInstance = null;
let regions = reactive([]);
const dataMax=ref(null)
//
function getNameTop(min, max, regionMiidle) {
//
@ -30,14 +30,30 @@ function getNumberTop(min, max, regionMax) {
//
const generateGraphics = (min, max) => {
let hasPartialVisible = false; //
return regions.flatMap((region) => {
if(!region.min || !region.max) return [];
const middleY = (Number(region.min) + Number(region.max)) / 2;
return [
//
{
const safeY = Math.max(min, Math.min(middleY, max*0.99));
//
const isFullyVisible = region.min >= min && region.max <= max;
//
const isPartiallyVisible = (region.min < max && region.max > min) && !isFullyVisible;
//
if (isPartiallyVisible && hasPartialVisible) {
return [];
}
//
if (isPartiallyVisible) {
hasPartialVisible = true;
}
const graphics = [];
//
if (isFullyVisible || isPartiallyVisible) {
graphics.push({
type: "text",
left: '60', //
top: getNameTop(min, max, middleY),
left: '10%',
top: getNameTop(min, max, safeY),
style: {
text: region.name,
fill: region.fontColor,
@ -45,11 +61,13 @@ const generateGraphics = (min, max) => {
fontWeight: "bold",
},
z: 3,
},
// y
{
});
}
// y
if (isFullyVisible) {
graphics.push({
type: "text",
left: '60', //
left: '5%', //
top: getNumberTop(min, max, region.max),
// top: 100,
style: {
@ -58,8 +76,9 @@ const generateGraphics = (min, max) => {
fontSize: 12,
},
z: 3,
},
];
});
}
return graphics;
});
};
@ -89,41 +108,41 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
min: qxnlzhqData.dd,
max: qxnlzhqData.zc,
name: "【情绪冰点区】",
color: "#e7a5d6",
fontColor: 'white',
NumberColor: 'blue',
color: "#FF9F9F",
fontColor: '#666666',
NumberColor: 'white',
},
{
min: qxnlzhqData.zc,
max: qxnlzhqData.ht,
name: "【认知潜伏区】",
color: "#f36587",
fontColor: 'white',
NumberColor: 'blue',
color: "#FFCB75",
fontColor: '#666666',
NumberColor: 'white',
},
{
min: qxnlzhqData.ht,
max: qxnlzhqData.qs,
name: "【多空消化区】",
color: "#e99883",
fontColor: 'white',
NumberColor: 'blue',
color: "#D7E95D",
fontColor: '#666666',
NumberColor: 'white',
},
{
min: qxnlzhqData.qs,
max: qxnlzhqData.tp,
name: "【共识加速区】",
color: "#f0db84",
fontColor: 'white',
NumberColor: 'red',
color: "#A0F56F",
fontColor: '#666666',
NumberColor: 'white',
},
{
min: qxnlzhqData.tp,
max: qxnlzhqData.js,
name: "【情绪临界区】",
color: "#dbeee3",
fontColor: 'red',
NumberColor: 'red',
color: "#87F3CD",
fontColor: '#666666',
NumberColor: 'white',
},
];
// gg yl-1
@ -133,9 +152,9 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
min: qxnlzhqData.js,
max: qxnlzhqData.yl,
name: "【杠杆失衡区】",
color: "#9ac2d8",
fontColor: 'red',
NumberColor: 'red',
color: "#51C3F9",
fontColor: '#666666',
NumberColor: 'white',
},
)
}
@ -145,13 +164,21 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
min: qxnlzhqData.yl,
max: qxnlzhqData.gg,
name: "【情绪熔断区】",
color: "#bce283",
fontColor: 'red',
NumberColor: 'red',
color: "#D0A7FF",
fontColor: '#666666',
NumberColor: 'white',
},
)
}
// y
const priceValues = kline.flatMap(item => [item[1], item[2], item[3], item[4]]);
const dataMin = Math.min(...priceValues);
const dataMax = Math.max(...priceValues);
// K线
const lastKLine = mixData[mixData.length - 1];
const lastHigh = lastKLine.value[2]; //
const lastLow = lastKLine.value[3]; //
//
const stopProfitPrice = Number(qxnlzhqData.cc) * 1.05; //
const stopLossPrice = Number(qxnlzhqData.cc) * 0.97; //
@ -257,7 +284,7 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
borderWidth: 1
}
},
backgroundColor: 'rgba(0, 0, 0, 0.8)',
backgroundColor: '#646E71',
borderColor: '#fff',
borderWidth: 1,
padding: 10,
@ -299,9 +326,9 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
result += `<div style="color: ${changeColor};">涨跌: ${priceChange >= 0 ? '+' : ''}${priceChange.toFixed(2)} (${changePercent}%)</div>`
result += `</div>`
} else if (param.seriesName === '止盈线' && value !== null && value !== undefined && typeof value === 'number') {
result += `<div style="color: #ff80ff; margin-bottom: 4px;">${param.seriesName}: ${value.toFixed(2)}</div>`
result += `<div style="color: #FF0000; margin-bottom: 4px;">${param.seriesName}: ${value.toFixed(2)}</div>`
} else if (param.seriesName === '止损线' && value !== null && value !== undefined && typeof value === 'number') {
result += `<div style="color: #080bfd; margin-bottom: 4px;">${param.seriesName}: ${value.toFixed(2)}</div>`
result += `<div style="color: #001EFF; margin-bottom: 4px;">${param.seriesName}: ${value.toFixed(2)}</div>`
}
})
@ -373,17 +400,12 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
qxnlzhqData.dd < stopLossPrice * 0.98
? Math.floor(qxnlzhqData.dd)
: Math.floor(stopLossPrice * 0.98),
max:
qxnlzhqData.yl > stopProfitPrice * 1.02
? Math.ceil(qxnlzhqData.yl)
: Math.ceil(stopProfitPrice * 1.02),
max: Math.max(Math.ceil(dataMax * 1.02), (qxnlzhqData.yl > 0 ? qxnlzhqData.yl : Math.ceil(dataMax * 1.02)), stopProfitPrice * 1.02),
},
//
graphic: generateGraphics(qxnlzhqData.dd < stopLossPrice * 0.98
? Math.floor(qxnlzhqData.dd)
: Math.floor(stopLossPrice * 0.98), qxnlzhqData.yl > stopProfitPrice * 1.02
? Math.ceil(qxnlzhqData.yl)
: Math.ceil(stopProfitPrice * 1.02)),
: Math.floor(stopLossPrice * 0.98), Math.max(Math.ceil(dataMax * 1.02), (qxnlzhqData.yl > 0 ? qxnlzhqData.yl : Math.ceil(dataMax * 1.02)), stopProfitPrice * 1.02),),
series: [
{
type: "candlestick",
@ -399,10 +421,12 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
itemStyle: {
normal: {
// 线 >
color: '#14b143', // < 绿
// color: '#14b143', // < 绿
color: 'rgba(0,0,0,0)',
color0: '#ef232a', // >
borderColor: '#14b143', // 线绿
borderColor0: '#ef232a', // 线
borderWidth: 1.5
}
},
//
@ -453,7 +477,7 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
symbol: 'none',
lineStyle: {
normal: {
color: '#ff80ff', //
color: '#FF0000', //
width: 2,
type: 'solid'
}
@ -470,15 +494,16 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
label: {
normal: {
show: true,
position: 'bottom',
formatter: `{text|止盈: ${stopProfitPrice}}`,
position: 'top',
formatter: `{text|止盈}`,
rich: {
text: {
color: '#820a06',
color: '#FF0000',
fontSize: 14,
fontWeight: 'bold'
}
}
},
offset: [-20, 0]
}
}
}
@ -492,7 +517,7 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
symbol: 'none',
lineStyle: {
normal: {
color: '#080bfd', //
color: '#001EFF',
width: 2,
type: 'solid'
}
@ -510,20 +535,101 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
normal: {
show: true,
position: 'bottom',
formatter: `{text|止损: ${stopLossPrice}}`,
formatter: `{text|止损}`,
rich: {
text: {
color: '#080bfd',
color: '#001EFF',
fontSize: 14,
fontWeight: 'bold'
}
}
},
offset: [-20, 0]
}
}
}
]
}
},
{
name: '最低价',
type: 'line',
symbol: 'none',
lineStyle: {
normal: {
color: 'transparent',
width: 0
}
},
markPoint: {
symbol: 'circle',
symbolSize: 1,
data: [
{
coord: [mixData.length - 1, mixData[mixData.length - 1].value[2]],
itemStyle: {
color: 'transparent'
},
label: {
normal: {
show: true,
position: 'top',
formatter: `{text|${mixData[mixData.length - 1].value[2].toFixed(2)}}`,
rich: {
text: {
color: '#001EFF',
fontSize: 12,
fontWeight: 'bold',
textBorderColor: '#ffffff',
textBorderWidth: 2,
}
},
offset: [20, 10]
}
}
}
]
}
},
{
name: '最高价',
type: 'line',
symbol: 'none',
lineStyle: {
normal: {
color: 'transparent',
width: 0
}
},
markPoint: {
symbol: 'circle',
symbolSize: 1,
data: [
{
coord: [mixData.length - 1, mixData[mixData.length - 1].value[3]],
itemStyle: {
color: 'transparent'
},
label: {
normal: {
show: true,
position: 'bottom',
formatter: `{text|${mixData[mixData.length - 1].value[3].toFixed(2)}}`,
rich: {
text: {
color: '#FF0000',
fontSize: 12,
fontWeight: 'bold',
textBorderColor: '#ffffff',
textBorderWidth: 2,
}
},
offset: [20, -10]
}
}
}
]
}
}
],
grid: {
left: "7%",

Loading…
Cancel
Save