0

我试图从表中的数据中可视化图形,我创建了一个数组列表(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";


    }

`

4

0 回答 0