iOS中画图表 使用HighChart
来源:互联网 发布:杭州橙群网络怎么样 编辑:程序博客网 时间:2024/05/29 13:52
首先,要将HighChart的包导入到工程中。这个包在下面的例子中是有的。
代码例子下载: http://pan.baidu.com/s/1eQIG68y
为WebView添加一个类别方便方法调用
UIWebView+UIWebView_LoadHighChart.h
//// UIWebView+UIWebView_LoadHighChart.h// HighChartDemo//// Created by 杜甲 on 14-1-7.// Copyright (c) 2014年 杜甲. All rights reserved.//#import <UIKit/UIKit.h>@interface UIWebView (UIWebView_LoadHighChart)-(void)loadHightChart;-(void)loadDocument:(NSString *)docName;@end
//// UIWebView+UIWebView_LoadHighChart.m// HighChartDemo//// Created by 杜甲 on 14-1-7.// Copyright (c) 2014年 杜甲. All rights reserved.//#import "UIWebView+UIWebView_LoadHighChart.h"#define ChartHtml @"demo.bundle/adaperHighChart.html"@implementation UIWebView (UIWebView_LoadHighChart)-(void)loadHightChart{ // [self performSelectorInBackground:@selector(loadDocument:) withObject:ChartHtml]; [self performSelectorOnMainThread:@selector(loadDocument:) withObject:ChartHtml waitUntilDone:NO]; // [self loadDocument:ChartHtml];}-(void)loadDocument:(NSString *)docName{ NSString *mainBundleDirectory=[[NSBundle mainBundle] bundlePath]; NSString *path=[mainBundleDirectory stringByAppendingPathComponent:docName]; NSURL *url=[NSURL fileURLWithPath:path]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; [self loadRequest:request]; }@end
ViewController.h
//// ViewController.h// NewHighChartDemo//// Created by 杜甲 on 14-1-7.// Copyright (c) 2014年 杜甲. All rights reserved.//#import <UIKit/UIKit.h>@interface ViewController : UIViewController<UIWebViewDelegate>@end
ViewController.m
//// ViewController.m// NewHighChartDemo//// Created by 杜甲 on 14-1-7.// Copyright (c) 2014年 杜甲. All rights reserved.//#import "ViewController.h"#import "UIWebView+UIWebView_LoadHighChart.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib. UIWebView* web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; web.delegate = self; [self.view addSubview:web]; [web loadHightChart]; }- (void)webViewDidFinishLoad:(UIWebView *)webView{ //showChart($('#container'),'',['吉林','大连','辽宁','黑龙江','上海','江苏','宁波','杭州','浙江','厦门','福建','江西','山东','青岛','湖南','湖北','河南'],'',[{type:'line' ,data:[['吉林',9.840000] ,['大连',7.270000] ,['辽宁',2.660000] ,['黑龙江',1.780000] ,['上海',8.040000] ,['江苏',2.600000] ,['宁波',3.960000] ,['杭州',1.900000] ,['浙江',1.280000] ,['厦门',3.450000] ,['福建',5.430000] ,['江西',0.850000] ,['山东',3.000000] ,['青岛',3.650000] ,['湖南',1.840000] ,['湖北',4.930000] ,['河南',0.140000] ] , name:'应收率'}],'line',335.000000,230.000000) NSArray* cityArr = @[@"吉林",@"大连",@"辽宁",@"黑龙江",@"上海",@"江苏",@"宁波",@"杭州",@"浙江",@"厦门",@"福建",@"江西",@"山东",@"青岛",@"湖南",@"湖北",@"河南"]; NSData* jsonData = [NSJSONSerialization dataWithJSONObject:cityArr options:NSJSONWritingPrettyPrinted error:nil]; NSString* json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; NSLog(@"%@",json); [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"showChart($('#container'),'',%@,'',[{type:'line' ,data:[['吉林',9.840000] ,['大连',7.270000] ,['辽宁',2.660000] ,['黑龙江',1.780000] ,['上海',8.040000] ,['江苏',2.600000] ,['宁波',3.960000] ,['杭州',1.900000] ,['浙江',1.280000] ,['厦门',3.450000] ,['福建',5.430000] ,['江西',0.850000] ,['山东',3.000000] ,['青岛',3.650000] ,['湖南',1.840000] ,['湖北',4.930000] ,['河南',0.140000] ] , name:'应收率'}],'line',335.000000,230.000000)",json]];}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- iOS中画图表 使用HighChart
- ExtJs中使用highChart
- vue中使用highchart
- highchart 画图,datatable根据图中数值画表的demo
- highchart使用
- Highchart在react中使用雷达图
- iOS画图 在控件中画图
- IOS中使用CGContext画图填充渐变颜色图层
- IOS中画图方法列举
- ios开发使用CGContextRef画图
- iOS开发 CGContextRef画图使用
- HighChart使用总结
- 使用highchart.js
- iOS画图 在控件中画图,并实现清理
- 使用echarts画图表
- highchart
- highchart
- highchart
- String.getBytes()的问题
- 架构图汇总
- samba是什么
- MongoDB MapReduce
- vc 使用COM
- iOS中画图表 使用HighChart
- MATLAB函数句柄(@),feval与内连函数(inline)
- HDS USP系列存储(一)专业名词解释(持续添加中..)
- 取模运算和求余运算的区别
- window.showModalDialog使用手册
- MySQL Cluster(MySQL 集群) 初入测试
- http://bbs.csdn.net/topics/390330900 地址备忘
- 用户空间的映射
- coreseek配置