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