Set axis labels in 10th power.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Set axis labels in 10th power.

Post by Amol » Tue Sep 25, 2018 1:20 pm

Hi Steema,

We are facing one problem that is when we set axis labels in 10th power then labels values are not showing correct.

We have created plot in which we have set bottom axis Logarithmic. The minimum and maximum value of bottom axis are 0.1 and 100 respectively.

Case1

When we set label format in exponential then labels of bottom axis shown in below figure:

tChart1.Axes.Bottom.Labels.ValueFormat = " 0.####E+0";
case1.jpg
case1.jpg (85.33 KiB) Viewed 11711 times


Case2

When we want to show the bottom axis labels in 10th power.

for this we have set following properties

tChart1.Axes.Bottom.Labels.Exponent = true;
tChart1.Axes.Bottom.Labels.ValueFormat = "00e0";
case2.jpg
case2.jpg (87.28 KiB) Viewed 11711 times
But here in above figure, the labels of bottom axis are not showing correct values label.

Currently it is showing following labels: 10¯², 10¯¹, 10⁰, 10¹.

But the correct labels value should be: 10¯¹, 10⁰, 10¹, 10².

So we can see here the deference of multiply of 10 in all labels value.

Case3

Now we changed value format:
tChart1.Axes.Bottom.Labels.Exponent = true;
tChart1.Axes.Bottom.Labels.ValueFormat = "# "x10" E+0”;

then values are showing correct as shown in below figure:
case3.jpg
case3.jpg (86.98 KiB) Viewed 11711 times
But here we want to show labels in 10th power like case2.
So kindly assist us to give the solution.

Thanks & regards
PlanoResearch

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Set axis labels in 10th power.

Post by Amol » Tue Sep 25, 2018 1:24 pm

Hi Steema,

we have also attached a demo for your reference.

Thanks & regards
PlanoResearch
Attachments
Demo.rar
(73.35 KiB) Downloaded 814 times

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: Set axis labels in 10th power.

Post by Amol » Tue Oct 16, 2018 12:42 pm

Hi Steama,

We have posted one issue regarding the axis labels and we will still waiting for your response.
So kindly provide the any solution regarding this.

Thanks & regards
PlanoResearch

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Set axis labels in 10th power.

Post by Christopher » Wed Oct 17, 2018 7:52 am

Hello Amol,

When I run this code using the latest public version of TeeChart.dll (available here):

Code: Select all

		public Form1()
		{
			InitializeComponent();
			//FillData();
			FillSeriesData();
			this.Controls.Add(tChart1);
			tChart1.Dock = DockStyle.Fill;
			tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.Points line1 = new Points();
			line1.ShowInLegend = false;
			line1.VertAxis = VerticalAxis.Left;
			line1.LinePen.Width = 2;
			//line1.Smoothed = true;
			line1.Add(lstX.ToArray(), lstY.ToArray());

			string format = "00e0";

			List<string> strings = lstX.Select(x => x.ToString(format)).ToList();

			strings.ForEach(x => Console.WriteLine(x));

			tChart1.Series.Add(line1);

			//tChart1.Axes.Bottom.Logarithmic = true;
			tChart1.Axes.Bottom.Labels.Exponent = true;
			tChart1.Axes.Bottom.Labels.ValueFormat = format;

			tChart1.MouseDoubleClick += TChart1_MouseDoubleClick;
		}
I obtain the following:
devenv_2018-10-17_09-11-11.png
devenv_2018-10-17_09-11-11.png (35.55 KiB) Viewed 11673 times
This chart is correct, as you can see - the strings we write out in Console.WriteLine using code which is independent of TeeChart match exactly the strings TeeChart writes out in the bottom axis.

Now when we use this code:

Code: Select all

	public Form1()
		{
			InitializeComponent();
			//FillData();
			FillSeriesData();
			this.Controls.Add(tChart1);
			tChart1.Dock = DockStyle.Fill;
			tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.Points line1 = new Points();
			line1.ShowInLegend = false;
			line1.VertAxis = VerticalAxis.Left;
			line1.LinePen.Width = 2;
			//line1.Smoothed = true;
			line1.Add(lstX.ToArray(), lstY.ToArray());

			string format = "00e0";

			List<string> strings = lstX.Select(x => x.ToString(format)).ToList();

			strings.ForEach(x => Console.WriteLine(x));

			tChart1.Series.Add(line1);

			tChart1.Axes.Bottom.Logarithmic = true;
			tChart1.Axes.Bottom.Labels.Exponent = true;
			tChart1.Axes.Bottom.Labels.ValueFormat = format;

			tChart1.MouseDoubleClick += TChart1_MouseDoubleClick;
		}
I obtain the following:
devenv_2018-10-17_09-12-27.png
devenv_2018-10-17_09-12-27.png (35.87 KiB) Viewed 11673 times
This chart is also correct - it has to be correct, because the previous chart was correct, which is to say that the label '10⁰' is correctly positioned.

I think confusion is occuring because TChart does not display the logarithmic value of the points on the labels - it displays their actual values but plots the values as logarithmic. Here's some code that explains what I mean:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			//FillData();
			FillSeriesData();
			FillXData();
			this.Controls.Add(tChart1);
			tChart1.Dock = DockStyle.Fill;
			tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.Points line1 = new Points();
			line1.ShowInLegend = false;
			line1.VertAxis = VerticalAxis.Left;
			line1.LinePen.Width = 2;
			//line1.Smoothed = true;
			line1.Add(lstX.ToArray(), lstY.ToArray());

			string format = "00e+0";

			List<string> strings = lstX.Select(x => x.ToString(format)).ToList();

			strings.ForEach(x => Console.WriteLine(x));

			tChart1.Series.Add(line1);

			//tChart1.Axes.Bottom.Logarithmic = true;
			//tChart1.Axes.Bottom.LogarithmicBase = 10;
			//tChart1.Axes.Bottom.Labels.Exponent = true;
			tChart1.Axes.Bottom.Labels.ValueFormat = format;

			tChart1.MouseDoubleClick += TChart1_MouseDoubleClick;
		}

		private void FillXData()
		{
			lstX.Clear();

			double ten = 1;

			for (int i = 0; i < 17; i++)
			{
				ten *= 10;
				lstX.Add(ten);
			}
		}
and the result:
devenv_2018-10-17_09-46-08.png
devenv_2018-10-17_09-46-08.png (37.04 KiB) Viewed 11673 times
I think we can agree this is correct. Now if we use logarithmic both on the xvalue strings and on the bottom axis:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			//FillData();
			FillSeriesData();
			FillXData();
			this.Controls.Add(tChart1);
			tChart1.Dock = DockStyle.Fill;
			tChart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
			tChart1.Aspect.View3D = false;
			Steema.TeeChart.Styles.Points line1 = new Points();
			line1.ShowInLegend = false;
			line1.VertAxis = VerticalAxis.Left;
			line1.LinePen.Width = 2;
			//line1.Smoothed = true;
			line1.Add(lstX.ToArray(), lstY.ToArray());

			string format = "00e+0";

			List<string> strings = lstX.Select(x => Math.Log10(x).ToString(format)).ToList();

			strings.ForEach(x => Console.WriteLine(x));

			tChart1.Series.Add(line1);

			tChart1.Axes.Bottom.Logarithmic = true;
			tChart1.Axes.Bottom.LogarithmicBase = 10;
			tChart1.Axes.Bottom.Labels.Exponent = true;
			tChart1.Axes.Bottom.Labels.ValueFormat = format;

			tChart1.MouseDoubleClick += TChart1_MouseDoubleClick;
		}

		private void FillXData()
		{
			lstX.Clear();

			double ten = 1;

			for (int i = 0; i < 17; i++)
			{
				ten *= 10;
				lstX.Add(ten);
			}
		}
we obtain:
devenv_2018-10-17_09-50-23.png
devenv_2018-10-17_09-50-23.png (37.06 KiB) Viewed 11673 times
Here we can see that the chart plots the xvalues as logarithmic values, the values you can see in Console.WriteLine, but the labels are still the actual (non-logarithmic) value of each point.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply