Webform Calendar

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Aug 23, 2007 9:44 am

Hi MikeTheLad,

I'm afraid this is not possible for now. I've added your request to our wish-list to be considered for inclusion in future releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 11
Joined: Mon Jan 19, 2004 5:00 am

Post by MikeTheLad » Tue Aug 28, 2007 12:29 pm

How do I get the next / previous months button to appear as per your demo, I have

calendar1.PreviousMonthButton.Visible = true;
calendar1.NextMonthButton.Visible = true;

But does not appear,

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Aug 28, 2007 1:57 pm

Hi MikeTheLad,

This is not possible in ASP.NET applications as WebChart is rendered as an image on the client. To achieve what you request you can add two buttons on your WebForm and this code:

Code: Select all

    protected void Button1_Click(object sender, EventArgs e)
    {
        calendar1.PreviousMonth();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        calendar1.NextMonth();
    }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 11
Joined: Mon Jan 19, 2004 5:00 am

Post by MikeTheLad » Tue Aug 28, 2007 2:32 pm

Thanks, this works, but I can only goto the next month, ie September, if I then select again it does not goto October.

Also how do I find the year, to get the month I have:-


int currentmonth = calendar1.Month;


I need to know what the current month/year the calendar is currently on.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Aug 28, 2007 3:41 pm

Hi MikeTheLad,
Thanks, this works, but I can only goto the next month, ie September, if I then select again it does not goto October.


This is because PreviousMonth and NextMonth move the Calendar series onto the month before and after the present one respectively.

To achieve what you request you should use Calendar.Date.AddMonth method and save the chart as a session variable as shown here:

Code: Select all

    private MemoryStream tmpChart;

    protected void Page_Load(object sender, EventArgs e)
    {
        Steema.TeeChart.Chart ch1=WebChart1.Chart;
		tmpChart=new MemoryStream();

        if (Session["ch1"] == null)
        {
            //setup Chart
            Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar(WebChart1.Chart);
            calendar1.FillSampleValues();

            SaveChart();
        }
        else
        {
            LoadChart();
        }
    }

    private void LoadChart()
    {
        //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
        WebChart1.Chart.Import.Template.Load(tmpChart);

        Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart.Series[0]);
        calendar1.Date = calendar1.Date.AddMonths(((int)Session["months"]));
    }

    private void SaveChart()
    {
        //export Chart to a MemoryStream template
        WebChart1.Chart.Export.Template.Save(tmpChart);
        //save template to a Session variable
        Session.Add("ch1", tmpChart);

        if (Session["months"] == null)
        {
            Session.Add("months", 0);
        }
        else
        {
            Session.Add("months", tmpMonths);
        }
    }

    private int tmpMonths;

    protected void Button1_Click(object sender, EventArgs e)
    {
        Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart.Series[0]);
        tmpMonths = ((int)Session["months"]) - 1;
        calendar1.Date = calendar1.Date.AddMonths(-1);
        SaveChart();
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Steema.TeeChart.Styles.Calendar calendar1 = ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart.Series[0]);
        tmpMonths = ((int)Session["months"]) + 1;
        calendar1.Date = calendar1.Date.AddMonths(1);
        SaveChart();
    }
Also how do I find the year, to get the month I have:-


int currentmonth = calendar1.Month;


I need to know what the current month/year the calendar is currently on.
Yes, you can use this:

Code: Select all

        int currMonth = calendar1.Date.Month;
        int currYear = calendar1.Date.Year;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 11
Joined: Mon Jan 19, 2004 5:00 am

Post by MikeTheLad » Wed Aug 29, 2007 8:48 am

thanks for this, this bit more complex than expected. If I put

Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar(WebChart1.Chart);

In the page load, it will not compile as unable to resolve calendar1 further down, if I put:-

Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar();

Before the page load and comment out the one in page load it will then compile, and load the calender, but I can't goto next month as get error on the LoadChart() on the line:-

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

Is this due the having the define the calendar1 differently before the page load.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Aug 29, 2007 9:29 am

Hi MikeTheLad,

Ok, then try adding the calendar series like this:

Code: Select all

Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar(); 
WebChart1.Chart.Series.Add(calendar1);
Hopefully this will solve your problems.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 11
Joined: Mon Jan 19, 2004 5:00 am

Post by MikeTheLad » Wed Aug 29, 2007 9:39 am

Sorry, but when I add that line i get

Invalid token '(' in class, struct, or interface member declaration

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Aug 29, 2007 10:52 am

Hi MikeTheLad,

The code below builds successfully here using TeeChart for .NET v1. However it fails when loading the chart at WebChart1.Chart.Import.Template.Load(tmpChart);. Anyway, this code works fine here using TeeChart for .NET v3.

Code: Select all

	private MemoryStream tmpChart;

	protected void Page_Load(object sender, EventArgs e)
	{
		tmpChart = new MemoryStream();

		if (Session["ch1"] == null)
		{
			//setup Chart
			Steema.TeeChart.Styles.Calendar calendar1 = new Steema.TeeChart.Styles.Calendar();
			WebChart1.Chart.Series.Add(calendar1);
			calendar1.FillSampleValues();

			SaveChart(0);
		}
		else
		{
			LoadChart();
		}
	}

	private void LoadChart()
	{
		//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
		WebChart1.Chart.Import.Template.Load(tmpChart);

		Steema.TeeChart.Styles.Calendar calendar1 = GetCalendarSeries();
		calendar1.Date = calendar1.Date.AddMonths(GetMonths());
	}

	private Steema.TeeChart.Styles.Calendar GetCalendarSeries()
	{
		return ((Steema.TeeChart.Styles.Calendar)WebChart1.Chart.Series[0]);
	}

	private int GetMonths()
	{
		return (int)Session["months"];
	}

	private void SaveChart(int tmpMonths)
	{
		//export Chart to a MemoryStream template
		WebChart1.Chart.Export.Template.Save(tmpChart);
		//save template to a Session variable
		Session.Add("ch1", tmpChart);
		Session.Add("months", tmpMonths);
	}

	protected void Button1_Click(object sender, EventArgs e)
	{
		Steema.TeeChart.Styles.Calendar calendar1 = GetCalendarSeries();
		calendar1.Date = calendar1.Date.AddMonths(-1);
		SaveChart(GetMonths() - 1);
	}

	protected void Button2_Click(object sender, EventArgs e)
	{
		Steema.TeeChart.Styles.Calendar calendar1 = GetCalendarSeries();
		calendar1.Date = calendar1.Date.AddMonths(1);
		SaveChart(GetMonths() + 1);
	}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

MikeTheLad
Newbie
Newbie
Posts: 11
Joined: Mon Jan 19, 2004 5:00 am

Post by MikeTheLad » Wed Aug 29, 2007 11:03 am

thanks, I am using V1 and therefore as you said it fails on when loading the chart at:-

WebChart1.Chart.Import.Template.Load(tmpChart);.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Aug 29, 2007 11:23 am

Hi MikeTheLad,

Please notice that TeeChart for .NET v2 was released back on June 2006 and on May 2007 v3 was published as well. So it's most unlikely that this is fixed now in v1.

Also please notice that later TeeChart for .NET versions include several enhancements as far as ASP.NET applications concerns, including much more interactivity, as you can see at the live ASP.NET demo.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply