Highcharts报表 饼状图编程代码
2016-09-07 10:18
169 查看
第一步:http://www.hcharts.cn/demo/highcharts 官网下载Highcharts包,并且解压,引入项目
第二步:创建页面,找到 以下js文件 Highcharts-4.2.6/js/highcharts.js
第三步:创建js文件 ,js代码
$(function () {
$("#btnSave").click(function () {
istxt();
var txtBeginTime = $("#txtBeginTime").val();
var txtEndTime = $("#txtEndTime").val();
$.ajax({
type: "POST",
url: "TjQy1.aspx/btnSaveGetInitForm",
data: "{'tjsjq':'" + txtBeginTime + "','tjsjz':'" + txtEndTime + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (results) {
var arary = eval(results.d);
console.log(arary);
var output = [];
for (var i in arary) {
output.push([arary[i].Key, arary[i].Value]);
}
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: '企业数量统计'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{ type: 'pie', name: '企业数量', data: output}]
});
}
});
})
})
第四步:页面html部署
<meta http-equiv="content-type" content="text/html;charest=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=8" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<input type="button" id="btnSave" value="查询" class="blue_30_btn" />
<div id="container" style="min-width: 400px; height: 400px">
</div>
第五步 页面后端代码 创建 查询按钮事件
//点击查询
[WebMethod]
public static string btnSaveGetInitForm(string tjsjq, string tjsjz)
{
DataTable dt = Qhchanglike.TJqy("estdate>='" + tjsjq + "' and estdate<='" + tjsjz + "'").Tables[0];
int lm= Convert.ToInt32(dt.Rows[0]["列名1"]);
int lmtew = Convert.ToInt32(dt.Rows[0]["列名2"]);
List<IDictionary<string, object>> list = new List<IDictionary<string, object>>();
IDictionary<string, object> transferParams = new Dictionary<string, object>();
transferParams.Add("Key", "列名1");
transferParams.Add("Value",
lm);
list.Add(transferParams);
transferParams = new Dictionary<string, object>();
transferParams.Add("Key", "列名2");
transferParams.Add("Value",
lmtew);
list.Add(transferParams);
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(list);
}
详细请点:http://www.hcharts.cn/demo/highcharts
有什么不懂的请评论,也可以探讨
第二步:创建页面,找到 以下js文件 Highcharts-4.2.6/js/highcharts.js
第三步:创建js文件 ,js代码
$(function () {
$("#btnSave").click(function () {
istxt();
var txtBeginTime = $("#txtBeginTime").val();
var txtEndTime = $("#txtEndTime").val();
$.ajax({
type: "POST",
url: "TjQy1.aspx/btnSaveGetInitForm",
data: "{'tjsjq':'" + txtBeginTime + "','tjsjz':'" + txtEndTime + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (results) {
var arary = eval(results.d);
console.log(arary);
var output = [];
for (var i in arary) {
output.push([arary[i].Key, arary[i].Value]);
}
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: '企业数量统计'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{ type: 'pie', name: '企业数量', data: output}]
});
}
});
})
})
第四步:页面html部署
<meta http-equiv="content-type" content="text/html;charest=utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=8" />
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<input type="button" id="btnSave" value="查询" class="blue_30_btn" />
<div id="container" style="min-width: 400px; height: 400px">
</div>
第五步 页面后端代码 创建 查询按钮事件
//点击查询
[WebMethod]
public static string btnSaveGetInitForm(string tjsjq, string tjsjz)
{
DataTable dt = Qhchanglike.TJqy("estdate>='" + tjsjq + "' and estdate<='" + tjsjz + "'").Tables[0];
int lm= Convert.ToInt32(dt.Rows[0]["列名1"]);
int lmtew = Convert.ToInt32(dt.Rows[0]["列名2"]);
List<IDictionary<string, object>> list = new List<IDictionary<string, object>>();
IDictionary<string, object> transferParams = new Dictionary<string, object>();
transferParams.Add("Key", "列名1");
transferParams.Add("Value",
lm);
list.Add(transferParams);
transferParams = new Dictionary<string, object>();
transferParams.Add("Key", "列名2");
transferParams.Add("Value",
lmtew);
list.Add(transferParams);
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Serialize(list);
}
详细请点:http://www.hcharts.cn/demo/highcharts
有什么不懂的请评论,也可以探讨
相关文章推荐
- [转]水晶报表参数编程示例代码[http://blog.csdn.net/xwdd129/archive/2006/05/29/760672.aspx]
- 水晶报表参数编程示例代码
- 水晶报表参数编程示例代码
- 水晶报表参数编程示例代码
- 使用phantomjs实现highcharts等报表通过邮件发送(本文仅提供完整解决方案和实现思路,完全照搬不去整理代码无法马上得到效果)
- Highcharts 统计报表的使用(饼状图)
- 水晶报表参数编程示例代码
- [转]c#编程更改水晶报表中公式字段示例代码 [http://blog.csdn.net/xwdd129/archive/2006/05/29/760661.aspx]
- 水晶报表参数编程示例代码
- Highcharts报表 柱状图的编写代码
- 水晶报表参数编程示例代码
- 水晶报表参数编程示例代码
- 水晶报表参数编程示例代码
- JQuery_HighCharts生成图形报表_饼状图(模仿后台传送数据 JSON格式)
- 编程实现Office 2003 Research 功能的代码详解C#篇(2)
- WEB编程开发常用的代码
- 编程更改文本对象示例代码
- AOP:通过面向方面编程提高代码的封装和复用性
- 编程实现Office 2003 Research 功能的代码详解C#篇(4)
- SQL常见编程代码汇总