我无法在Android Webview中渲染HighCharts。这是在Android 4.0 +
上以下是我的HTML代码
<html lang="en" >
<head>
<meta charset="utf-8" />
<meta name="author" content="Script Tutorials" />
<title>How to create active charts using Highcharts | Script Tutorials</title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
</head>
<body>
<div id="chart_1" class="chart"></div>
<script type='text/javascript'>
$(document).ready(function() {
// First chart initialization
var chart1 = new Highcharts.Chart({
chart: {
renderTo: 'chart_1',
type: 'area',
height: 350,
},
title: {
text: 'Tools developers plans to use to make html5 games (in %)'
},
xAxis: {
categories: ['Processing.js', 'Impact.js', 'Other', 'Ease.js', 'Box2D.js', 'WebGL', 'DOM', 'CSS', 'Canvas', 'Javascript']
},
yAxis: {
title: {
text: 'Interviewed'
}
},
series: [{
name: 'Dev #1',
data: [5, 10, 20, 22, 25, 28, 30, 40, 80, 90]
}, {
name: 'Dev #2',
data: [15, 15, 18, 40, 30, 25, 60, 60, 80, 70]
}, {
name: 'Dev #3',
data: [1, 3, 6, 0, 50, 25, 50, 60, 30, 100]
}]
});
});</script>
</body>
</html>
我从资产目录中读取html文件,使用bufferedreader将其转换为字符串,然后使用
将其加载到webview中webview.loaddata(customHtml, "text/html", "UTF-8");
答案 0 :(得分:1)
您是否在网络视图中启用了Javascript?如果没有,只需在onCreate方法中添加以下行:
webview.getSettings().setJavaScriptEnabled(true);
其中&#34; webview&#34;是:
WebView webview = (WebView)findViewById(R.id.my_webview);
答案 1 :(得分:0)
当我使用highcharts和android webview时,我遇到了同样的问题...
WebView webview;
webview = (WebView) findViewById(R.id.webview);
WebSettings settings = webview.getSettings();
settings.setJavaScriptEnabled(true);
webview.clearCache(true);
settings.setDomStorageEnabled(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("your_website.com");
我将此代码用于本机应用程序,并且效果很好...