图表可视化数据

时间:2012-05-18 17:43:44

标签: c# sql-server visual-studio-2010

我试图从表格中的数据中篡改图表,我创建了一个arraylist(arlData),但我发现了这个异常“你只能为这个数据点设置1个Y值。 参数名称:yValue'我该怎么办?

        chart1.Series.Add("W1 Electricity");
        chart1.Series.Add("W2 Electricity");
        chart1.Series.Add("W1 Gas");
        chart1.Series.Add("W2 Gas");

        chart1.Series["W1 Electricity"].Color = Color.Red;
        chart1.Series["W2 Electricity"].Color = Color.Blue;

        chart1.Series["W1 Gas"].Color = Color.Green;
        chart1.Series["W2 Gas"].Color = Color.Green;

        foreach (UsageWeek objCurrEntry in arlData)
        {
            chart1.Series["W1 Electricity"].Points.AddXY(1, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(2, objCurrEntry.StartDate,objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(3, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(4, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(5, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(6, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Electricity"].Points.AddXY(7, objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W Electricity"].Points.AddXY(objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W1 Gas"].Points.AddXY(objCurrEntry.StartDate, objCurrEntry.EndDate);
            chart1.Series["W2 Gas"].Points.AddXY(objCurrEntry.StartDate, objCurrEntry.EndDate);

        }

         //X-axis labels 
        chart1.Series["W1 Electricity"].Points[0].AxisLabel = "Monday";
        chart1.Series["W1 Electricity"].Points[1].AxisLabel = "Tuesday";
        chart1.Series["W1 Electricity"].Points[2].AxisLabel = "Wednesday";
        chart1.Series["W1 Electricity"].Points[3].AxisLabel = "Thursday"; 
        chart1.Series["W1 Electricity"].Points[4].AxisLabel = "Friday";
        chart1.Series["W1 Electricity"].Points[5].AxisLabel = "Saturday";
        chart1.Series["W1 Electricity"].Points[6].AxisLabel = "Sunday";

        //X-axis labels 
        chart1.Series["W2 Electricity"].Points[0].AxisLabel = "Monday";
        chart1.Series["W2 Electricity"].Points[1].AxisLabel = "Tuesday";
        chart1.Series["W2 Electricity"].Points[2].AxisLabel = "Wednesday";
        chart1.Series["W2 Electricity"].Points[3].AxisLabel = "Thursday";
        chart1.Series["W2 Electricity"].Points[4].AxisLabel = "Friday";
        chart1.Series["W2 Electricity"].Points[5].AxisLabel = "Saturday";
        chart1.Series["W2 Electricity"].Points[6].AxisLabel = "Sunday";


    }

`

0 个答案:

没有答案