feiyu02
2024-06-27 e8f935a01d75c89ac591a80b9318eac2480e2dcd
src/main/kotlin/com/flightfeather/uav/common/chart/DataToChartUtil.kt
@@ -1,5 +1,6 @@
package com.flightfeather.uav.common.chart
import com.flightfeather.uav.biz.FactorFilter
import com.flightfeather.uav.common.utils.DateUtil
import com.flightfeather.uav.domain.entity.BaseRealTimeData
import com.flightfeather.uav.socket.eunm.FactorType
@@ -11,13 +12,13 @@
 */
object DataToChartUtil {
    fun lineToByteArray(type: FactorType?, data: List<BaseRealTimeData>): ByteArray {
        val title = type?.des ?: "未知监测因子"
        val seriesName = type?.des ?: "未知系列"
    fun lineToByteArray(type: FactorFilter.SelectedFactor?, data: List<BaseRealTimeData>): ByteArray {
        val title = type?.main?.des ?: "未知监测因子"
        val seriesName = type?.main?.des ?: "未知系列"
        val dataList = data.map { d ->
            ChartUtil.ChartValue(
                DateUtil.instance.dateToString(d.dataTime, DateUtil.DateStyle.HH_MM_SS),
                d.getByFactorType(type) ?: 0f
                d.getByFactorType(type?.main) ?: 0f
            )
        }
        val dataset = ChartUtil.newDataset(dataList, seriesName)