Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i having a data grid in my program.i want to plot a chart according to two colum values.
employee id and Perfomance colum.
employee Id colum contain string value like EMP002.
Perfomance column contain percentage values.


i tried this code
C#
chart1.DataSource = dataGridView1;
           chart1.Series["series1"].XValueMember = "Employee Id";
           chart1.Series["series1"].YValueMembers = "Perfomance";
           chart1.DataBind();


but i am gettin aerror like-----A chart element with the name 'series1' could not be found in the 'SeriesCollection'.




HOW CAN I DO THIS
Posted
Updated 12-Jun-13 0:03am
v3

I do not think that you can bind DataGridView to a MS Chart control. List of supported types which can be used from binding are

•SqlCommand
•OleDbCommand
•SqlDataAdapter
•OleDbDataAdapter
•DataView
•DataSet
•DataReader
•List
•Array
•IList
•IListSource
•IEnumerable

try binding the source directly to your chart and providing the x and y values form original source.

more help you can see Data Binding Microsoft Chart Control[^]
 
Share this answer
 
Hi,

Please make sure you have graph structure as below,
XML
<asp:chart id="chart1" runat="server" xmlns:asp="#unknown">
	<series>
		<asp:series name="series1">
		</asp:series>                
	</series>
</asp:chart>


Error says that you are missing Series with the given name.

[Edit]
Let me know if this is in ASP.NET or in C# windows forms ?
[/Edit]

Best luck
~Amit
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900