Integrate hundreds of echarts3.0 and iosecharts3.0 in iOS

Source: Internet
Author: User

Integrate hundreds of echarts3.0 and iosecharts3.0 in iOS

# Import "HistoryDateCell. h "# import" HistoryDateModel. h "# import <WebKit/WebKit. h> # import "TimeTools. h "# define BTN_BACKCOLOR JdryRGBColorAlpha (25,180,212, 0.2) # define SELECTBTN_BACKCOLOR JdryColorFromHex (0 xFFFFFF)/* macro color definition */# define JdryColorFromHex (s) [UIColor colorWithRed :( (s & 0xFF0000)> 16)/255.0 green :( (s & 0xFF00)> 8)/255.0 blue :( (s & 0xFF )) /255.0 alpha: 1.0] # define JdryRGBColor (r, g, B )[ UIColor colorWithRed :( r)/255.0 green :( g)/255.0 blue :( B)/255.0 alpha: 1.0] # define JdryRGBColorAlpha (r, g, B,) [UIColor colorWithRed :( r)/255.0 green :( g)/255.0 blue :( B)/255.0 alpha: a]; # define BACK_COLOR JdryColorFromHex (0xE8F0F2) # define BLUE_COLOR JdryColorFromHex (0x19B5D4) # define RED_COLOR JdryColorFromHex (0xF95656)/* Get the screen size of the device */# define JdryScreeWidth [UIScreen mainScreen]. bounds. size. width # define Jd RyScreeHeight [UIScreen mainScreen]. bounds. size. height # define JdryScreeBounds [UIScreen mainScreen]. bounds @ interface compute () <response> @ property (weak, nonatomic) IBOutlet UIButton * dayBtn; @ property (weak, nonatomic) IBOutlet UIButton * monthBtn; @ property (weak, nonatomic) IBOutlet UIButton * yearBtn;/** echart */@ property (strong, nonatomic) WKWebView * wkWebView;/** xAxisData */ @ Property (strong, nonatomic) NSString * xAxisData;/** total */@ property (strong, nonatomic) NSMutableString * valueDat;/** A */@ property (strong, nonatomic) NSMutableString * valueDatA;/** B */@ property (strong, nonatomic) NSMutableString * valueDatB;/** C */@ property (strong, nonatomic) NSMutableString * valueDatC; /** X axis */@ property (strong, nonatomic) NSMutableString * xAxis; @ end @ implementation HistoryDateCell-(voi D) awakeFromNib {[super awakeFromNib]; self. xAxis = [NSMutableString string]; [self setEcharts: self. webContentView];}-(void) setHistoryDate :( NSArray *) historyDate {_ historyDate = historyDate; self. subType = @ "cos"; self. timeType = @ "2"; [self selectSubType: self. subType timeType: _ timeType];}-(void) selectSubType :( NSString *) subType timeType :( NSString *) timeType {self. valueDat = [NSMutableString strin G]; self. valueDatA = [NSMutableString string]; self. valueDatB = [NSMutableString string]; self. valueDatC = [NSMutableString string]; if ([subType isEqualToString: @ "I"]) {for (HistoryDateModel * model in _ historyDate) {[_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. ia]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. ib]; [_ valueDatC appendString: [NSString StringWithFormat: @ "'% @',", model. ic] ;}} else if ([subType isEqualToString: @ "U"]) {for (HistoryDateModel * model in _ historyDate) {[_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. ua]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. ub]; [_ valueDatC appendString: [NSString stringWithFormat: @ "'% @',", model. uc] ;}} else if ([subType isEqualToString: @ "P"]) {( HistoryDateModel * model in _ historyDate) {[_ valueDat appendString: [NSString stringWithFormat: @ "'% @',", model. p]; [_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. pa]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. pb]; [_ valueDatC appendString: [NSString stringWithFormat: @ "'% @',", model. pc] ;}} else if ([subType isEqualToString: @ "Q"]) {for (HistoryDateModel * Model in _ historyDate) {[_ valueDat appendString: [NSString stringWithFormat: @ "'% @',", model. q]; [_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. qa]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. qb]; [_ valueDatC appendString: [NSString stringWithFormat: @ "'% @',", model. qc] ;}} else if ([subType isEqualToString: @ "S"]) {for (HistoryDateModel * model in _ histor YDate) {[_ valueDat appendString: [NSString stringWithFormat: @ "'% @',", model. s]; [_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. sa]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. sb]; [_ valueDatC appendString: [NSString stringWithFormat: @ "'% @',", model. SC] ;}} else if ([subType isEqualToString: @ "cos"]) {for (HistoryDateModel * model in _ historyDate) {[_ valu EDat appendString: [NSString stringWithFormat: @ "'% @',", model. cos]; [_ valueDatA appendString: [NSString stringWithFormat: @ "'% @',", model. cosa]; [_ valueDatB appendString: [NSString stringWithFormat: @ "'% @',", model. cosb]; [_ valueDatC appendString: [NSString stringWithFormat: @ "'% @',", model. cosc] ;}}for (HistoryDateModel * model in _ historyDate) {if ([timeType is1_tostring: @ "0"]) {[_ xAxis appendStr Ing: [NSString stringWithFormat: @ "'% @',", [TimeTools timeWithDateAndHourAndMIn: model. fixTimeDate];} else if ([timeType is1_tostring: @ "1"]) {[_ xAxis appendString: [NSString stringWithFormat: @ "'% @',", [TimeTools timeWithDayAndMonthString: model. fixTimeDate];} else if ([timeType is1_tostring: @ "2"]) {[_ xAxis appendString: [NSString stringWithFormat: @ "'% @ month ',", [TimeTools timeWithDateAndMonth: model. f IxTimeDate] ;}} if (! [SubType isEqualToString: @ "I"] &! [SubType isEqualToString: @ "U"]) {[_ valueDat deleteCharactersInRange: NSMakeRange (_ valueDat. length-1, 1)];} [_ valueDatA deleteCharactersInRange: NSMakeRange (_ valueDatA. length-1, 1)]; [_ valueDatB deleteCharactersInRange: NSMakeRange (_ valueDatB. length-1, 1)]; [_ valueDatC deleteCharactersInRange: NSMakeRange (_ valueDatC. length-1, 1)]; [_ xAxis deleteCharactersInRange: NSMakeRange (_ xAxis. length-1, 1)];} # Pragma mark-set echarts-(void) setEcharts :( UIView *) contentView {NSString * path = [[NSBundle mainBundle] pathForResource: @ "HistoryData" ofType: @ "html"]; self. wkWebView = [[WKWebView alloc] initWithFrame: CGRectMake (0, 0, JdryScreeWidth-30,406)]; if (path) {if ([[UIDevice currentDevice]. systemVersion floatValue]> = 9.0) {NSURL * fileURL = [NSURL fileURLWithPath: path]; [self. wkWebView loadFileURL: f IleURL allowingReadAccessToURL: fileURL];} else {NSURL * fileURL = [self affinity: [NSURL fileURLWithPath: path]; NSURLRequest * request = [NSURLRequest requestWithURL: fileURL]; [self. wkWebView loadRequest: request] ;}} self. wkWebView. navigationDelegate = self; [contentView addSubview: self. wkWebView];}-(NSURL *) fileURLForBuggyWKWebView8 :( NSURL *) fileURL {NSError * error = nil; if (! FileURL. fileURL |! [FileURL checkResourceIsReachableAndReturnError: & error]) {return nil;} // Create "/temp/www" directory NSFileManager * fileManager = [NSFileManager defamanager]; NSURL * temDirURL = [[NSURL fileURLWithPath: NSTemporaryDirectory ()] metadata: @ "www"]; [fileManager createDirectoryAtURL: temDirURL metadata: YES attributes: nil error: & error]; NSURL * dstURL = [temDirURL URLByAppendingPathComponent: fileURL. lastPathComponent]; // Now copy given file to the temp directory [fileManager removeItemAtURL: dstURL error: & error]; [fileManager copyItemAtURL: fileURL toURL: dstURL error: & error]; // Files in "/temp/www" load flawlesly :) return dstURL;}-(void) webView :( WKWebView *) webView didFinishNavigation :( WKNavigation *) navigation {[self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setValueDate ([% @])", _ valueDat] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setValueDateA ([% @])", _ valueDatA] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setValueDateB ([% @])", _ valueDatB] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setValueDateC ([% @])", _ valueDatC] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setXAxisData ([% @])", _ xAxis] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: [NSString stringWithFormat: @ "setSubType ('% @')", self. subType] completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}]; [self. wkWebView evaluateJavaScript: @ "update ()" completionHandler: ^ (id dict, NSError * error) {NSLog (@ "% @", error) ;}];}-(void) setFrame :( CGRect) frame {frame. origin. y = frame. origin. y + = 10; frame. size. height = frame. size. height-= 10; [super setFrame: frame];}-(void) setSelected :( BOOL) selected animated :( BOOL) animated {[super setSelected: selected animated: animated]; // Configure the view for the selected state}-(IBAction) selectDay :( UIButton *) sender {sender. backgroundColor = SELECTBTN_BACKCOLOR; self. monthBtn. backgroundColor = BTN_BACKCOLOR; self. yearBtn. backgroundColor = BTN_BACKCOLOR;}-(IBAction) selectMonth :( UIButton *) sender {sender. backgroundColor = SELECTBTN_BACKCOLOR; self. dayBtn. backgroundColor = BTN_BACKCOLOR; self. yearBtn. backgroundColor = BTN_BACKCOLOR;}-(IBAction) selectYear :( UIButton *) sender {sender. backgroundColor = SELECTBTN_BACKCOLOR; self. monthBtn. backgroundColor = BTN_BACKCOLOR; self. dayBtn. backgroundColor = BTN_BACKCOLOR;} @ end

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.