Page 1 of 1

dynamic generation of charts

Posted: Thu Apr 20, 2006 9:50 am
by 9640127
hi,
how do i generate multiple charts from code behind in c# without dragging them onto the designer at first ?
eg..
i want to generate 'n' number of charts depending on the value of 'n' i get from the database. since i dont know the value of 'n' before hand i cant drag and drop those number of objects in the designer.
my sample code is pasted below :

//generate 3 different charts
for (int k = 0; k < 3; k++)
{
Database db = DatabaseFactory.CreateDatabase();
DataSet ds = db.ExecuteDataSet(CommandType.Text, "select * from datavalues order by bench");

Steema.TeeChart.Web.WebChart webchart1 = new Steema.TeeChart.Web.WebChart();
Steema.TeeChart.Chart Chart1 = webchart1.Chart;

Steema.TeeChart.Axis bottomAxis = Chart1.Axes.Left;
bottomAxis.Automatic = false;
bottomAxis.Increment = 0.5;
bottomAxis.Maximum = 5;
bottomAxis.Minimum = 0;

//3 different bar graphs on each chart
for (int j = 0; j < 3; j++)
{
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(Chart1);
bar1.YValues.DataMember = ds.Tables[0].Columns[2].ToString();
bar1.DataSource = ds.Tables[0];
bar1.Title = "crap" + j;
}
}


with this i get a blank screen.

what am i doing wrong?
could you please suggest a smple code for this?

thanks,
POP.

Posted: Thu Apr 20, 2006 10:17 am
by narcis
Hi POP,

To dynamically generate WebCharts you need to use Response.Write to write HTML to the browser as done here:

