How to draw non-linear custom weibull scale?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Fri Sep 04, 2009 4:09 am

Hello,

I need to plot a Weibull CDF(Cumulative Distribution) graph. Is it possible to draw a Weibull scale on t-chart? i.e custom axis scale. If yes, then please show some example on how it can be done. I don't want the graph to be drawn on a linear or log scale. I want to plot it purely on Weibull scale.

Cheers

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Fri Sep 04, 2009 8:01 am

Hello Glenn,

If you are trying to plot a scale as in Wikipedia Weibull distribution's entry image below

Image

Then you can easily achieve that either manually setting axes scales using Minimum, Maximum and Increment properties as described in tutorial 4. Tutorials are available at TeeChart's program group. If that's not enough you can manually customise and parse axes labels in the GetAxisLabel event. Examples are also available in tutorial 4.

Finally, if that doesn't fit your needs you can also use custom axis labels as shown in the All Features\Welcome!\Axes\Labels\Custom labels example at the features demo, available 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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Fri Sep 04, 2009 12:02 pm

Hello,

I want the following graph:-
Weibull.JPG
Weibull.JPG (28.34 KiB) Viewed 18631 times


The example that you show plots the CDF on linear scale. I want the scaling to be as the above graph, i.e, Weibull scale. How can this form of graph be achieved?

Thanks

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Fri Sep 04, 2009 2:24 pm

Hello,

In that case I think the best option would be:

-Left axis: using custom labels using a linear scale for the values where they are located but Weibull scale for the values of the labels, as in the example below.
-Bottom axis: Logarithmic scale as in the example.

Code: Select all

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

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

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
			line1.Pointer.Visible = true;

			tChart1.Axes.Bottom.Logarithmic = true;
			tChart1.Axes.Bottom.SetMinMax(10000, 1000000);
			tChart1.Axes.Bottom.MinorTickCount = 8;
			tChart1.Axes.Bottom.MinorGrid.Visible = true;
			tChart1.Axes.Bottom.MinorGrid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
			tChart1.Axes.Bottom.Grid.Style = System.Drawing.Drawing2D.DashStyle.Solid;
			tChart1.Axes.Bottom.Grid.Color = Color.Red;
			tChart1.Axes.Bottom.Labels.Font.Color = Color.Red;

			tChart1.Axes.Left.SetMinMax(1, 10);
			tChart1.Axes.Left.MinorTicks.Visible = false;
			tChart1.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Solid;

			for (int i = 0; i < 10; i++)
			{
				line1.Add(10000*i, i);
			}

			//add custom Weibull labels
			AddWeibullLabels(Color.Red);
		}

		private void AddWeibullLabels(Color color)
		{
			tChart1.Axes.Left.Labels.Items.Clear();
			(tChart1.Axes.Left.Labels.Items.Add(1, "10000")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(2.8, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(3.9, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(4.75, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(5.5, "50000")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(6.2, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(6.8, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(7.5, " ")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(8.5, "90000")).Font.Color = color;
			(tChart1.Axes.Left.Labels.Items.Add(10, "99000")).Font.Color = color;
		}
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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Mon Sep 07, 2009 7:03 am

Hello,

Thanks. It works.

Cheers

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Mon Sep 07, 2009 9:43 am

Hi Gleen,

You're welcome. I'm glad to hear that.

Also, an alternative solution could be using a dummy series for plotting the Weibull scale. This series should have a point for each grid line/label in the axis, axis labels should be set to text format and points in that series should be transparent.
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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Mon Sep 07, 2009 11:52 am

Hello,

We are using T-Chart version 1 for .NET. Our chosen language is Managed C++. The above approaches you suggest work for the new versions of T-Chart only. Any suggestions on how all this can be achieved in T-Chart Version 1 for .NET with managed C++?

Cheers

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Mon Sep 07, 2009 11:58 am

Hello Glenn,

I have check that this works using last TeeChart for .NET v1 release available with managed C# and I wouldn't expect any problem with managed C++. Are you having any specific problem porting the code to C++?
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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Mon Sep 07, 2009 12:40 pm

Hello,

The following line doesn't work in Managed C++ with T-Chart .NET version 1:-

(tChart1.Axes.Left.Labels.Items.Add(1, "10000")).Font.Color = color;

Labels doesn't have any member called "Items" is the error.

How do we put custom labels on the left axis?

Thanks for your quick responses.

Cheers
Last edited by Glenn F. Henriksen on Tue Sep 08, 2009 3:54 am, 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: How to draw non-linear custom weibull scale?

Post by Narcís » Mon Sep 07, 2009 1:17 pm

Hello Glenn,

Code below works fine for me here in a Visual C++ WinForms project using latest TeeChart for .NET v1 release available. Does this work fine for you?

Code: Select all

	private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {

				tChart1->Aspect->View3D = false;				 

				tChart1->Axes->Bottom->Logarithmic = true;
				tChart1->Axes->Bottom->SetMinMax(10000, 1000000);
				tChart1->Axes->Bottom->MinorTickCount = 8;
				tChart1->Axes->Bottom->MinorGrid->Visible = true;
				tChart1->Axes->Bottom->MinorGrid->Style = System::Drawing::Drawing2D::DashStyle::Solid;
				tChart1->Axes->Bottom->Grid->Style = System::Drawing::Drawing2D::DashStyle::Solid;
				tChart1->Axes->Bottom->Grid->Color = Color::Red;
				tChart1->Axes->Bottom->Labels->Font->Color = Color::Red;

				tChart1->Axes->Left->SetMinMax(1, 10);
				tChart1->Axes->Left->MinorTicks->Visible = false;
				tChart1->Axes->Left->Grid->Style = System::Drawing::Drawing2D::DashStyle::Solid;

				Steema::TeeChart::Styles::Line ^ line1 = gcnew Steema::TeeChart::Styles::Line(tChart1->Chart);
				line1->Pointer->Visible = true;

				for (int i = 0; i < 10; i++)
				{
					line1->Add(10000 * i, i);
				}			

				//add custom Weibull labels
				AddWeibullLabels(Color::Red);
			 }

	private: System::Void AddWeibullLabels(Color color) {

				tChart1->Axes->Left->Labels->Items->Clear();
				(tChart1->Axes->Left->Labels->Items->Add(1, "10000"))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(2.8, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(3.9, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(4.75, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(5.5, "50000"))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(6.2, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(6.8, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(7.5, " "))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(8.5, "90000"))->Font->Color = color;
				(tChart1->Axes->Left->Labels->Items->Add(10, "99000"))->Font->Color = color;
			 }
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

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Mon Sep 07, 2009 1:31 pm

Hello Glenn,

Also, if the kind of project I described is not the same as yours please attach a simple example project we can run "as-is" to reproduce the problem here.

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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Tue Sep 08, 2009 3:53 am

Hello,

We are using TeeChart.NET Version 1, Build 1.0.1189.31308. The language supported there is Managed C++. The example you show above is in C++/CLI. Could you please show us an example that would work with TeeChart.NET Version 1, Build 1.0.1189.31308.

Please find the sample project attached
WeibullTry.zip
(388.2 KiB) Downloaded 713 times
. It is a Visual C++, .NET WinForms project using VS 2003.

Thanks for the alacrity.

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

Re: How to draw non-linear custom weibull scale?

Post by Narcís » Tue Sep 08, 2009 7:58 am

Hi Glenn,

Thanks for the project.

First of all please notice there's a newer build of TeeChart for .NET v1 build available at the client download area.

Having said that, I couldn't open your project with VS2003 as I got this error message:
Project 'C:\temp\WeibullTry\WeibullTry.vcproj' failed to open.
Anyway, I could open it in VS2003 and with the last TeeChart or .NET v1 release available I got it working implementing AddWeibullLabels method like this:

Code: Select all

	private: void AddWeibullLabels(Color color)
      {
         tChart1->Axes->Left->Labels->Items->Clear();
         (tChart1->Axes->Left->Labels->Items->Add(1, "10000"))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(2.8, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(3.9, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(4.75, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(5.5, "50000"))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(6.2, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(6.8, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(7.5, " "))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(8.5, "90000"))->Font->Color = color;
         (tChart1->Axes->Left->Labels->Items->Add(10, "99000"))->Font->Color = color;
      }
Can you please check if this works fine for you?
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

Glenn F. Henriksen
Newbie
Newbie
Posts: 52
Joined: Tue Mar 04, 2003 5:00 am

Re: How to draw non-linear custom weibull scale?

Post by Glenn F. Henriksen » Tue Sep 08, 2009 10:48 am

Hello,

Thanks a lot for your responses. As you suggested, I downloaded and used the last build for .Net Version 1 and the code just works fine.

Cheers

Post Reply