Can TChart plot chart like this

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Matthew Scott
Newbie
Newbie
Posts: 16
Joined: Tue Apr 08, 2003 4:00 am

Can TChart plot chart like this

Post by Matthew Scott » Fri Nov 06, 2009 3:41 pm

Dear All,

I have a sample chart as in the attachment with 4 series. I would like to plot them like as in the attachment and plug-in with colours like this.
Could you please advise if there is any way of doing this. I am doing C# and my TChart version is 1.1.1544.23908


I really appreciate if there is any advice or suggestions.


Regards,

LG
Attachments
samplechart.JPG
samplechart.JPG (46.31 KiB) Viewed 8193 times
Last edited by Matthew Scott on Fri Nov 06, 2009 10:28 pm, edited 1 time in total.

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

Re: Can TChart plot chart like this

Post by Narcís » Fri Nov 06, 2009 4:42 pm

Hi Leng,

Yes, this can be easily achieved using multiple Area series in your chart. You'll find similar examples at All Features\Welcome!\Chart Styles\Standard\Area in the features demo. I also recommend you to check out Tutorial 6 - Working with Series which shows how to create and use series in TeeChart and how to customize their colours. Regarding DateTime axes please read Tutorial 4 - Axis Control. Tutorials and features demo can be found at TeeChart's program group.

Hope this helps!
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

Matthew Scott
Newbie
Newbie
Posts: 16
Joined: Tue Apr 08, 2003 4:00 am

Re: Can TChart plot chart like this

Post by Matthew Scott » Fri Nov 06, 2009 11:07 pm

Thank you. I was trying that and the colour in the middle (the blue one) does not really connect to each other nicely when I use origin value. There are white spaces in between even I am trying to connect from the max of the previous series.

I want the blue area seen nicely as the middle area not just like this as in the above posted chart. Could you please advise?



Regards

LG
Attachments
test chart.png
test chart.png (42.23 KiB) Viewed 8122 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Can TChart plot chart like this

Post by Sandra » Mon Nov 09, 2009 11:12 am

Hello Leng,

I recommend that if isn't necessary use origin in your application, put area1.origin= false and use area1.MultiArea= Steema.TeeChart.Styles.MultiAreas.Stacked. Please see next simple example,try to made a similar code using your data and check if it works as you want.

Code: Select all

       private Steema.TeeChart.Styles.Area area1, area2, area3;
        private void InitializeChart()
        {
            tChart1.Dock = DockStyle.Fill;
            tChart1.Aspect.View3D = false;
            area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
            area2 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
            area3 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
            area1.FillSampleValues();
            area2.FillSampleValues();
            area3.FillSampleValues();
            area1.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
        }
If this don't works as you want, please explain exactly how are you want the chart, because we could help you. On the other hand, actually exist new versions improved of version 1, for example version of we works, version 2009 of TeeChart.Net (version 4 of TeeChart .Net).

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / 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

Matthew Scott
Newbie
Newbie
Posts: 16
Joined: Tue Apr 08, 2003 4:00 am

Re: Can TChart plot chart like this

Post by Matthew Scott » Mon Nov 09, 2009 11:50 am

Hello Sandra,


Thank you very much. I would like to have the year on X axis and Date (DD/MM) on the Y axis. I have 4 sets of data in which we can use for plotting and I would like to have the result similar to my first message post chart. I was trying the stack but it does not seem to work well. We can remove the week-out from the example chart that I have so that we can use only a single left axis.


I am trying to stack on the top of each other but it does not seem to give the same result as the chart I posted in my first message. Please find the attachment of data and let me know your advice on how that can be done.



Regards,

LG
Attachments
Date Input.zip
(4.18 KiB) Downloaded 347 times

Matthew Scott
Newbie
Newbie
Posts: 16
Joined: Tue Apr 08, 2003 4:00 am

Re: Can TChart plot chart like this

Post by Matthew Scott » Tue Nov 10, 2009 7:01 am

Dear all,

I am trying this code and the chart does not seem to stack on the top of each other very well at all. The value becomes huge on the top and we can see only one colour. It seems to have one colour only as the second series obscure the first one and based on the data they should be stacked on the top each other nicely. Please advise

