We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Different Graphs with one Chart Control

I have a need to use one Chart Control that will allow me to graph various types of data. For example, I would like to graph a pie chart of Coded Data and then allow the user to select from a list a X and Y field (from data) that is then plotted as a simple Line Chart. I would like to reuse the same Chart Control as was used with the Pie chart. I can plot the Pie chart without any trouble (and also a Bar Chart) but when I try to plot the Line Chart I get a nullrefrence (see my post about NullReference when adding to a series). I am Clearing the series before I attempt to build the new series (with the XY data) but when I try to add to the ChartControl series I get the NullReference error. How do I "reset" the chart to use different data and plot that data?

Thanks.
David.

I am using 6.1 and ASP.NET 2.0


5 Replies

AD Administrator Syncfusion Team March 19, 2008 09:16 AM UTC

Hi David,

Thank you for using Syncfusion Products.

Please use the Series.BeginUpdate() and Series.EndUpdate() code in this manner. The NullReferenceException is not seen now.
this.ChartWebControl1.Series.BeginUpdate();
this.ChartWebControl1.Series.Add(series); this.ChartWebControl1.Series.EndUpdate();

Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Chart.Web/6.1.0.34/72416/main.htm

Please use this and let me know if it helps.

Regards,
Anupama



DA David March 19, 2008 01:16 PM UTC

Thank you for your quick reply. I did put in the BeginUpdate and EndUpdate but that did not solve the problem. I still get a NullReference when trying to add a series to the chart control. On my page I have 4 types of graphs (XY Scatter, Multi-Y, Bar and Pie). When the user clicks the graph button whatever type chart was selected will be drawn. I default to the Pie chart (which comes up fine). Then if I select a Bar Chart it works but XY or Multi-Y does not. A note that might help is that the Pie and Bar charts use the same data while the XY and Multi-Y use totally different type of data.

I ended up having to use a PlaceHolder control and dynamically build the chart for each type of graph the user wanted to draw. It just might be my development environment (Visual Studio 2008 and Vista). Don't know why it does not work. I have a simple test project that is almost exactly like the sample you gave me but it does not work either.

Thanks for your help anyway.

David.



MA Manohari Syncfusion Team May 31, 2008 03:25 PM UTC

Hi David,

Thanks for the update. Could you please provide us with the simple sample that could reproduce the reported issue. So that it would help us to sort out the problem and to provide you with a better solution at the earliest.

Thanks for your patience.

Regards,
Manohari.R



AD Administrator Syncfusion Team November 4, 2008 04:49 AM UTC

David,

I realize this thread is a bit old, but your approach addresses the new question I have.

I want to use a PlaceHolder to dynamically generate charts for various input requests. However, unless I put a "holder" chart in the aspx file, it does not work out. I'd like to just use the "new" and then add the chart control to the PlaceHolder.

Bob



>Thank you for your quick reply. I did put in the BeginUpdate and EndUpdate but that did not solve the problem. I still get a NullReference when trying to add a series to the chart control. On my page I have 4 types of graphs (XY Scatter, Multi-Y, Bar and Pie). When the user clicks the graph button whatever type chart was selected will be drawn. I default to the Pie chart (which comes up fine). Then if I select a Bar Chart it works but XY or Multi-Y does not. A note that might help is that the Pie and Bar charts use the same data while the XY and Multi-Y use totally different type of data.

I ended up having to use a PlaceHolder control and dynamically build the chart for each type of graph the user wanted to draw. It just might be my development environment (Visual Studio 2008 and Vista). Don't know why it does not work. I have a simple test project that is almost exactly like the sample you gave me but it does not work either.

Thanks for your help anyway.

David.





MA Manohari Syncfusion Team November 14, 2008 09:22 AM UTC

Hi Bob,

Thanks for your interest in Syncfusion products. Please find our response to your query below.

For ChartWebControl to display correctly, the fHTTPHandler entry is needed to be included in your application webConfig file.







Hence, could you please make sure whether the following HTTP handler is being included in your application webconfig file. Because, by default when you drag and drop ChartWebControl, this HTTP handler is included automatically. And since you add the control through code using new, this Handler entry may not be included in your Web config file.

Please let us know if this helps in resolving your problem. Thanks for your patience.

Regards,
Manohari.R


Loader.
Live Chat Icon For mobile
Up arrow icon