下载ZedGraph.dll :/Files/ProgrammerSystem/ZedGraph.dll.rar
BuildReport.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BuildReport.aspx.cs" Inherits="Count_BuildReport" %>
<%@ Register TagPrefix="zgw" Namespace="ZedGraph.Web" Assembly="ZedGraph.Web" %>
<ZGW:ZEDGRAPHWEB id="ZedGraphWeb1" runat="server" width="780" Height="260" RenderMode="RawImage"
BarType="Stack" IsFontsScaled="false" IsShowTitle="true" BaseDimension="10" />
BuildReport.aspx.cs 类文件
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 System.Drawing;

using ZedGraph;
using ZedGraph.Web;

public partial class Count_BuildReport : System.Web.UI.Page
{
private string _serverName = "";
private string _startTime = "";
private string _endTime = "";

public string ServerName { get { return this._serverName; } set { this._serverName = value; } }
public string StartTime { get { return this._startTime; } set { this._startTime = value; } }
public string EndTime { get { return this._endTime; } set { this._endTime = value; } }

protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
接受参数
}
}

WebForm Designer generated code


private void OnRenderGraph(ZedGraphWeb zgw, Graphics g, MasterPane masterPane)
{
GraphPane myPane = masterPane[0];

报表相关属性设置

//从数据库中取出数据
DataSet ds = ManageAnalyzeDAL.CountDAL.GetOnlineCount(_serverName, _startTime, _endTime);
DataTable dt = ds.Tables[0];
DataTable dtTopOnlineCount = ds.Tables[1]; //某天中最高值

int dtRows = dt.Rows.Count / 24; //获取天数

PointPairList[] list = new PointPairList[dtRows];

for (int i = 0; i < dtRows; i++)
{
int startNum = i * 24;
int endNum = (i + 1) * 24 - 1;

list[i] = new PointPairList();

double intTopCount = Convert.ToDouble(dtTopOnlineCount.Rows[i]["onlineCount"]);

获取某天24小时的点
}

LineItem[] lineItem = new LineItem[dtRows];

for (int i = 0; i < dtRows; i++)
{
lineItem[i] = myPane.AddCurve(Convert.ToDateTime(dt.Rows[i * 23 + i]["WriteTime"]).ToShortDateString(), (PointPairList)list[i], getColor(i),SymbolType.Star);
}
masterPane.AxisChange(g);
}

DrawText

getColor
}
BuildReport.aspx页面





BuildReport.aspx.cs 类文件













































































【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步