Optimize code

This commit is contained in:
2023-12-08 17:47:08 +08:00
parent 633985af8e
commit 81cc23248c

View File

@@ -53,11 +53,7 @@ const barDefaultSeriesOption: BarSeriesOption = {
} }
const eChartsBaseOption: EChartsOption = { const eChartsBaseOption: EChartsOption = {
tooltip: { tooltip: {},
axisPointer: {
axis: 'x'
}
},
xAxis: { xAxis: {
show: false show: false
}, },
@@ -399,7 +395,7 @@ const MemoryInfo: React.FC = () => {
} }
setTimeout(() => { setTimeout(() => {
const eEchartsOptions = [ const eEchartsOption = [
{ {
...eChartsBaseOption, ...eChartsBaseOption,
xAxis: { xAxis: {
@@ -493,11 +489,11 @@ const MemoryInfo: React.FC = () => {
] ]
} }
] ]
setMemoryInfoEChartsOption(eEchartsOptions) setMemoryInfoEChartsOption(eEchartsOption)
if (percentDivRef.current) { if (percentDivRef.current) {
percentDivRef.current.innerHTML = '' percentDivRef.current.innerHTML = ''
eEchartsOptions.forEach((value) => { eEchartsOption.forEach((value) => {
const percentElement = document.createElement('div') const percentElement = document.createElement('div')
percentElement.innerText = `${( percentElement.innerText = `${(
(value.series[0].data[0] / (value.series[0].data[0] /
@@ -512,7 +508,7 @@ const MemoryInfo: React.FC = () => {
if (!memoryInfoEChatsRef.current.length) { if (!memoryInfoEChatsRef.current.length) {
memoryInfoDivRef.current && (memoryInfoDivRef.current.innerHTML = '') memoryInfoDivRef.current && (memoryInfoDivRef.current.innerHTML = '')
eEchartsOptions.forEach(() => { eEchartsOption.forEach(() => {
const element = document.createElement('div') const element = document.createElement('div')
memoryInfoDivRef.current?.appendChild(element) memoryInfoDivRef.current?.appendChild(element)
memoryInfoEChatsRef.current.push( memoryInfoEChatsRef.current.push(