<!DOCTYPE html> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/style_box_demo.css"> <script type="text/javascript" src="merge.js"></script> <script type="text/javascript" charset="utf-8"> <!--frame 位置--> <!--type:1 折線圖 2 柱狀圖 3 餅狀圖--> <!--ymax y軸最大值--> <!--xtitles x軸下面的標題--> <!--dataSource 數據源組--> <!--{--> <!-- piePercentValue 數值--> <!-- color 顏色--> <!-- text 關聯名--> <!-- project 關聯項目名--> <!-- plots 點集合--> <!-- isShowPoint 顯示點--> <!--}--> function createchart() { var options = { "frame" : [0,104,375,200], "type":1, "ymax":1000, "isShowPoint":1, "xtitles" :["1", "2", "3", "4", "5", "6", "7", "8" , "9", "10", "11", "12"], "dataSource" :[ { "piePercentValue": "10", "color": [200, 0, 135], "text":"1組", "project":"1組", "plots":["200", "800", "500", "300", "1000", "600", "100", "300" , "500", "600", "700", "800"] }, { "piePercentValue": "20", "color": [10, 50, 205], "text":"2組", "project":"2組", "plots":["700", "300", "400", "500", "300", "500", "700", "800" , "900", "800", "400", "600"] }, { "piePercentValue": "20", "color": [0, 40, 135], "text":"3組", "project":"3組", "plots":["800", "300", "600", "900", "600", "700", "600", "500" , "400", "300", "900", "600"] } ] }; showChartView.chartutility(testSuccess,testFailed,[options]); } function testSuccess(msg) { alert(msg); } function testFailed(msg) { alert('failed: ' + msg); } function goHome() { cordova.exec(testSuccess,testFailed,"ChartUtilityPlugin","remove"); window.location.href = "index.html"; } </script> </head> <body> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <div class="btn bg_5" onclick="createchart();">生成圖表</div><br/> <div class="btn bg_1" onclick="goHome();">返回</div><br/> </body> </html>
出現這種報錯的原因是
showChartView.chartutility(testSuccess,testFailed,[options]);
數據類型錯誤,這里去掉括號即可,已經聲明的參數等同於["xxxx"]
showChartView.chartutility(testSuccess,testFailed,options);