par*_*gic 5 iphone highcharts ipad ios
我是HighCharts的新手,我提到了示例http://blog.li-labs.com/developing-ios-apps-with-custom-charting/并尝试了相同的功能,但在iPad模拟器上我得到了一个空白屏幕.
我已经提到了关于堆栈溢出的问题,但它仍然没有用.任何人都可以告诉我哪里出错了.
编辑:我的HTML文件中的代码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
// Radialize the colors
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
// Build the chart
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: 'Browser market shares at a specific website, 2010'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
});
</script>
</head>
<body>
<!--<script src="../../js/highcharts.js"></script>-->
<!--<script src="../../js/modules/exporting.js"></script>-->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如何在XCode中添加和使用Javascript库
以下是我如何处理XCode中的代码和数据的简单视图.
从您喜欢的图表网站下载Javascript报告包.就我而言:http://www.highcharts.com/download
将文件添加或导入XCode资源.(我建议创建一个名为JS的组).
将资源添加到XCode时,通常会将其标记为需要编译.确保文件未列为"已编译".最简单的方法是将文件从目标 - >您的项目名称 - >编译的源拖动到目标 - >您的项目名称 - >复制包资源.
创建一个测试html文件或只是从HighChart(或任何其他javascript图表库)示例文件夹中导入一个.在我的情况下,我将其命名为hcpie.html
确保标记中的任何文件引用都不会递归或移动到任何文件夹中(即使它们位于项目中的一个文件夹中).例如
对=
错误=
- 在界面设计器中创建一个UIWebView并将其链接到您的视图(在我的例子中,我将其命名为chart1).例如
@interface FirstViewController:UIViewController {IBOutlet UIWebView*chart1; }
@结束
加载时只需引用HTML示例文件即可.
- (void)viewDidLoad {
NSString*pathOfFile = [[NSBundle mainBundle] pathForResource:@"hcpie"ofType:@"html"]; NSString*htmlText = [NSString stringWithContentsOfFile:pathOfFile encoding:NSUTF8StringEncoding error:nil];
NSURL*baseURL = [NSURL fileURLWithPath:pathOfFile];
[chart1 loadHTMLString:htmlText baseURL:baseURL];
[super viewDidLoad];
}
脚步:-
1)首先只创建一个html文件并执行必要的代码或试用可以从包中获取的示例中复制html代码http://www.highcharts.com/download
2)确保html中的脚本应具有适当的.js链接,例如: - <script src="http://code.highcharts.com/highcharts.js"></script>
要么
如果你想在本地提供它,你可以写<script src="highcharts.js"></script>
但是确保.js文件在你的应用程序文件夹中.
3) NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"graph" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[obj loadHTMLString:htmlString baseURL:nil]; // Webview *obj;
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.在我的情况下它的工作.
| 归档时间: |
|
| 查看次数: |
7433 次 |
| 最近记录: |