Compare commits

...

2 Commits

  1. 97
      src/views/components/emotionDecod.vue

97
src/views/components/emotionDecod.vue

@ -1,57 +1,34 @@
<template> <template>
<!-- <div ref="qxnlzhqEchartsRef" id="qxnlzhqEcharts"></div> -->
<div class="qxjmqbox"> <div class="qxjmqbox">
<div ref="KlineCanvs" id="qxjmqEcharts" class="qxjmqbox"></div>
<div ref="qxjmqEchartsRef" id="qxjmqEcharts" class="qxjmqbox"></div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted, onBeforeUnmount, toRef } from "vue";
import { ref, onMounted, onBeforeUnmount } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
import { color } from "echarts/lib/export";
defineExpose({ initQXNLZHEcharts }); defineExpose({ initQXNLZHEcharts });
const KlineCanvs = ref(null);
let KlineCanvsChart = null;
const qxjmqEchartsRef = ref(null);
let qxjmqChart = null;
const heatmapData = ref([]); // const heatmapData = ref([]); //
//
const rawData2 = ref([]);
const lineData3 = ref([]);
const rawData2 = ref([]); //
const lineData3 = ref([]);// 线
function initQXNLZHEcharts(kline, qxnlzhqData) { function initQXNLZHEcharts(kline, qxnlzhqData) {
qxnlzhqData[9][9] = 1;
qxnlzhqData[2][9] = 1;
rawData2.value = qxnlzhqData; rawData2.value = qxnlzhqData;
// //
const processedHeatmap = []; const processedHeatmap = [];
rawData2.value.forEach((item, dateIndex) => { rawData2.value.forEach((item, dateIndex) => {
const [date, d1, d2, d3, d4, d5, d6, d7, d8, d9] = item; const [date, d1, d2, d3, d4, d5, d6, d7, d8, d9] = item;
processedHeatmap.push([
dateIndex,
0,
d4,
d8 == 1 ? "green" : "transparent",
]); // 1
processedHeatmap.push([
dateIndex,
1,
d3,
d7 == 1 ? "purple" : "transparent",
]); // 2
processedHeatmap.push([dateIndex, 2, d2, d6 == 1 ? "red" : "transparent"]); // 3
processedHeatmap.push([
dateIndex,
3,
d1,
d5 == 1 ? "yellow" : "transparent",
]); // 4
processedHeatmap.push([ dateIndex, 0, d4, d8 == 1 ? "green" : "transparent", date]); // 1
processedHeatmap.push([ dateIndex, 1, d3, d7 == 1 ? "purple" : "transparent", date]); // 2
processedHeatmap.push([ dateIndex, 2, d2, d6 == 1 ? "red" : "transparent", date]); // 3
processedHeatmap.push([ dateIndex, 3, d1, d5 == 1 ? "yellow" : "transparent", date, ]); // 4
}); });
heatmapData.value = processedHeatmap; heatmapData.value = processedHeatmap;
// 线
lineData3.value = rawData2.value.map((item) => item[9]); lineData3.value = rawData2.value.map((item) => item[9]);
console.log("热力图数据:", heatmapData.value);
console.log("折线图数据:", lineData3.value);
const data = kline; const data = kline;
// //
const spliteDate = (a) => { const spliteDate = (a) => {
@ -64,16 +41,10 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
return { categoryData, value }; return { categoryData, value };
}; };
const dealData = spliteDate(data); const dealData = spliteDate(data);
//
//
const KlineOption = { const KlineOption = {
tooltip: { tooltip: {
trigger: "item", //
// axisPointer: {
// type: "cross", //
// crossStyle: {
// color: "#999"
// }
// }
show: false
}, },
// //
@ -82,7 +53,6 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
{ top: "45%", height: "35%" }, { top: "45%", height: "35%" },
{ top: "80%", height: "2%" }, { top: "80%", height: "2%" },
], ],
visualMap: [ visualMap: [
{ {
show: false, // show: false, //
@ -127,7 +97,6 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
show: true, show: true,
lineStyle: { lineStyle: {
color: "white", color: "white",
// 线线
type: "solid", type: "solid",
}, },
interval: 0, interval: 0,
@ -138,6 +107,9 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
gridIndex: 2, gridIndex: 2,
data: dealData.categoryData, data: dealData.categoryData,
axisLine: { lineStyle: { color: "#8392A5" } }, axisLine: { lineStyle: { color: "#8392A5" } },
axisLabel: {
rotate: 45, // 45
},
}, },
], ],
yAxis: [ yAxis: [
@ -166,14 +138,10 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
{ {
gridIndex: 1, gridIndex: 1,
type: "category", type: "category",
data: [0, 1, 2, 3], //
data: [0, 1, 2, 3],
axisLine: { lineStyle: { color: "#8392A5" } }, axisLine: { lineStyle: { color: "#8392A5" } },
axisLabel: { axisLabel: {
show: true, //
color: "#fff", //
backgroundColor: "transparent",
fontSize: 12,
margin: 8,
show: false,
}, },
axisTick: { show: false }, // 线 axisTick: { show: false }, // 线
splitLine: { splitLine: {
@ -183,7 +151,6 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
width: 1, width: 1,
type: "solid", type: "solid",
}, },
interval: 0, // interval: 0, //
}, },
}, },
@ -240,9 +207,12 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
series: [ series: [
{ {
type: "candlestick", type: "candlestick",
name: "\u65e5K",
name: "K线",
// //
data: dealData.value, data: dealData.value,
tooltip: {
show: false
},
itemStyle: { itemStyle: {
normal: { normal: {
color0: "red", // 线 color0: "red", // 线
@ -261,13 +231,12 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
yAxisIndex: 1, yAxisIndex: 1,
data: processedHeatmap, data: processedHeatmap,
coordinateSystem: "cartesian2d", coordinateSystem: "cartesian2d",
// tooltip: {
// // tooltip
// formatter: function (params) {
// const date = params.axisValue;
// return `${date}${params.data[2]}`; // 3
// }
// },
// tooltip: {
// formatter: function (params) {
// return `${params.data[4]}: ${params.data[2]}`; //
// },
// },
label: { label: {
normal: { normal: {
show: true, show: true,
@ -275,7 +244,6 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
formatter: function (params) { formatter: function (params) {
const value = params.value[2]; // const value = params.value[2]; //
const colorType = params.value[3]; // const colorType = params.value[3]; //
// 使 rich
return `{${colorType}|${value}}`; return `{${colorType}|${value}}`;
}, },
rich: { rich: {
@ -322,11 +290,11 @@ function initQXNLZHEcharts(kline, qxnlzhqData) {
}; };
// echarts // echarts
KlineCanvsChart = echarts.init(KlineCanvs.value);
KlineCanvsChart.setOption(KlineOption);
qxjmqChart = echarts.init(qxjmqEchartsRef.value);
qxjmqChart.setOption(KlineOption);
// //
window.addEventListener("resize", () => { window.addEventListener("resize", () => {
KlineCanvsChart.resize();
qxjmqChart.resize();
}); });
} }
const windowHeight = ref(window.innerHeight); const windowHeight = ref(window.innerHeight);
@ -338,14 +306,15 @@ onMounted(() => {
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
// //
if (KlineCanvsChart) {
KlineCanvsChart.dispose();
if (qxjmqChart) {
qxjmqChart.dispose();
} }
}); });
</script> </script>
<style scoped> <style scoped>
.qxjmqbox { .qxjmqbox {
background-color: #131a2a; background-color: #131a2a;
width: 100%;
} }
#qxjmqEcharts { #qxjmqEcharts {
width: 100%; width: 100%;

Loading…
Cancel
Save