Echarts和JSTL、EL标签的混合使用

示例代码:

<c:if test="${empty sessionScope.taData}">
		<jsp:forward page="TempServlet"></jsp:forward>
	</c:if>

	<c:set var="taData" value="${sessionScope.taData}"></c:set>

	<script>
	  var ctdata=new Array();
	  var daydata=new Array();
	</script>

	<c:forEach var="t" items="${taData}" varStatus="status">
		<script>
	  		ctdata.push("${t.ct}");
	  		daydata.push("${t.day}")
		</script>
	</c:forEach>


	<div id="main" style="width: 1024px; height: 800px;"></div>

	<script>
		var myChart = echarts.init(document.getElementById('main'));
		option = {
			    xAxis: {
			        type: 'category',
			        data: daydata
			    },
			    yAxis: {
			        type: 'value'
			    },
			    series: [{
			        data: ctdata,
			        type: 'line',
			        smooth: true
			    }]
			};
		myChart.setOption(option);
	</script>


	<c:remove var="taData" />

  

posted @ 2020-06-09 11:18  rask  阅读(382)  评论(0编辑  收藏  举报