javascript中嵌入java代码
今天又长了一个见识,以前我一直不知道javascript中可以嵌入java代码,今天才知道是可以嵌入的。在这里非常感谢飞哥。下面把java代码贴在下面:
<% CreateUserRecodeBean bean = (CreateUserRecodeBean)pageContext.getAttribute("createUserRecodeBean"); int[] todayData = bean.getTodayDateByHour(); String data = ""; for(int i:todayData){ data +=i+","; } data = data.substring(0,data.length()-1); %>
<script type="text/javascript"> jQuery(function() { var data = "<%=data%>".split(","); var data_ = []; for(var i=0;i<data.length;i++){ data_.push(parseInt(data[i])); } var options = { chart: {"defaultSeriesType":"line","animation":false,"renderTo":"installations-by-hours-chart"}, title: {"text":""}, legend: {"margin":25,"enabled":true}, xAxis: {"categories":["00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"], "labels":{"step":2,"align":"right","rotation":-90}}, yAxis: {"title":"","tickPixelInterval":50,"min":0}, tooltip: {"enabled":true}, credits: {"enabled":false}, plotOptions: {"area":{"stacking":null}}, series: [{"name":"今天","data":data_,"type":null,"visible":true}, {"name":"昨天","data":[10,10,3,4,2,1,3,5,8,3,12,16,21,17,9,21,21,18,13,17,13,18,12,8],"type":null,"visible":false}] }; //[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0] options.tooltip.formatter = function() { return parseInt(this.x,10) +':00 ~' + (parseInt(this.x,10) + 1) + ':00 新增 '+ this.y + ' 个用户'; } var chart = new Highcharts.Chart(options); }); </script>
通过上面的方式从数据库中抽取数据显示到界面上非常方便
相关推荐
nmgxzm00 2020-11-10
ifconfig 2020-10-14
hhanbj 2020-11-17
zfszhangyuan 2020-11-16
古叶峰 2020-11-16
一个智障 2020-11-15
jipengx 2020-11-12
81427005 2020-11-11
xixixi 2020-11-11
游走的豚鼠君 2020-11-10
苗疆三刀的随手记 2020-11-10
Web卓不凡 2020-11-03
小飞侠V 2020-11-02
帕尼尼 2020-10-30
爱读书的旅行者 2020-10-26
帕尼尼 2020-10-23
杏仁技术站 2020-10-23
淼寒儿 2020-10-22