ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  New Chart Director dll chart viewstate no longer works.
Posted by Kevin on Jan-23-2015 00:41
I am using asp.net 4.0 and have recently updated my netchartdir.dll from one that was created 9/30/2005 with one that was 10/29/2012. When that change was made now when I do a postback on the page the chart image does not persist through the postback. It is almost as if this being set EnableViewState="true" ViewStateMode="Enabled"  is not enabling the viewstate anymore.

Thanks,
Kevin

  Re: New Chart Director dll chart viewstate no longer works.
Posted by Peter Kwan on Jan-24-2015 04:29
Hi Kevin,

ChartDirector is never designed to maintain the chart state in postback. It is because a
chart is a very large object and can contain or output a huge amount of data, and it
would be impractical to store it in the ViewState and send to the browser and send back
to the server during postback.

After reading your post, I did some test and found that older versions of ChartDirector
apparently maintains the chart image during postback. However, the image map (the
tooltips and clickable hotspots) was not maintained.

What actually persists during postback is the image URL, not the image itself, and it is an
automatic side-effect of the Image base class. (WebChartViewer is a subclass of the
Image control.)

In 2006, we started to support drag to zoom/scroll, and in modern versions of
ChartDirector, we support track cursors. These features use additional data structures
(hidden fields) which do not persist during postback. The code was changed at that some
so that the image URL no longer persist.

So in brief, ChartDirector is never designed to maintain chart state, and even in older
versions of ChartDirector, it does not maintain the full chart state, but just the image.

Our suggestion is to simply regenerate the chart during postback. In this way, all
ChartDirector features (tooltips, clickable hot spots, track cursors, etc) would work
during postback. If you just need the image but not the other features, you can try the
following method:

if (!IsPostBack)
{
   //not postback, so draw chart as usual
   drawChart();

   //save the chart to be used during postback
   Session["chart"] = WebChartViewer1.Image;
}
else
{
   //use the saved chart instead of drawing another one
   WebChartViewer1.Image = (WebImage)Session["chart"];
}

Regards
Peter Kwan