分頁檔
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Area.aspx.cs" Inherits="OFCDemo.ofc.Area" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ofc:Chart ID="ofcArea" runat="server" Url="../data/AreaData.aspx" Width="90%"
Height="500px" />
</div>
</form>
</body>
</html>
資料檔案。
這裡是空心點拋物線和實心的拋物線都合并在一起開發的。
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenFlashChart;
namespace OFCDemo.data
{
public partial class AreaData : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Graph graph = new Graph();
graph.Title = new Title("拋物線地區圖", "{font-size: 14px;}");
//X軸名,字型,字型顏色。
graph.LegendX = new LegendX("拋物線圖", 12, "#000000");
//Y軸名,字型,字型顏色。
graph.LegendY = new LegendY("Text Value", 12, "#00FF00");
//y軸的最大值
graph.MaxY = 2;
//y軸的最小值
graph.MinY = -2;
////y軸的步長
graph.StepsY = 2;
//構造報表資料對象
OpenFlashChart.Charts.ChartData areaLine, areaHollow;
areaLine = new OpenFlashChart.Charts.Line(2, "#C4B86A", "實心點線圖", 12, 2);
areaHollow = new OpenFlashChart.Charts.AreaHollow(2, 4, "#573567", 10, "空心點線圖", 12, "#573567");
Random rd = new Random();
for (float i = 0; i < 30; i++)
{
//加點值
areaLine.Data.Add(Convert.ToSingle(Math.Sin(i * 0.2)));
areaHollow.Data.Add(Convert.ToSingle(Math.Sin(i * 0.2) + 0.5));
graph.LabelsX.Add(string.Format("{0}日", i));
}
graph.Data.Add(areaLine);
graph.Data.Add(areaHollow);
//輸出資料
Response.Clear();
Response.CacheControl = "no-cache";
Response.Write(graph.ToString());
Response.End();
}
}
}