You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

269 lines
8.4 KiB

//
// ChartViewModel.swift
// HPlusFit
//
// Created by lemo. on 2019/9/24.
// Copyright © 2019 lemo. All rights reserved.
//
import Foundation
enum ChartViewType {
/// 线(使线)
case polyline
///
case stickMatch
///
case gradentFill
/// 线
case vertical
///
case segmentBar
///
case rectangleSegBar
///
case horizontalSegment
///
case roundBar
///
case regularBar
///
case stepRoundBar
/// hrv线
case hrvEcg
// 线
case temp
}
///
struct LegendData {
let docColor: UIColor
let name: String
}
///
struct sleepData {
var type: Int?
var value: Float32?
var begin: String?
var end: String?
init(type: Int?, value: Float32?) {
self.type = type
self.value = value
}
init(type: Int?, value: Float32?, begin: String?, end: String?) {
self.type = type
self.value = value
self.begin = begin
self.end = end
}
}
struct ChartViewData {
var date: String?
var maxValue: Int = 0
var minValue: Int = 0
var aveValue: Int = 0
var value: Int = 0
var sleeps: [sleepData]?
var sum: Float = 0
var number: Int = 0
var fallingsleepTimes: String = ""
var awakeTimes: String = ""
var sleep: sleepData?
//
var value2: Int = 0
///
var floatValue: CGFloat = 0
///
///
/// - Parameters:
/// - date:
/// - maxValue: , 0
/// - aveValue: , 0
/// - minValue: , 0
/// - value: , 0
init(date: String?, maxValue: Int = 0,aveValue: Int = 0, minValue: Int = 0, value: Int = 0, value2: Int = 0, floatValue: CGFloat = 0) {
self.date = date
self.maxValue = maxValue
self.minValue = minValue
self.aveValue = aveValue
self.value = value
self.value2 = value2
self.floatValue = floatValue
}
///
///
/// - Parameters:
/// - date:
/// - number: 0
/// - sum: 0.0
/// - sleeps:
init(date: String?, number: Int = 0, sum: Float = 0.0, sleeps:[sleepData] = []) {
self.date = date
self.sleeps = sleeps
self.sum = sum
self.number = number
}
init(date: String?, number: Int = 0, sum: Float = 0.0, sleeps:[sleepData] = [],fallingsleepTimes: String = "", awakeTimes: String = "") {
self.date = date
self.sleeps = sleeps
self.sum = sum
self.number = number
self.fallingsleepTimes = fallingsleepTimes
self.awakeTimes = awakeTimes
}
///
init(sleep: sleepData?) {
self.sleep = sleep
}
}
struct ChartViewModel {
var leftIcon: String?
var title: String?
var legends: Array<LegendData>?
var source: Array<ChartViewData>?
var chartType: ChartViewType = .polyline
var maxAxis: Int?
var lineColor: UIColor?
var xAxis: [String]?
var rightTime: String = ""
var points: Int = 0 //
var maxpoints: Int = 0 //
var isContinuous: Bool = true //线
var isShowMeasureLine: Bool = false //线
var isDrawAvgLine: Bool = false // 线
// &&
var centerColor: UIColor? = nil
var centerValue: String? = nil
var centerUnitValue: String? = nil
//
var floatMaxAxis: CGFloat = 0
init() {
}
init(leftIcon: String?, title: String?) {
self.leftIcon = leftIcon
self.title = title
}
init(title: String?, rightTime: String) {
self.title = title
self.rightTime = rightTime
}
init(leftIcon: String?, title: String?, rightTime: String) {
self.leftIcon = leftIcon
self.title = title
self.rightTime = rightTime
}
init(leftIcon: String?, title: String?, legends: Array<LegendData>?, source: Array<ChartViewData>?, chartType: ChartViewType) {
self.leftIcon = leftIcon
self.title = title
self.legends = legends
self.source = source
self.chartType = chartType
}
init(leftIcon: String?, title: String?, source: Array<ChartViewData>?,chartType: ChartViewType,maxAxis: Int?) {
self.leftIcon = leftIcon
self.title = title
self.source = source
self.chartType = chartType
self.maxAxis = maxAxis
}
init(leftIcon: String?, title: String?, legends: Array<LegendData>?, source: Array<ChartViewData>?, chartType: ChartViewType, maxAxis: Int?) {
self.leftIcon = leftIcon
self.title = title
self.legends = legends
self.source = source
self.chartType = chartType
self.maxAxis = maxAxis
}
init(leftIcon: String?, title: String?, legends: Array<LegendData>?, source: Array<ChartViewData>?, chartType: ChartViewType, maxAxis: Int?, xAxis: [String]?, isShowMeasureLine: Bool = false) {
self.leftIcon = leftIcon
self.title = title
self.legends = legends
self.source = source
self.chartType = chartType
self.maxAxis = maxAxis
self.xAxis = xAxis
self.isShowMeasureLine = isShowMeasureLine
}
init(leftIcon: String?, title: String?, legends: Array<LegendData>?, source: Array<ChartViewData>?, chartType: ChartViewType, maxAxis: Int?, lineColor: UIColor?, isShowMeasureLine: Bool = false, center: String? = nil, centerColor: UIColor? = nil, centerUnit: String? = nil) {
self.leftIcon = leftIcon
self.title = title
self.legends = legends
self.source = source
self.chartType = chartType
self.maxAxis = maxAxis
self.lineColor = lineColor
self.isShowMeasureLine = isShowMeasureLine
self.centerValue = center
self.centerColor = centerColor
self.centerUnitValue = centerUnit
}
///
///
/// - Parameters:
/// - leftIcon:
/// - title:
/// - legends:
/// - source:
/// - chartType:
/// - maxAxis:
/// - xAxis: x
/// - lineColor: 线
/// - points:
/// - maxpoints:
/// - isContinuous: 线
/// - isDrawAvgLine: 线
init(leftIcon: String?, title: String?, legends: Array<LegendData>?, source: Array<ChartViewData>?, chartType: ChartViewType, maxAxis: Int?,xAxis: [String]?, lineColor: UIColor?, points: Int = 0, maxpoints: Int = 0,isContinuous: Bool = true,isShowMeasureLine: Bool = false, isDrawAvgLine: Bool = false, center: String? = nil, centerColor: UIColor? = nil, centerUnit: String? = nil) {
self.leftIcon = leftIcon
self.title = title
self.legends = legends
self.source = source
self.chartType = chartType
self.maxAxis = maxAxis
self.xAxis = xAxis
self.lineColor = lineColor
self.points = points
self.maxpoints = maxpoints
self.isContinuous = isContinuous
self.isShowMeasureLine = isShowMeasureLine
self.isDrawAvgLine = isDrawAvgLine
self.centerValue = center
self.centerColor = centerColor
self.centerUnitValue = centerUnit
}
/// 使
init(source: Array<ChartViewData>?, chartType: ChartViewType, floatMaxAxis: CGFloat, xAxis: [String]?, lineColor: UIColor, isContinuous: Bool, isShowMeasureLine: Bool, center: String, centerColor: UIColor, centerUnit: String? = nil) {
self.source = source
self.chartType = chartType
self.floatMaxAxis = floatMaxAxis
self.xAxis = xAxis
self.lineColor = lineColor
self.isContinuous = isContinuous
self.isShowMeasureLine = isShowMeasureLine
self.centerValue = center
self.centerColor = centerColor
self.centerUnitValue = centerUnit
}
}