Click here to Skip to main content
15,887,285 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi all,

I have created charts dynamically and want to add the charts created dynamically into a list, or store as chart image first then add them into a list.

Question: How to add chart created dynamically into a list using C# / save chart as image first then add them into a list using C#?


This is my codes to create the chart dynamically:
C#
Chart Chart1 = new Chart();
                          Chart1.DataSource = dt;
                          Chart1.Width = 800;
                          Chart1.Height = 500;
 
                          Chart1.Series.Add(new Series());
                          Chart1.Series[0].ChartType = SeriesChartType.BoxPlot;
 
                          List<object> List_CHART = dt.AsEnumerable().ToList<object>();
 
                          foreach (DataRow row in dt.Rows)
                          {
                              Chart1.Series[0].Points.AddXY(row["TITLE"], new object[] { row["MIN"], row["MAX"], row["25TH_PERCENTILE"], row["75TH_PERCENTILE"], row["50TH_PERCENTILE"], row["AVG"] });
                          }
 
                          //create chartareas
                          ChartArea ca= new ChartArea();
                          ca.AxisX = new Axis();
                          ca.AxisY = new Axis();
                          Chart1.ChartAreas.Add(ca);
 
                          //databind
                          Chart1.DataBind();
                          Chart1.Visible = true;
 
                          panel.Controls.Add(Chart1);

Appreciate if someone can provide me help on this, thanks!
Posted
Comments
Ralf Meier 21-Oct-15 8:45am    
Because of you got no answer until now :
With your code-snippet I got no match (for me) to your question.
So your should write something more about your issue.

What I understood :
- you have a datatable which contents your values for the chart
- you want to create the chart dynamicly and fill it with those values - does it work in the moment ?
- you want to save the chart as an image - to where ?
- you want to create a list from the chart-entries - why that, I don't understand ?

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