webview加载js图形报表
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了webview加载js图形报表,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含5257字,纯文字阅读大概需要8分钟。
内容图文
-
<! doctype html > < html lang ="en" > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=UTF-8" > < script type ="text/javascript" src ="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js" ></ script > < script type ="text/javascript" src ="http://cdn.hcharts.cn/highcharts/highcharts.js" ></ script > < script type ="text/javascript" src ="http://cdn.hcharts.cn/highcharts/exporting.js" ></ script > < script type ="text/javascript" > var result = window.Android.getResult(); // 调用android中的方法,取得从android传递过来的数据 // alert("result="+result); var jsonData = eval( " ( " + result + " ) " ); // 将json字符串数据转换为jsonObject对象 // alert("jsonData="+jsonData); var xText = jsonData.xtext; // 解析xtext节点数据 // alert("xText="+xText); var data = jsonData.data; // alert("data="+data); var xdata = jsonData.xdata; // alert("xdata="+xdata); $( function () { $( ‘ #container ‘ ).highcharts({ chart: { type: ‘ areaspline ‘ }, title: { text: ‘ 收费统计 ‘ }, legend: { layout: ‘ vertical ‘ , align: ‘ left ‘ , verticalAlign: ‘ top ‘ , x: 150 , y: 100 , floating: true , borderWidth: 1 , backgroundColor: ‘ #FFFFFF ‘ }, xAxis: { title: { text: xText }, categories:xdata, plotBands: [{ // visualize the weekend from: 4.5 , to: 6.5 , // color: ‘rgba(68, 170, 213, .2)‘ color: ‘ rgba(68, 255, 0, 0) ‘ }] }, yAxis: { title: { text: ‘ 收费 ‘ } }, tooltip: { shared: true , valueSuffix: ‘ units ‘ }, credits: { enabled: false }, plotOptions: { areaspline: { fillOpacity: 0.5 } }, series: [{ name: ‘ 收费 ‘ , data: data }] }); }); </ script > < style > body { margin : 0 ; padding : 0 ; } </ style > </ head > < body > < div id ="container" style ="width:100%;height:400px" ></ div > </ body > </ html >
-
private void initWebView() { activity = this; webview.setVisibility(View.VISIBLE); WebSettings webSettings = webview.getSettings(); url = "file:/android_asset/index3.html"; // 支持JS webSettings.setJavaScriptEnabled(true); webSettings.setDisplayZoomControls(false); // 隐藏webview缩放按钮 webview.addJavascriptInterface(new JsInteration(), "Android"); webview.setWebChromeClient(new WebChromeClient() { }); // 设置进度条 webview.setWebChromeClient(new WebChromeClient() { publicvoid onProgressChanged(WebView view, int progress) { activity.setTitle("小弟正在努力加载中..."); activity.setProgress(progress * 100); if (progress == 100) activity.setTitle(R.string.app_name); } }); webview.setWebViewClient(new WebViewClient() { publicvoid onReceivedError(WebView view, int errorCode, String description, String failingUrl) { // Handle the error } @Override publicboolean shouldOverrideUrlLoading(WebView view, String url2) { if (Uri.parse(url2).getHost().equals(url)) { // Load the site into the default browser Intent intent = new Intent(Intent.ACTION_VIEW, Uri .parse(url)); startActivity(intent); returntrue; } // 1:返回false: Load url into the webview // 2:返回true:已浏览器方式returnfalse; } }); webview.loadUrl(url); } private String showtype; publicclass JsInteration { @JavascriptInterface public String getResult() { JSONObject jsonObject = new JSONObject(); try { JSONArray jsonArray1 = new JSONArray(); JSONArray jsonArray2 = new JSONArray(); for (int j = 0; j < list2.size(); j++) { //这里的list2是通过接口从服务器取得的数据集合 StatisticsChartInfo statisticsChartInfo = list2.get(j); jsonArray1.put(statisticsChartInfo.getCurrtime()); jsonArray2.put(Double.valueOf(statisticsChartInfo .getRevenue())); } jsonObject.put("xtext", xtext); jsonObject.put("xdata", jsonArray1); jsonObject.put("data", jsonArray2); } catch (JSONException e) { e.printStackTrace(); } LogUtil.d("传递的数据=" + jsonObject.toString()); return jsonObject.toString(); } } @Override protectedvoid onDestroy() { // TODO Auto-generated method stubsuper.onDestroy(); if (webview!= null) { webview.destroy(); } }
原文:http://www.cnblogs.com/xiaoxiao-study/p/3206fd1935a0a3f8440fc59beb7c950b.html
内容总结
以上是互联网集市为您收集整理的webview加载js图形报表全部内容,希望文章能够帮你解决webview加载js图形报表所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。