<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="pie" style="width:800px;height:600px;"> </div>
</div>
</form>
<script src="../scripts/jquery-1.10.2.min.js"></script>
<script src="esl.js"></script>
<script src="test.js"></script>
</body>
</html>/////////////////////// 以上是 html 或者是 aspx 部分,以下是 js 关键部分///////////
//////////////////////////////////////
$(function () {
var fileLocation = '../Report/echarts';//访问路径
require.config({
paths: {
echarts: fileLocation,
'echarts/chart/line': fileLocation,
'echarts/chart/bar': fileLocation,
'echarts/chart/pie': fileLocation
}
});
// 作为入口
require(
[
'echarts',
'echarts/chart/pie'
],
displayChart
)
});
function displayChart(ec) {
var pieChart = ec.init(document.getElementById('pie')); //饼图
$.post('../ashx/WarehouseInMainHandler.ashx?Method=PieData',
function (data) { //data 返回的数据是 json 格式字符串
var objData = $.parseJSON(data);//把字符串转成对象
var dLegend = [];
var dSource = [];
$(objData.rows).each(function (i, obj) {//遍历
dLegend[i] = obj.WarehouseName;
dSource[i] = { value: obj.Qty.replace('.00', ''), name:
obj.WarehouseName };
//这里是针对某一项进行渲染
if (i == 1) {
dSource[i].itemStyle = {
normal: {
color: (function () {
var zrColor = require('zrender/tool/color');
return zrColor.getRadialGradient(
300, 200, 110, 300, 200, 140,
[[0, 'rgba(255,255,0,1)'], [1,
评论3