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 |