ext曲线图 asp.net
公司要做进度曲线图,查了资料,看到ext可以实现,数据格式用json,返回形如
{totalCount:6,success:true,error:"",singleInfo:"",data:[{name:'2010-3-1 0:00:00',visits:1000,views:800},{name:'2010-3-2 0:00:00',visits:1200,views:1000},{name:'2010-3-3 0:00:00',visits:1500,views:1800},{name:'2010-3-4 0:00:00',visits:1300,views:1000},{name:'2010-3-5 0:00:00',visits:1400,views:1800},{name:'2010-3-6 0:00:00',visits:1000,views:500}]} 数据
代码extjs
var fields = ['name','visits','views'];
store = new Ext.data.Store({
   
proxy:new Ext.data.HttpProxy(
{
http://www.cnblogs.com/longfeitengda/admin/%22HandlerJdjhMap.ashx",
method:"POST"
}),
reader:new Ext.data.JsonReader(
{
fields:fields,
root:"data"
              
})
});
store.load();
new Ext.Panel({
iconCls: 'chart',
title: 'test',
frame: true,
renderTo: 'map1',
width: 500,
height:300,
layout: 'fit',
  
items: {
xtype: 'columnchart',
store: store,
url: '../ext-3.0.3/resources/charts.swf',
xField: 'name',
yAxis: new Ext.chart.NumericAxis({
displayName: 'Visits',
labelRenderer: Ext.util.Format.numberRenderer('0,0')
}),
tipRenderer: function (chart, record, index, series) {
if (series.yField == 'visits') {
return Ext.util.Format.number(record.data.visits, '0,0') + ' 实际完成 ' + record.data.name;
} else {
return Ext.util.Format.number(record.data.views, '0,0') + '预期完成在 ' + record.data.name;
}
},
       
series: [{
type: 'line',
displayName: 'Page Views',
yField: 'views',
style: {
image: 'bar.gif',
mode: 'stretch',
color: 0x99BBE8
}
},
{
type: 'line',
displayName: 'Visits',
yField: 'visits',
style: {
color: 0x15428B
}
}]
}
});
代码
代码
store = new Ext.data.Store({
proxy:new Ext.data.HttpProxy(
{
http://www.cnblogs.com/longfeitengda/admin/%22HandlerJdjhMap.ashx",
method:"POST"
}),
reader:new Ext.data.JsonReader(
{
fields:fields,
root:"data"
})
});
store.load();
new Ext.Panel({
iconCls: 'chart',
title: 'test',
frame: true,
renderTo: 'map1',
width: 500,
height:300,
layout: 'fit',
items: {
xtype: 'columnchart',
store: store,
url: '../ext-3.0.3/resources/charts.swf',
xField: 'name',
yAxis: new Ext.chart.NumericAxis({
displayName: 'Visits',
labelRenderer: Ext.util.Format.numberRenderer('0,0')
}),
tipRenderer: function (chart, record, index, series) {
if (series.yField == 'visits') {
return Ext.util.Format.number(record.data.visits, '0,0') + ' 实际完成 ' + record.data.name;
} else {
return Ext.util.Format.number(record.data.views, '0,0') + '预期完成在 ' + record.data.name;
}
},
series: [{
type: 'line',
displayName: 'Page Views',
yField: 'views',
style: {
image: 'bar.gif',
mode: 'stretch',
color: 0x99BBE8
}
},
{
type: 'line',
displayName: 'Visits',
yField: 'visits',
style: {
color: 0x15428B
}
}]
}
});
代码
<%@ WebHandler Language="C#" Class="HandlerJdjhMap" %>
using System;
using System.Web;
public class HandlerJdjhMap : IHttpHandler {
public string ReportJSON = "";
reportnew report1 = new reportnew();
public void ProcessRequest(HttpContext context)
{
bool flag = false;
string starts = context.Request.Form["start"];
string limits = context.Request.Form["limit"];
string start = "";
string limit = "";
if (starts != null && limits != null)
{
if (starts == "" || limits == "")
{
GetRoomtypeJSON();
}
else
{
GetRoomtypeJSON(starts.ToString(), limits.ToString());
}
}
else
{
GetRoomtypeJSON();
}
context.Response.ContentType = "text/plain";
context.Response.Write(ReportJSON);
}
public bool IsReusable
{
get
{
return false;
}
}
public void GetRoomtypeJSON(string start, string limit)
{
ReportJSON = report1.getReport(start, limit);
}
public void GetRoomtypeJSON()
{
ReportJSON = report1.getReport();
}
}
using System;
using System.Web;
public class HandlerJdjhMap : IHttpHandler {
public string ReportJSON = "";
reportnew report1 = new reportnew();
public void ProcessRequest(HttpContext context)
{
bool flag = false;
string starts = context.Request.Form["start"];
string limits = context.Request.Form["limit"];
string start = "";
string limit = "";
if (starts != null && limits != null)
{
if (starts == "" || limits == "")
{
GetRoomtypeJSON();
}
else
{
GetRoomtypeJSON(starts.ToString(), limits.ToString());
}
}
else
{
GetRoomtypeJSON();
}
context.Response.ContentType = "text/plain";
context.Response.Write(ReportJSON);
}
public bool IsReusable
{
get
{
return false;
}
}
public void GetRoomtypeJSON(string start, string limit)
{
ReportJSON = report1.getReport(start, limit);
}
public void GetRoomtypeJSON()
{
ReportJSON = report1.getReport();
}
}
代码
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;
/// <summary>
/// reportnew 的摘要说明
/// </summary>
public class reportnew
{
public reportnew()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//['name','visits','views']
public string getReport(string start, string limit)
{
string reportinfor;
string sql = "select * from report where nowdate>='" + start +"'and nowdate<='" + limit +"'";
DataSet ds = DBAccess.Query(sql);
JSONHelper json = new JSONHelper();
if (ds.Tables[0].Rows.Count > 0)
{
json.success = true;
foreach (DataRow dr in ds.Tables[0].Rows)
{
json.AddItem("name", dr["nowdate"].ToString());
json.AddItem("visits", int.Parse(dr["shiji"].ToString()));
json.AddItem("views", int.Parse(dr["jihua"].ToString()));
json.ItemOk();
}
json.totlalCount = ds.Tables[0].Rows.Count;
reportinfor = json.ToString();
}
else
{
reportinfor = "{success:false}";
}
return reportinfor;
 
}
public string getReport()
{
string reportinfor;
string sql = "select * from report ";
DataSet ds = DBAccess.Query(sql);
JSONHelper json = new JSONHelper();
if (ds.Tables[0].Rows.Count > 0)
{
json.success = true;
foreach (DataRow dr in ds.Tables[0].Rows)
{
json.AddItem("name", dr["nowdate"].ToString());
json.AddItem("visits", int.Parse(dr["shiji"].ToString()));
json.AddItem("views", int.Parse(dr["jihua"].ToString()));
json.ItemOk();
             
}
json.totlalCount = ds.Tables[0].Rows.Count;
reportinfor = json.ToString();
}
else
{
reportinfor = "{success:'false'}";
}
return reportinfor;
}
}
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DBUtility;
/// <summary>
/// reportnew 的摘要说明
/// </summary>
public class reportnew
{
public reportnew()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//['name','visits','views']
public string getReport(string start, string limit)
{
string reportinfor;
string sql = "select * from report where nowdate>='" + start +"'and nowdate<='" + limit +"'";
DataSet ds = DBAccess.Query(sql);
JSONHelper json = new JSONHelper();
if (ds.Tables[0].Rows.Count > 0)
{
json.success = true;
foreach (DataRow dr in ds.Tables[0].Rows)
{
json.AddItem("name", dr["nowdate"].ToString());
json.AddItem("visits", int.Parse(dr["shiji"].ToString()));
json.AddItem("views", int.Parse(dr["jihua"].ToString()));
json.ItemOk();
}
json.totlalCount = ds.Tables[0].Rows.Count;
reportinfor = json.ToString();
}
else
{
reportinfor = "{success:false}";
}
return reportinfor;
}
public string getReport()
{
string reportinfor;
string sql = "select * from report ";
DataSet ds = DBAccess.Query(sql);
JSONHelper json = new JSONHelper();
if (ds.Tables[0].Rows.Count > 0)
{
json.success = true;
foreach (DataRow dr in ds.Tables[0].Rows)
{
json.AddItem("name", dr["nowdate"].ToString());
json.AddItem("visits", int.Parse(dr["shiji"].ToString()));
json.AddItem("views", int.Parse(dr["jihua"].ToString()));
json.ItemOk();
}
json.totlalCount = ds.Tables[0].Rows.Count;
reportinfor = json.ToString();
}
else
{
reportinfor = "{success:'false'}";
}
return reportinfor;
}
}
                    
                

                
            
        
浙公网安备 33010602011771号