Commit 8088b4fd authored by Javen's avatar Javen

no message

parent 950112e4
......@@ -18,13 +18,15 @@
29D7E020204E72DB00010071 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29D7E01F204E72DB00010071 /* Assets.xcassets */; };
29D7E023204E72DB00010071 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29D7E021204E72DB00010071 /* LaunchScreen.storyboard */; };
29D7E02B204E738D00010071 /* Podfile in Resources */ = {isa = PBXBuildFile; fileRef = 29D7E02A204E738D00010071 /* Podfile */; };
29D9E26C2050FB3300E1C3F5 /* SpotsResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E26B2050FB3200E1C3F5 /* SpotsResult.swift */; };
29D9E27020510DED00E1C3F5 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E26F20510DED00E1C3F5 /* Date+Extensions.swift */; };
29D9E2722051182900E1C3F5 /* Color+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E2712051182800E1C3F5 /* Color+Extension.swift */; };
29D9E27420511E8C00E1C3F5 /* DensityResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E27320511E8C00E1C3F5 /* DensityResult.swift */; };
29D9E27A2051216000E1C3F5 /* AxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E2792051216000E1C3F5 /* AxisValueFormatter.swift */; };
29D9E38C20513A7100E1C3F5 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E38B20513A7100E1C3F5 /* DetailViewController.swift */; };
29D9E39020513F6500E1C3F5 /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E38F20513F6500E1C3F5 /* UIView+Extension.swift */; };
8F64F344206CF1B20047402A /* DensityResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F64F342206CF1B20047402A /* DensityResult.swift */; };
8F64F345206CF1B20047402A /* DensityRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F64F343206CF1B20047402A /* DensityRow.swift */; };
8F64F349206CF62F0047402A /* SpotsYesterdayrow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F64F347206CF62F0047402A /* SpotsYesterdayrow.swift */; };
8F64F34A206CF62F0047402A /* SpotsResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F64F348206CF62F0047402A /* SpotsResult.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -41,14 +43,16 @@
29D7E022204E72DB00010071 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
29D7E024204E72DB00010071 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
29D7E02A204E738D00010071 /* Podfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Podfile; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
29D9E26B2050FB3200E1C3F5 /* SpotsResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotsResult.swift; sourceTree = "<group>"; };
29D9E26F20510DED00E1C3F5 /* Date+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Date+Extensions.swift"; sourceTree = "<group>"; };
29D9E2712051182800E1C3F5 /* Color+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Color+Extension.swift"; sourceTree = "<group>"; };
29D9E27320511E8C00E1C3F5 /* DensityResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DensityResult.swift; sourceTree = "<group>"; };
29D9E2792051216000E1C3F5 /* AxisValueFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AxisValueFormatter.swift; sourceTree = "<group>"; };
29D9E38B20513A7100E1C3F5 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
29D9E38F20513F6500E1C3F5 /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
741C820678A2593F5FCD1236 /* Pods-SHZX.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SHZX.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SHZX/Pods-SHZX.debug.xcconfig"; sourceTree = "<group>"; };
8F64F342206CF1B20047402A /* DensityResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DensityResult.swift; sourceTree = "<group>"; };
8F64F343206CF1B20047402A /* DensityRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DensityRow.swift; sourceTree = "<group>"; };
8F64F347206CF62F0047402A /* SpotsYesterdayrow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotsYesterdayrow.swift; sourceTree = "<group>"; };
8F64F348206CF62F0047402A /* SpotsResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotsResult.swift; sourceTree = "<group>"; };
F4B2B6ED73482878EC2355ED /* Pods_SHZX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SHZX.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
......@@ -86,9 +90,9 @@
29266CB3204FF03E000CBB4B /* Response */ = {
isa = PBXGroup;
children = (
8F64F346206CF62F0047402A /* SpotsResult */,
8F64F341206CF1B20047402A /* DensityResult */,
29266CB4204FF05D000CBB4B /* LoginResult.swift */,
29D9E26B2050FB3200E1C3F5 /* SpotsResult.swift */,
29D9E27320511E8C00E1C3F5 /* DensityResult.swift */,
);
path = Response;
sourceTree = "<group>";
......@@ -148,6 +152,24 @@
path = Formatter;
sourceTree = "<group>";
};
8F64F341206CF1B20047402A /* DensityResult */ = {
isa = PBXGroup;
children = (
8F64F342206CF1B20047402A /* DensityResult.swift */,
8F64F343206CF1B20047402A /* DensityRow.swift */,
);
path = DensityResult;
sourceTree = "<group>";
};
8F64F346206CF62F0047402A /* SpotsResult */ = {
isa = PBXGroup;
children = (
8F64F347206CF62F0047402A /* SpotsYesterdayrow.swift */,
8F64F348206CF62F0047402A /* SpotsResult.swift */,
);
path = SpotsResult;
sourceTree = "<group>";
};
EA98A5D05CDBDCE4B956AC93 /* Frameworks */ = {
isa = PBXGroup;
children = (
......@@ -300,19 +322,21 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
29D9E27420511E8C00E1C3F5 /* DensityResult.swift in Sources */,
8F64F34A206CF62F0047402A /* SpotsResult.swift in Sources */,
8F64F345206CF1B20047402A /* DensityRow.swift in Sources */,
29D9E39020513F6500E1C3F5 /* UIView+Extension.swift in Sources */,
29D7E01B204E72DB00010071 /* ViewController.swift in Sources */,
29D9E27A2051216000E1C3F5 /* AxisValueFormatter.swift in Sources */,
29D9E38C20513A7100E1C3F5 /* DetailViewController.swift in Sources */,
29D9E2722051182900E1C3F5 /* Color+Extension.swift in Sources */,
29D9E27020510DED00E1C3F5 /* Date+Extensions.swift in Sources */,
8F64F349206CF62F0047402A /* SpotsYesterdayrow.swift in Sources */,
29266CB2204FEE57000CBB4B /* NetworkAPI.swift in Sources */,
29D7E019204E72DB00010071 /* AppDelegate.swift in Sources */,
29266CB1204FEE57000CBB4B /* MBProgressView.swift in Sources */,
29D9E26C2050FB3300E1C3F5 /* SpotsResult.swift in Sources */,
29266CB5204FF05D000CBB4B /* LoginResult.swift in Sources */,
29266CB0204FEE57000CBB4B /* Network.swift in Sources */,
8F64F344206CF1B20047402A /* DensityResult.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -13,7 +13,7 @@ public class ChartViewAxisValueFormatter: NSObject, IAxisValueFormatter {
open var titleArray: Array<String>!
public func stringForValue(_ value: Double, axis: AxisBase?) -> String {
return titleArray[Int(value)] + ":00"
return titleArray[Int(value)]
}
}
......
......@@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>CFBundleVersion</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
......
......@@ -12,27 +12,29 @@ import Alamofire
import SwiftyJSON
public enum Service {
// MARK: - 登录
case Login()
// MARK: - 登录iPad测试接口地址IP端口号改为121.40.116.34:8072
// case Login()
// MARK: - 用于首页中查询当天累计客流人数、实时人数及当天各小时峰值
case Spots(String,String)
case Spots()
// MARK: - 景点区域密度查询
case GETDensity(String,String)
case GETDensity()
}
extension Service: TargetType {
public var baseURL: URL {
return URL(string: "http://172.16.23.112:8081/")!
return URL(string: "http://172.16.23.112:8081/")!//内网正式
// return URL(string: "http://121.40.116.34:8072/")!//外网临时调试地址
}
public var path: String {
switch self {
case .Login():
return "User/Login"
case .Spots(_ ,_):
return "Spots/currentquery"
case .GETDensity(_):
return "Spots/GETDensity"
// case .Login():
// return "User/Login"
case .Spots():
return "ChartDisplay/SumKlReport/ListGetYesterdayHistogram"
case .GETDensity():
return "Home/GetDeviceGroupDensity"
}
}
......@@ -46,20 +48,14 @@ extension Service: TargetType {
public var task: Task {
switch self {
case .Login():
return .requestParameters(parameters: ["usercode": "SHZX",
"password": "SHZX"],
encoding: JSONEncoding.default)
case .Spots(let uuid,let time):
return .requestParameters(parameters: ["useruuid": uuid,
"dateType": time,
"spotcode": "SHZX"],
encoding: JSONEncoding.default)
case .GETDensity(let uuid, let time):
return .requestParameters(parameters: ["useruuid": uuid,
"dateType": time,
"spotcode": "SHZX"],
encoding: JSONEncoding.default)
// case .Login():
// return .requestParameters(parameters: ["usercode": "SHZX",
// "password": "SHZX"],
// encoding: JSONEncoding.default)
case .Spots:
return .requestPlain
case .GETDensity:
return .requestPlain
}
}
......
//
// DensityResult.swift
//
// Create by 云霄 曹 on 8/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class DensityResult : NSObject{
var data : [DensityData]!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
data = [DensityData]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
let value = DensityData(fromJson: dataJson)
data.append(value)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class DensityData : NSObject{
var cameraDateTime : String!
var codeType : String!
var deviceGroup : String!
var displayDensity : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
cameraDateTime = json["CameraDateTime"].stringValue
codeType = json["CodeType"].stringValue
deviceGroup = json["DeviceGroup"].stringValue
displayDensity = json["DisplayDensity"].stringValue
}
}
//
// DensityResult.swift
//
// Create by Javen Zhang on 29/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class DensityResult : NSObject, NSCoding{
var rows : [DensityRow]!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
rows = [DensityRow]()
let rowsArray = json["rows"].arrayValue
for rowsJson in rowsArray{
let value = DensityRow(fromJson: rowsJson)
rows.append(value)
}
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if rows != nil{
var dictionaryElements = [[String:Any]]()
for rowsElement in rows {
dictionaryElements.append(rowsElement.toDictionary())
}
dictionary["rows"] = dictionaryElements
}
return dictionary
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
rows = aDecoder.decodeObject(forKey: "rows") as? [DensityRow]
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
func encode(with aCoder: NSCoder)
{
if rows != nil{
aCoder.encode(rows, forKey: "rows")
}
}
}
//
// DensityRow.swift
//
// Create by Javen Zhang on 29/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class DensityRow : NSObject, NSCoding{
var devicegroup : String!
var displaydensity : String!
var n : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
devicegroup = json["devicegroup"].stringValue
displaydensity = json["displaydensity"].stringValue
n = json["n"].stringValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if devicegroup != nil{
dictionary["devicegroup"] = devicegroup
}
if displaydensity != nil{
dictionary["displaydensity"] = displaydensity
}
if n != nil{
dictionary["n"] = n
}
return dictionary
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
devicegroup = aDecoder.decodeObject(forKey: "devicegroup") as? String
displaydensity = aDecoder.decodeObject(forKey: "displaydensity") as? String
n = aDecoder.decodeObject(forKey: "n") as? String
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
func encode(with aCoder: NSCoder)
{
if devicegroup != nil{
aCoder.encode(devicegroup, forKey: "devicegroup")
}
if displaydensity != nil{
aCoder.encode(displaydensity, forKey: "displaydensity")
}
if n != nil{
aCoder.encode(n, forKey: "n")
}
}
}
//
// SpotsResult.swift
//
// Create by 云霄 曹 on 8/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class SpotsResult : NSObject{
var data : [SpotsData]!
var message : String!
var success : Bool!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
data = [SpotsData]()
let dataArray = json["data"].arrayValue
for dataJson in dataArray{
let value = SpotsData(fromJson: dataJson)
data.append(value)
}
message = json["message"].stringValue
success = json["success"].boolValue
}
}
class SpotsData : NSObject{
var hour : NSDictionary!
var increase : NSDictionary!
var realtimenumber : Int!
var spotid : String!
var time : String!
var totalnumber : Int!
var updatetimer : String!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
hour = json["hour"].dictionaryObject! as NSDictionary
increase = json["hour"].dictionaryObject! as NSDictionary
realtimenumber = json["realtimenumber"].intValue
spotid = json["spotid"].stringValue
time = json["time"].stringValue
totalnumber = json["totalnumber"].intValue
updatetimer = json["updatetimer"].stringValue
}
}
//
// SpotsResult.swift
//
// Create by Javen Zhang on 29/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class SpotsResult : NSObject, NSCoding{
var yesterdayrows : [SpotsYesterdayrow]!
var rows : [SpotsYesterdayrow]!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
yesterdayrows = [SpotsYesterdayrow]()
let yesterdayrowsArray = json["Yesterdayrows"].arrayValue
for yesterdayrowsJson in yesterdayrowsArray{
let value = SpotsYesterdayrow(fromJson: yesterdayrowsJson)
yesterdayrows.append(value)
}
rows = [SpotsYesterdayrow]()
let rowsArray = json["rows"].arrayValue
for rowsJson in rowsArray{
let value = SpotsYesterdayrow(fromJson: rowsJson)
rows.append(value)
}
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if yesterdayrows != nil{
var dictionaryElements = [[String:Any]]()
for yesterdayrowsElement in yesterdayrows {
dictionaryElements.append(yesterdayrowsElement.toDictionary())
}
dictionary["Yesterdayrows"] = dictionaryElements
}
if rows != nil{
var dictionaryElements = [[String:Any]]()
for rowsElement in rows {
dictionaryElements.append(rowsElement.toDictionary())
}
dictionary["rows"] = dictionaryElements
}
return dictionary
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
yesterdayrows = aDecoder.decodeObject(forKey: "Yesterdayrows") as? [SpotsYesterdayrow]
rows = aDecoder.decodeObject(forKey: "rows") as? [SpotsYesterdayrow]
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
func encode(with aCoder: NSCoder)
{
if yesterdayrows != nil{
aCoder.encode(yesterdayrows, forKey: "Yesterdayrows")
}
if rows != nil{
aCoder.encode(rows, forKey: "rows")
}
}
}
//
// SpotsYesterdayrow.swift
//
// Create by Javen Zhang on 29/3/2018
// Copyright © 2018. All rights reserved.
// Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport
import Foundation
import SwiftyJSON
class SpotsYesterdayrow : NSObject, NSCoding{
var cameradatetime : String!
var displayin : Int!
var displayout : Int!
/**
* Instantiate the instance using the passed json values to set the properties values
*/
init(fromJson json: JSON!){
if json.isEmpty{
return
}
cameradatetime = json["cameradatetime"].stringValue
displayin = json["displayin"].intValue
displayout = json["displayout"].intValue
}
/**
* Returns all the available property values in the form of [String:Any] object where the key is the approperiate json key and the value is the value of the corresponding property
*/
func toDictionary() -> [String:Any]
{
var dictionary = [String:Any]()
if cameradatetime != nil{
dictionary["cameradatetime"] = cameradatetime
}
if displayin != nil{
dictionary["displayin"] = displayin
}
if displayout != nil{
dictionary["displayout"] = displayout
}
return dictionary
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
cameradatetime = aDecoder.decodeObject(forKey: "cameradatetime") as? String
displayin = aDecoder.decodeObject(forKey: "displayin") as? Int
displayout = aDecoder.decodeObject(forKey: "displayout") as? Int
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
func encode(with aCoder: NSCoder)
{
if cameradatetime != nil{
aCoder.encode(cameradatetime, forKey: "cameradatetime")
}
if displayin != nil{
aCoder.encode(displayin, forKey: "displayin")
}
if displayout != nil{
aCoder.encode(displayout, forKey: "displayout")
}
}
}
......@@ -26,16 +26,15 @@ class ViewController: UIViewController {
let height: CGFloat = UIScreen.main.bounds.size.height
var oldFrame: CGRect!
/// 横坐标title
final lazy var xTitles: Array<String> = {
var xTitles = ["8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]
return xTitles
}()
var xTitles: Array<String> = []
var yTitles: Array<String> = []
/// 柱状图
@IBOutlet weak var barChartView: BarChartView!
/// 登陆用户信息
var userData: LoginData!
// var userData: LoginData!
var imageArray: Array<String> = {
......@@ -55,18 +54,19 @@ class ViewController: UIViewController {
// MARK: - 登陆
fileprivate func loginAction() {
Network.request(target: .Login(), success: {[weak self] (json) in
let model = LoginResult(fromJson: json)
if model.success {
self?.userData = model.data
self?.getSpotsDataAction()
self?.getDensityDataAction()
}else {
ShowMessage(model.message)
}
}) { (error) in
ShowMessage(error.localizedDescription)
}
self.getSpotsDataAction()
self.getDensityDataAction()
// Network.request(target: .Login(), success: {[weak self] (json) in
// let model = LoginResult(fromJson: json)
// if model.success {
// self?.userData = model.data
//
// }else {
// ShowMessage(model.message)
// }
// }) { (error) in
// ShowMessage(error.localizedDescription)
// }
}
// MARK: - 拍摄照片
......@@ -78,27 +78,21 @@ class ViewController: UIViewController {
// MARK: - 获取折线图数据
fileprivate func getSpotsDataAction() {
let time = Date().dateToDateString(dateFormat: "yyyy-MM-dd HH:mm:ss")
Network.request(target: .Spots(userData.uuid, time), success: {[weak self] (json) in
Network.request(target: .Spots(), success: {[weak self] (json) in
let model = SpotsResult(fromJson: json)
if model.success {
var todayValue = Array<Double>()
var yesterdayValue = Array<Double>()
for i in 0..<self!.xTitles.count {
if let count = model.data.last?.hour.object(forKey: self!.xTitles[i]) {
yesterdayValue.append(count as! Double)
}else {
yesterdayValue.append(0)
}
if let count = model.data.first?.hour.object(forKey: self!.xTitles[i]) {
todayValue.append(count as! Double)
}else {
todayValue.append(0)
}
}
self?.setChart(todayValue: todayValue, yesterdayValue: yesterdayValue)
}else {
ShowMessage(model.message)
var todayValue = Array<Double>()
var yesterdayValue = Array<Double>()
self?.xTitles.removeAll()
self?.yTitles.removeAll()
for i in 8..<model.yesterdayrows.count {
let yesterdayRow = model.yesterdayrows[i]
yesterdayValue.append(Double(yesterdayRow.displayin))
self?.xTitles.append(yesterdayRow.cameradatetime ?? "")
let todayRow = model.rows[i]
todayValue.append(Double(todayRow.displayin))
}
self?.setChart(todayValue: todayValue, yesterdayValue: yesterdayValue)
}) { (error) in
ShowMessage(error.localizedDescription)
}
......@@ -107,19 +101,16 @@ class ViewController: UIViewController {
// MARK: - 获取柱状图数据
fileprivate func getDensityDataAction() {
let time = Date().dateToDateString(dateFormat: "yyyy-MM-dd HH:mm:ss")
Network.request(target: .GETDensity(userData.uuid, time), success: {[weak self] (json) in
Network.request(target: .GETDensity(), success: {[weak self] (json) in
let model = DensityResult(fromJson: json)
if model.success {
var todayValue = Array<Double>()
var titleArray = Array<String>()
for i in 0..<model.data.count {
titleArray.append(model.data[i].deviceGroup)
todayValue.append(Double(model.data[i].displayDensity)!)
for i in 0..<model.rows.count {
titleArray.append(model.rows[i].devicegroup)
todayValue.append(Double(model.rows[i].displaydensity)!)
}
self?.setBarChart(todayValue: todayValue, title: titleArray)
}else {
ShowMessage(model.message)
}
}) { (error) in
ShowMessage(error.localizedDescription)
}
......@@ -144,7 +135,8 @@ class ViewController: UIViewController {
var tyesterdayDataEntries: [ChartDataEntry] = []
for i in 0..<xTitles.count {
let time = Date().hour
if Int(xTitles[i])! <= time {
let titleTime = xTitles[i].components(separatedBy: ":").first
if Int(titleTime!)! <= time {
let dataEntry = ChartDataEntry(x: Double(i), y: todayValue[i])
todayDataEntries.append(dataEntry)
}
......@@ -198,6 +190,9 @@ class ViewController: UIViewController {
// MARK: - 填充柱状图数据
fileprivate func setBarChart(todayValue: [Double], title: [String]) {
let formatter = BarChartViewAxisValueFormatter()
formatter.titleArray = title
barChartView.xAxis.valueFormatter = formatter
var dataEntris = [BarChartDataEntry]()
for i in 0..<todayValue.count {
let dataEntry = BarChartDataEntry(x: Double(i), y: todayValue[i])
......@@ -210,9 +205,6 @@ class ViewController: UIViewController {
let chartData = BarChartData(dataSet: chartDataSet)
chartData.setValueFormatter(DigitValueFormatter())
self.barChartView.data = chartData
let formatter = BarChartViewAxisValueFormatter()
formatter.titleArray = title
barChartView.xAxis.valueFormatter = formatter
self.barChartView.animate(yAxisDuration: 1.0, easingOption: .easeInBack)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment