在ASP.net图形中使用数组

本文关键字:数组 图形 ASP net | 更新日期: 2023-09-27 18:09:01

我必须对从数据库中提取的数据进行一些计算。我现在有一个双数组,有24个数据点。是否有一种方法可以将这些信息绘制到我网站上现有的图表上?

using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.DataVisualization.Charting;
using System.Web.UI.WebControls;
public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Get data for limits
        DataView avgLim = avgLimits.Select(DataSourceSelectArguments.Empty) as DataView;
        DataTable averageLim = avgLim.ToTable();
        //Add data for single fill parts
        DataView dv = noDamper.Select(DataSourceSelectArguments.Empty) as DataView;
        DataTable singleDT = dv.ToTable();

        //Add data for Dampered Parts
        DataView dv1 = Damper.Select(DataSourceSelectArguments.Empty) as DataView;
        DataTable damperDT = dv1.ToTable();
        damperData.Series.Add("damperData");
        //Moving Average starts here
        //Calc moving data
        Double[] singleMovData = new Double[24];
        Double[] damperMovData = new Double[24];
        //GET DATA TO Column
        Double[] tempSingle = new Double[25];
        Double[] tempDamper = new Double[25];
        int j =0;
        foreach (DataRow row in singleDT.Rows)
            tempSingle[j++] = Convert.ToInt32(row[2]);//Convert.ToDouble(row[3]);
        j =0;
        foreach(DataRow row in damperDT.Rows)
            tempDamper[j++] = Convert.ToInt32(row[2]);
        for (int i = 0; i <= 23; i++)
        {
            singleMovData[i] = Math.Abs(Convert.ToDouble(tempSingle[i]) - Convert.ToDouble(tempSingle[i+1]));
            damperMovData[i] = Math.Abs(Convert.ToDouble(tempDamper[i]) - Convert.ToDouble(tempDamper[i + 1]));
        }
        //singleFillMoving.Series.Add("singleMov");
        //singleFillMoving.Series["singleMov"].ChartType = SeriesChartType.Line;
        singleFillMoving.DataSource = singleMovData;
        //singleFillMoving.Series.Add(singleMovData);
        singleFillMoving.DataBind();
        damperFillMoving.Series.Add("damperData");
        damperFillMoving.Series["damperData"].ChartType = SeriesChartType.Line;
        //damperFillMoving.Series["damperData"].XValueMember = "CONTAINER_ID";
        //damperFillMoving.Series["damperData"].YValueMembers = "DIFFERENCE";
        damperFillMoving.DataSource = damperMovData;
        damperFillMoving.DataBind();  
    }
}

在ASP.net图形中使用数组

singleFillMoving.Series["singleMov"].Points.DataBindY(singleMovData);

这是我需要的代码行。只是需要挖得足够深。