Code: Select all

		private void button1_Click(object sender, System.EventArgs e)
		{
			Steema.TeeChart.Styles.Area area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
			Steema.TeeChart.Styles.Area area2 = new Steema.TeeChart.Styles.Area(tChart1.Chart);

			DateTime[] adatTR1S = new DateTime[16];
			DateTime[] adatTR1E = new DateTime[16];
			adatTR1S[0] = DateTime.Parse("13/05/2008");
			adatTR1S[1] = DateTime.Parse("11/05/2008");
			adatTR1S[2] = DateTime.Parse("14/06/2008");
			adatTR1S[3] = DateTime.Parse("14/05/2008");
			adatTR1S[4] = DateTime.Parse("16/05/2008");
			adatTR1S[5] = DateTime.Parse("13/05/2008");
			adatTR1S[6] = DateTime.Parse("26/05/2008");
			adatTR1S[7] = DateTime.Parse("28/05/2008");
			adatTR1S[8] = DateTime.Parse("11/05/2008");
			adatTR1S[9] = DateTime.Parse("18/05/2008");
			adatTR1S[10] = DateTime.Parse("19/05/2008");
			adatTR1S[11] = DateTime.Parse("17/05/2008");
			adatTR1S[12] = DateTime.Parse("13/05/2008");
			adatTR1S[13] = DateTime.Parse("23/05/2008");
			adatTR1S[14] = DateTime.Parse("19/05/2008");
			adatTR1S[15] = DateTime.Parse("23/04/2008");

			tChart1.Legend.CheckBoxes =true;
			tChart1.Aspect.View3D = false;
			area1.Title = "Start";
			area2.Title = "END";
			//area1.Transparency = 80;
			for (int intYear = 1985; intYear <= 2000; intYear++)
			{
				DateTime dat = adatTR1S[intYear - 1985];
				double dblValue = dat.ToOADate();
				area1.Add(intYear, dblValue);
				area2.Add(intYear, dblValue);
			}
			area1.YValues.DateTime = true;
			area2.YValues.DateTime = true;
			area1.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
			area2.MultiArea = Steema.TeeChart.Styles.MultiAreas.Stacked;
			area1.AreaLines.Visible = false;
			area2.AreaLines.Visible = false;
		}

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

Re: Can TChart plot chart like this

Post by Narcís » Tue Nov 10, 2009 9:24 am

Dear LG,

The problem here is that you are stacking DateTime values meaning they will sum up and therefore you'll get huge DateTime values. To see both series you should set left axis minimum value like this:

Code: Select all

			tChart1.Axes.Left.AutomaticMinimum = false;
			tChart1.Axes.Left.Minimum = DateTime.Parse("01/01/1950").ToOADate();
However, a chart stacking DateTime values doesn't make much sense to me. Could you please describe in detail which kind of data your series will have as X and Y values and how would you like them to be plotted or give us more detailed information on what the original image you sent represents and we will try to arrange an example for you?

Thanks in advance.
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

Matthew Scott
Newbie
Newbie
Posts: 16
Joined: Tue Apr 08, 2003 4:00 am

Re: Can TChart plot chart like this

Post by Matthew Scott » Tue Nov 10, 2009 10:01 am

Dear Nacis,


Thank you and now I figured out how to do it by ordering the chart as you said stacking does not really make sense at all.

Another question, I am trying to draw some dot dot line within a line series of a given period and the whole series is still solid line except a few periods only - how can we I plot this?


Regards,

LG

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can TChart plot chart like this

Post by Yeray » Wed Nov 11, 2009 4:27 pm

Hi LG,

You could do it using two series. In the following example I use the first series to show the solid pen setting some values as null points to hide them. And the second series will show the dotted pen so uses the same values with inverse null properties.

In .NET v2009, setting a point as null will hide two line segment (because we consider that a line segment is the union of two visible points). Then, to hide a line segment I set the desired null points and I add another point in the same position so that the second segment that will be hidden will have the same start and end position (so it won't appear).

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        Steema.TeeChart.Styles.Line line1, line2;

        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;

            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues(10);         
            line1.LinePen.Width = 3;
            
            line1.SetNull(3);
            line1.SetNull(5);

            int j = 0;
            while (j < line1.Count)
            {
                if (line1.IsNull(j)) line1.Add(line1.XValues[j], line1.YValues[j]);
                j++;
            }

            line2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line2.LinePen.Width = line1.LinePen.Width;
            line2.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Dot;
            line2.ShowInLegend = false;           

            for (int i = 0; i < line1.Count; i++)
            {
                if (line1.IsNull(i) || ((i < line1.Count) && (line1.IsNull(i + 1))))
                {
                    line2.Add(line1.XValues[i], line1.YValues[i], line1.Color);
                }
                else
                {
                    line2.Add(line1.XValues[i], line1.YValues[i], Color.Transparent);
                }
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply