I want to use HighCharts in Android and iOS mobile apps . Is there any libraries or Gradle dependencies are availble in Android or iOS?
问题:
回答1:
If you have already written code in Highcharts
and want to display it in iOS
, then the best way would be to display the chart inside a webView
. From this answer:
1) First just creat one html file and do the needful code or for trial can copy html code from examples that you get from package http://www.highcharts.com/download
2) Make sure that the scripts in html should have proper .js links for e.g:-
or
if you want to give it locally you can write But make sure that the .js files are there in your application folder.
3)
NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"graph" ofType:@"html"]; NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil]; [obj loadHTMLString:htmlString baseURL:nil];
OR
You could use one of the many native libraries available for android and iOS. "Why would I want to do that" you ask? Well, for starters, Native code performs much smoother and faster than HTML/Javascript-code-inside-a-webview. Additionally, you would have much finer control of what you display. For instance, you could handle Clustering inside your app itself.
Here are some of the good ones I know, but there are lots of good libraries if you search.
Android : MPAndroidChart
iOS : iOS-Charts and JBChartView
回答2:
You may check the following libraries
- iOS : https://www.cocoacontrols.com/controls/swiftcharts
- Android: https://github.com/PhilJay/MPAndroidChart