Page 1 of 1

Multiple webcharts issue

Posted: Mon Aug 14, 2006 6:54 pm
by 9525970
Hello,

I am using multiple Webcharts in my web application with tempchart set to session, my question is should I have to use one GetChart.aspx file for each webchart object ? or just one GetChart.aspx for the entire app ?

I am copying and using the exact format for GetChart.aspx as specified in the tutorial.

Everytime I add a webchart to a page the previous chart gets messed up.

For example in a point series though the locations remain the same, the point labels all get messed up, the tooltip shows different labels for the points.

Any suggestions/ tips as to why this might be happening ?

Thanks
Amarsh

Posted: Wed Aug 16, 2006 8:51 am
by Chris
Hello Armash,

This is perfectly possible using code similar to:

Code: Select all

   private static string hfChartId_1;
    private static string hfChartId_2;
    protected void Page_Load(object sender, EventArgs e)
    {

      Steema.TeeChart.Chart ch1 = WebChart1.Chart;
      Steema.TeeChart.Chart ch2 = WebChart2.Chart;
      MemoryStream tmpChart = new MemoryStream();
      if (!IsPostBack)
      {
        hfChartId_1 = Guid.NewGuid().ToString() + "_1";
        hfChartId_2 = Guid.NewGuid().ToString() + "_2";
        Draw_Chart();
      }
      else
      {
        if (Session[hfChartId_1] != null)
        {
          tmpChart = (MemoryStream)Session[hfChartId_1];
          tmpChart.Position = 0;
          ch1.Import.Template.Load(hfChartId_1);
        }
        if (Session[hfChartId_2] != null)
        {
          tmpChart = (MemoryStream)Session[hfChartId_2];
          tmpChart.Position = 0;
          ch2.Import.Template.Load(hfChartId_2);
        } 
      }
    }

  private void Draw_Chart()
  {
    MemoryStream tmpChart = new MemoryStream();

    Steema.TeeChart.Chart ch1 = WebChart1.Chart;
    Steema.TeeChart.Chart ch2 = WebChart2.Chart;

    ch1.Series.Add(new Steema.TeeChart.Styles.Line());
    ch2.Series.Add(new Steema.TeeChart.Styles.Bar());

    ch1.Series[0].FillSampleValues();
    ch2.Series[0].FillSampleValues();

    ch1.Export.Template.Save(tmpChart);
    Session.Add(hfChartId_1, tmpChart);
    tmpChart.Position = 0;
    ch2.Export.Template.Save(tmpChart);
    Session.Add(hfChartId_2, tmpChart); 
  }
There are a number of further examples of this in the ASP.NET demo shipped with TeeChart for .NET.