Page 1 of 1
Cumulative Graph in ASP??
Posted: Tue Jan 03, 2006 4:15 pm
by 9639571
I am attempting to create an ASP application that uses a cumulative graph. The problem I have is that every time a control button is activated, the page reloads and the previous data dissapears. This was not an issue in windows froms. How can I retain the current series on page reload when adding another series?
I assume this is something to do with the TEMPCHART setting. Can someone tell me how to set this to Session? I am new to ASP and the tutorial in section 9 did not make it clear to me.
Posted: Wed Jan 04, 2006 7:40 am
by Chris
Hi -
You can use code similar to the following:
Code: Select all
private void Page_Load(object sender, System.EventArgs e)
{
// ****************************************************
//The data load code for WebChart1 demostrates a technique to save
//data between page calls. The Chart is saved as a TeeChart template
//to a session variable.
// ****************************************************
Steema.TeeChart.Chart ch1=WebChart1.Chart;
MemoryStream tmpChart=new MemoryStream();
if (Session["ch1"]==null)
{
//setup Chart
if (ch1.Series.Count<2)
{
ch1.Series.Add(new Steema.TeeChart.Styles.Points());
ch1.Series.Add(new Steema.TeeChart.Styles.Points());
}
ch1.Header.Text="Chart 1.";
((Steema.TeeChart.Styles.Points)ch1.Series[0]).Pointer.Pen.Visible=false;
((Steema.TeeChart.Styles.Points)ch1.Series[1]).Pointer.Pen.Color=Color.FromArgb(79,79,255);
ch1.Series[0].Color=Color.FromArgb(255,199,26);
ch1.Series[1].Color=Color.FromArgb(106,106,255);
ch1.Series[0].FillSampleValues(5);
ch1.Series[1].FillSampleValues(5);
//export Chart to a MemoryStream template
ch1.Export.Template.Save(tmpChart);
//save template to a Session variable
Session.Add("ch1",tmpChart);
}
else
{
//retrieve the session stored Chart
tmpChart=(MemoryStream)Session["ch1"];
//set the Stream position to 0 as the last read/write
//will have moved the position to the end of the stream
tmpChart.Position=0;
//import saved Chart
ch1.Import.Template.Load(tmpChart);
}
}