ichartjsのデータは動的に値を割り当てて、jsのデータ構造.
4128 ワード
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp" %>
<?xml version="1.0" encoding="utf-8"?>
<imag>
<script>
<![CDATA[
$page.onload = fre();
function fre(){
var url = '${host}/image/lineChart1';
$http.get(url,function(data){
var objs = eval(data);
if(objs==null||objs.length<=0){
return;
}
var map = objs[0];
var name = map.name;
var value=map.value;
var day = map.day;
var hour = map.hour!=null?map.hour.toString():"";
var _hours = "";
// day , 。
if(hour.indexOf(",")!=-1){
var hs = hour.split(",");
var status = false;
for(var i = 0 ; i < hs.length;i++){
_hours+="\""+hs[i]+"\",";
status = true;
}
if(status){
_hours = _hours.substring(0,_hours.length-1);
}
}
//var src =
//alert(hour);
var html = $('web').html ;
var hint = html.substring(html.search('var'),html.search(';'));
//
var mfunction = "var value= ["+value+"];"+
"var hour= ["+_hours+"];"+
"var data = ["+
" {"+
" name : \" \","+
" value:value,"+
" color:'#0d8ecf',"+
" line_width:3"+
" }"+
" ];"+
"var chart = new iChart.LineBasic2D({"+
" render : 'canvasDiv',"+
" data: data,"+
" title : '"+name+day+" ',"+
" turn_off_touchmove:true,"+
" width : 1350,"+
" height : 450,"+
// 。
/*tip:{
enable:true,
shadow:true
},*/
" legend : {"+
" enable : true,"+
" row:1,"+
" column : 'max',"+
" valign:'top',"+
" sign:'bar',"+
" background_color:null,"+
" offsetx:-80,"+
" border : true"+
" },"+
" coordinate:{height:'90%',background_color:'#f6f9fa'},"+
" sub_option:{"+
" hollow_inside:false,"+
" point_size:16"+
" },"+
"labels:hour,"+
" });"+
"chart.draw();";
$('web').exec(mfunction);
//alert(mfunction);
});
}
$page.setInterval(function(){
fre();
hint(" ");
},1000*60*20);
]]>
</script>
<page style="background:#ecf0f1">
<title style="background:navigator.png">
<left>
<%@ include file="../common/backButton.jsp" %>
</left>
<center>
<label>${title}</label>
</center>
<right>
<button onclick="tuichu();" style="background:left.png"></button>
</right>
</title >
<content>
<button onclick="fre();"> </button>
<web id="web" include="ichart.1.2.min.js" scalable="true" >
<![CDATA[
<html>
<head>
</head>
<body>
<div id="canvasDiv">
</div>
</body>
</html>
]]>
</web>
</content>
</page>
</imag> _hours+="\""+hs[i]+"\",";
jsのデータストア、タイプ変換処理.