Code: Select all

  protected Steema.TeeChart.Web.WebChart WebChart1;

    protected void Page_Load(object sender, EventArgs e)
    {

      WebChart1 = new Steema.TeeChart.Web.WebChart();
      WebChart1.ID = "WebChart1";

      WebChart1.GetChartFile = "GetChart.aspx";
      WebChart1.TempChart = Steema.TeeChart.Web.TempChartStyle.Session;

      Steema.TeeChart.Chart ch1 = WebChart1.Chart;

      ch1.Series.RemoveAllSeries();
      ch1.Series.Add(new Steema.TeeChart.Styles.Pie());
      (ch1.Series[0] as Steema.TeeChart.Styles.Pie).Circled = true;
      (ch1.Series[0] as Steema.TeeChart.Styles.Pie).Pen.Visible = true;

      ch1.Series[0].FillSampleValues();

      ch1.Legend.Shadow.Visible = false;
      ch1.Legend.Visible = false;

      // Apply palette                          
      Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(ch1.Chart, 7);

      //Response.Write("<tchart:WebChart id=\"WebChart1\" style=\"Z-INDEX: 104; LEFT: 56px; POSITION: absolute; TOP: 56px\" runat=\"server\"Width=\"760px\" Height=\"448px\" TempChart=\"File\" ClickedY=\"0\" ClickedX=\"0\" GetChartFile=\"GetChart.aspx\" AutoPostback=\"False\" Config=\"AAEAAAD/////AQAAAAAAAAAMAgAAAAhUZWVDaGFydAwDAAAADlN5c3RlbS5EcmF3aW5nBQEAAAAVU3RlZW1hLlRlZUNoYXJ0LkNoYXJ0dgAAAAYuV2lkdGgVLlBhbmVsLlNoYWRvdy5WaXNpYmxlFS5XYWxscy5SaWdodC5BdXRvSGlkZRsuV2FsbHMuUmlnaHQuU2hhZG93LlZpc2libGUULldhbGxzLkJhY2suQXV0b0hpZGUaLldhbGxzLkJhY2suU2hhZG93LlZpc2libGUWLldhbGxzLkJvdHRvbS5BdXRvSGlkZRwuV2FsbHMuQm90dG9tLlNoYWRvdy5WaXNpYmxlFC5XYWxscy5MZWZ0LkF1dG9IaWRlGi5XYWxscy5MZWZ0LlNoYWRvdy5WaXNpYmxlFi5Gb290ZXIuU2hhZG93LlZpc2libGUbLkZvb3Rlci5Gb250LlNoYWRvdy5WaXNpYmxlFi5IZWFkZXIuU2hhZG93LlZpc2libGUbLkhlYWRlci5Gb250LlNoYWRvdy5WaXNpYmxlDS5IZWFkZXIuTGluZXMZLlN1YkhlYWRlci5TaGFkb3cuVmlzaWJsZR4uU3ViSGVhZGVyLkZvbnQuU2hhZG93LlZpc2libGUbLkxlZ2VuZC5Gb250LlNoYWRvdy5WaXNpYmxlHC5MZWdlbmQuVGl0bGUuU2hhZG93LlZpc2libGUhLkxlZ2VuZC5UaXRsZS5Gb250LlNoYWRvdy5WaXNpYmxlFy5MZWdlbmQuVGl0bGUuRm9udC5Cb2xkG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sZXMuQXJyb3dIZWFkU3R5bGVzAQAAAAd2YWx1ZV9fAAgCAAAAAAAAAAX2////FFN5c3RlbS5EcmF3aW5nLkNvbG9yBAAAAAV2YWx1ZQprbm93bkNvbG9yBXN0YXRlBG5hbWUAAAABCQcHAwAAAAAAAAAAAAAAIwABAAoIAAAAAfX////2////AACZ/wAAAAAAAAIACgYMAAAABnBvaW50MQHz////9v///wAAmf8AAAAAAAACAAoBAfL////2////AAAAAAAAAACNAAEACgHx////+P///wAAAAAJEAAAAAAAAAAGEQAAAAFZBhIAAAAdU3RlZW1hLlRlZUNoYXJ0LlN0eWxlcy5Qb2ludHMJEwAAAAAAAAAB7P////n///8BAAAAAAAAAAAAAev////4////AAAAAAAAAAAB6v////f///8AAAAAAen////2////AAAAAAAAAAAjAAEACggAAAAB6P////b///8ATQD/AAAAAAAAAgAKBhkAAAAGcG9pbnQyAeb////2////AE0A/wAAAAAAAAIACgEB5f////b///8AAAAAAAAAAE8AAQAKAeT////4////AAAAAAkdAAAAAAAAAAkRAAAA6AAAAGkAAAAB4f////b///8AAAAAAAAAADQAAQAKdgAAAAAAAAAAAAAAAAAAAAAABeD///8lU3lzdGVtLkRyYXdpbmcuVGV4dC5UZXh0UmVuZGVyaW5nSGludAEAAAAHdmFsdWVfXwAIAwAAAAAAAAAB3/////b///8AAAAAAAAAAKQAAQAKAQAF3v///yZTeXN0ZW0uRHJhd2luZy5EcmF3aW5nMkQuU21vb3RoaW5nTW9kZQEAAAAHdmFsdWVfXwAIAwAAAAEAAAAGIwAAAB5TdGVlbWEuVGVlQ2hhcnQuVG9vbHMuWm9vbVRvb2wB3P////b///8AAAAAAAAAAI0AAQAKBiUAAAAA8wEAAAYmAAAAHlN0ZWVtYS5UZWVDaGFydC5Ub29scy5ab29tVG9vbAHZ////9v///wAAAAAAAAAAjQABAAoJJQAAAPMBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEEAAAAAQAAAAYpAAAACFRlZUNoYXJ0DwYAAAAAAAAABg8QAAAAAAAAAAYPEwAAAAAAAAAGDx0AAAAAAAAABgs=\"></tchart:WebChart>");

    }
For the GetChart file please read Tutorial9 - ASP.NET Applications. You'll find the tutorials at TeeChart's program group.

Displaying Tee-chart without using Session.

Posted: Wed Apr 26, 2006 5:56 am
by 9640127
Hi,
We do not want to use Session variables in our web application.
Is there any way to get the Tee-chart displayed without using Session? i.e. without using GetChart.aspx?

What about the TempChartStyle.File option? As of now i have managed to get the png files created on my custom directory by making appropriate registry changes. However these pictures do not appear on the web page. instead a red cross appears.

Please advice.

Thanks,
POP

Posted: Thu Apr 27, 2006 10:29 am
by narcis
Hi POP,

Please see my reply at your other thread.