页面文件

<%@ 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 />
    </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();
        }
    }
}

相关文章: