Page 1 of 2

Webform Calendar

Posted: Wed Aug 08, 2007 10:04 am
by 8123522
Trying to get a calendar to work on webform with the following code:-

Steema.TeeChart.Styles.Calendar cal = new Steema.TeeChart.Styles.Calendar(this.WebChart1.Chart)

Getting error:-

Object reference not set to an instance of an object.

But I can use the following to make a bar graph work:-

Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(this.WebChart1.Chart)

I am missing something, can you get a calendar to work on a webform, the demo is showing windows form.

Posted: Wed Aug 08, 2007 10:17 am
by 9348258
Hi MikeTheLad

Which TeeChart version are you using? Here It's working fine using lastest release (Build 3.2.2763.26081/2 "available at the web") and the below code:

Code: Select all

Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar(this.WebChart1.Chart); 
(WebChart1.Chart.Series[0] as Steema.TeeChart.Styles.Calendar).FillSampleValues();
Could you please try with the last version?

Posted: Wed Aug 08, 2007 1:12 pm
by 8123522
Am using Teechart v1 (Build 1.1.2531.28391

Posted: Wed Aug 08, 2007 1:20 pm
by narcis
Hi MikeTheLad,

Yes, you are right, this is a bug in v1 but works fine like this:

Code: Select all

			Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar();
			WebChart1.Chart.Series.Add(calendar1);
			WebChart1.Chart.Series[0].FillSampleValues();

Posted: Wed Aug 08, 2007 1:30 pm
by 8123522
thanks that works fine now.

What I am trying to achieve is to display a name(s) on certain days. is this going to be possible?

Posted: Wed Aug 08, 2007 2:05 pm
by narcis
Hi MikeTheLad,

You can draw text in a calendar cell using something like the code below using RectCell(Column, Row) method.

Code: Select all

  protected void Page_Load(object sender, EventArgs e)
  {			
		Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar();
		WebChart1.Chart.Series.Add(calendar1);
		calendar1.FillSampleValues();
  }

	protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
	{
		Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart[0]);
		System.Drawing.Rectangle Rect = calendar1.RectCell(2, 5);
	}

Posted: Wed Aug 08, 2007 2:14 pm
by 8123522
the WebChart1_AfterDraw function is not being called

Posted: Wed Aug 08, 2007 2:17 pm
by narcis
Hi MikeTheLad,

You need to assign the WebChart's AfterDraw event at design-time or at run-time like this:

Code: Select all

  protected void Page_Load(object sender, EventArgs e)
  {			
		Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar();
		WebChart1.Chart.Series.Add(calendar1);
		calendar1.FillSampleValues();

		//AfterDraw event definition
		WebChart1.AfterDraw+=new Steema.TeeChart.PaintChartEventHandler(WebChart1_AfterDraw);
  }

	protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
	{
		Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart[0]);
		System.Drawing.Rectangle Rect = calendar1.RectCell(2, 5);
	}

Posted: Wed Aug 08, 2007 2:21 pm
by 8123522
It is now being called, but nothing is being drawn from what I can see

Posted: Wed Aug 08, 2007 2:28 pm
by narcis
Hi MikeTheLad,

Sorry, my fault. AfterDraw event should be as shown below. Removing unnecessary code I removed more than I should.

Code: Select all

	protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
	{
		Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart[0]);
		System.Drawing.Rectangle Rect = calendar1.RectCell(2, 5);

		g.TextOut(Rect.Left, Rect.Top, "My Text");
	}

Posted: Wed Aug 08, 2007 2:43 pm
by 8123522
That works fine thanks. I presume this is not a formuale to work out where to place for each day. Is it just a matter of guessing on this.

Posted: Wed Aug 08, 2007 2:50 pm
by narcis
Hi MikeTheLad,

There are DayOneColumn and DayOneRow properties which may help you identify the cells.

Posted: Mon Aug 13, 2007 10:44 am
by 6931524
Is it possible to have a hover popup as you go over the dates

Posted: Mon Aug 13, 2007 11:17 am
by narcis
Hi MikeTheLad,

TeeChart for .NET v2 and v3 include HotSpots tool for that but I'm afraid this won't work fine with Calendar series. Anyway, I'll add your request to our wish-list to be considered for inclusion in future releases.

Posted: Thu Aug 23, 2007 9:36 am
by 8123522
Is it possible to not show the weekends?