特性点连线顺序
This commit is contained in:
@@ -30,15 +30,15 @@
|
||||
</template>
|
||||
|
||||
<div class="chart-wrapper">
|
||||
<MyEchart ref="chartRef" :options="chartOptions" />
|
||||
<MyEchart ref="chartRef" :options="chartOptions"/>
|
||||
</div>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Document, Download } from '@element-plus/icons-vue'
|
||||
import {computed, nextTick, ref, watch} from 'vue'
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {Document, Download} from '@element-plus/icons-vue'
|
||||
import * as XLSX from 'xlsx'
|
||||
import MyEchart from '@/components/echarts/line/index.vue'
|
||||
|
||||
@@ -126,23 +126,29 @@ const sortedChartPoints = computed(() => {
|
||||
|
||||
const sortedCharacteristicCurveData = computed(() => {
|
||||
return [...characteristicCurveData.value].sort((a, b) => {
|
||||
if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
return a.timeMs - b.timeMs
|
||||
}
|
||||
|
||||
if (a.timeMs !== null && b.timeMs === null) {
|
||||
return -1
|
||||
}
|
||||
|
||||
if (a.timeMs === null && b.timeMs !== null) {
|
||||
return 1
|
||||
}
|
||||
|
||||
if (a.duration !== b.duration) {
|
||||
// 保留1位小数
|
||||
let aResidualVoltage = Math.floor(a.residualVoltage * 10) / 10
|
||||
let bResidualVoltage = Math.floor(b.residualVoltage * 10) / 10
|
||||
if (aResidualVoltage != bResidualVoltage) {
|
||||
return a.residualVoltage - b.residualVoltage;
|
||||
} else {
|
||||
let aDuration = a.duration * 1000 - a.duration * 1000 % 10
|
||||
let bDuration = b.duration * 1000 - b.duration * 1000 % 10
|
||||
if (aDuration != bDuration) {
|
||||
return a.duration - b.duration
|
||||
} else if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
return a.timeMs - b.timeMs
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
|
||||
return a.residualVoltage - b.residualVoltage
|
||||
}
|
||||
// if (a.timeMs !== null && b.timeMs !== null && a.timeMs !== b.timeMs) {
|
||||
// return a.timeMs - b.timeMs
|
||||
// } else {
|
||||
// return 0
|
||||
// }
|
||||
//
|
||||
// return a.residualVoltage - b.residualVoltage
|
||||
})
|
||||
})
|
||||
|
||||
@@ -336,7 +342,7 @@ const normalizeStatus = (value: unknown): ChartPointStatus => {
|
||||
const normalizeTolerantPoint = (source: Record<string, any>): NormalizedTolerantPoint | null => {
|
||||
const duration = normalizeDuration(source)
|
||||
const residualVoltage = normalizeResidualVoltageValue(source)
|
||||
const { time, timeMs } = parsePointTime(source.time)
|
||||
const {time, timeMs} = parsePointTime(source.time)
|
||||
|
||||
if (duration === null || residualVoltage === null) {
|
||||
return null
|
||||
@@ -577,7 +583,7 @@ const exportChartData = () => {
|
||||
XLSX.utils.book_append_sheet(workbook, curveSheet, '特性点')
|
||||
}
|
||||
|
||||
const workbookBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' })
|
||||
const workbookBuffer = XLSX.write(workbook, {bookType: 'xlsx', type: 'array'})
|
||||
const blob = new Blob([workbookBuffer], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
||||
})
|
||||
@@ -737,7 +743,7 @@ watch(
|
||||
characteristicCurveVisible.value = newValue ? characteristicCurveData.value.length > 0 : false
|
||||
drawnCharacteristicCurveData.value = newValue ? [...characteristicCurveData.value] : []
|
||||
},
|
||||
{ immediate: true }
|
||||
{immediate: true}
|
||||
)
|
||||
|
||||
watch(
|
||||
@@ -764,7 +770,7 @@ watch(
|
||||
mergeCharacteristicCurvePoints(extractCharacteristicCurvePoints(newValue))
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{ deep: true }
|
||||
{deep: true}
|
||||
)
|
||||
|
||||
watch(
|
||||
@@ -778,7 +784,7 @@ watch(
|
||||
characteristicCurveData.value = extractCharacteristicCurvePoints(newValue)
|
||||
updateCharacteristicCurveVisibility()
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
{deep: true, immediate: true}
|
||||
)
|
||||
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user