MSCHARTIN ERROR "A chart element with the name 'LightBlue' could not be found in the 'SeriesCollection'."

Mar 26 2010 12:35 PM
I AM GETTING THE ERROR WHILE WORKING WITH MSCHARTING.

A chart element with the name 'LightBlue' could not be found in the 'SeriesCollection'.




HTML CODE
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Chart ID="Chart1" runat="server">
<Legends>
<asp:Legend Name="Legend1">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Name="Title1">
</asp:Title>
</Titles>
<Series>
<asp:Series Name="Series1" ChartType="StackedBar100" ></asp:Series>
</Series>
<MapAreas>
<asp:MapArea Coordinates="0,0,0,0" />
</MapAreas>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
</div>
</form>
</body>
</html>



C# CODE
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.UI.DataVisualization.Charting;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Populate series data
Random random = new Random();
for (int pointIndex = 0; pointIndex < 10; pointIndex++)
{
Chart1.Series["Series1"].Points.AddY(random.Next(45, 95));
}
// Set chart type
Chart1.Series["Series1"].ChartType = SeriesChartType.StackedArea100;
// Show point labels
Chart1.Series["Series1"].IsValueShownAsLabel = true;
// Disable X axis margin
Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = false;
// Enable 3D
Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;

//// Set the first two series to be grouped into Group
Chart1.Series["LightBlue"]["StackedGroupName"] = "Group1";
Chart1.Series["Gold"]["StackedGroupName"] = "Group1";
//// Set the last two series to be grouped into Group2
Chart1.Series["Red"]["StackedGroupName"] = "Group2";
Chart1.Series["DarkBlue"]["StackedGroupName"] = "Group2";
}
}