Page 1 of 1

Labels DateTimeFormat problem

Posted: Wed May 16, 2007 1:12 pm
by 9790349
Hi,

I have several series and the Axes.Bottom.Labels.DateTimeFormat is yyyy.MM.dd HH:mm:ss.

When I remove all series with Legend Checkboxes then the Bottom Axes Labels come to double.

I uploaded a sample application (WinformSample.zip).

Start the application and hide all series with clicking on the Checkboxes of the Legend.

Best regards,

Gabor Varga

P.S. This is a test application with several test functions.

Posted: Wed May 16, 2007 3:09 pm
by narcis
Hi Gabor,

Thanks for the example.

The issue you reported happens when bottom axis label style is set to value:

Code: Select all

  TChart1.Axes.Bottom.Labels.Style := Steema.TeeChart.AxisLabelStyle.Value;
I can think of 3 options to solve this:

1. Use ClickLegend event to check if there are visible series or not. If none of them are visible then make labels not visible:

Code: Select all

  TChart1.Axes.Bottom.Labels.Visible := false;
2. Use ClickLegend event as in 1 but if no series is visible set label style to automatic:

Code: Select all

  TChart1.Axes.Bottom.Labels.Style := Steema.TeeChart.AxisLabelStyle.Auto;
3. Use GetAxisLabel or GetNextAxisLabel events to convert double labels to DateTime when no series is visible.

Posted: Thu May 17, 2007 10:11 am
by 9790349
Hi,

Thanks for the quick reply.

If I would like to use GetNextAxisLabel event how can I change the text of the Label? I get the value (e.LabelValue) but I cannot change the text of the label.

When I write a GetAxisLabel event handler the GetNextAxisLabel event does not run.

I modified and uploaded the sample application. I inserted Debug.Write lines into the event handlers to show which event handler run.

Best regards,

Gabor Varga

Posted: Thu May 17, 2007 11:21 am
by narcis
Hi Gabor,

In that case you should GetAxisLabel event doing something like this:

Code: Select all

procedure TWinForm.TChart1_GetAxisLabel(sender: System.Object; e: Steema.TeeChart.GetAxisLabelEventArgs);
var tmp: DateTime;
    tmp2 : double;
begin
  if ((sender = TChart1.Axes.Bottom) and (not TChart1[0].Active) and (not TChart1[1].Active)) then
  begin
    tmp2 := Convert.ToDouble(e.LabelText);
    tmp := DateTime.FromOADate(tmp2);
    e.LabelText := Convert.ToString(tmp);
  end;
end;
If you wish to use GetNextAxisLabel event you should do something as shown here but DateTime values may only be displayed as you want when series are visible. Another option would be using custom labels and GetNextAxisLabel event.

Posted: Thu May 17, 2007 11:52 am
by 9790349
Hi,

May I ask you to explain how can I do that?
Another option would be using custom labels and GetNextAxisLabel event.
I have another question regarding this topic:

I would like to show full date and time only at minimum and maximum. In the other case i want to show only the time.

How can I do that?

For example:

+<-----------------|--------------------|--------------------|------------------>+
2007.05.17___11:00________12:00________13:00____2007.05.17
10:00:00_______________________________________13:45:00

Best regards,

Gabor Varga

P.S. The underlines are just for keeping the distance between labels.

Posted: Thu May 17, 2007 1:54 pm
by narcis
Hi Gabor,
May I ask you to explain how can I do that?

Quote:

Another option would be using custom labels and GetNextAxisLabel event.
Sorry, I meant that you could use custom labels as shown in the All Features\Welcome !\Axes\Labels\Custom labels example at the features demo. You'll find the features demo at TeeChart's program group. GetNextAxisLabel is more useful for doing some kind of processing with custom labels.
I would like to show full date and time only at minimum and maximum. In the other case i want to show only the time.

How can I do that?
You can achieve this in a very similar way to the example my colleague Christopher Ireland posted on this thread on 10th August 2006.

Posted: Thu May 17, 2007 2:23 pm
by 9790349
Hi,
You can achieve this in a very similar way to the example my colleague Christopher Ireland posted on this thread on 10th August 2006.
In this code I just see how to control where to put Label but it does not set the Label text.

I would like to have exactly the following: (same texts!)

+<-----------------|--------------------|--------------------|------------------>+
2007.05.17___11:00________12:00________13:00____2007.05.17
10:00:00_______________________________________13:45:00

Christopher sets once the DateTimeFormat:

Code: Select all

tChart1.Axes.Bottom.Labels.DateTimeFormat = "yyyy.MM.dd HH:mm:ss"; 
That's why I think the axis labels will be the following:

2007.05.17 10:00:00
2007.05.17 11:00:00 etc.

Sorry, I meant that you could use custom labels as shown in the All Features\Welcome !\Axes\Labels\Custom labels example at the features demo.

Code: Select all

      (tChart1.Axes.Left.Labels.Items.Add(123,"Hello")).Font.Size=16;
I think this is not an acceptable method if you have time series data.

I think my original problem is a bug but it seems that you don't have the same opinion. :?

I think the one acceptable method is to be able to modify LabelText from GetNextAxisLabel event handler. In this case you are able to control _where_ to put Label and _what_ to show.

All other solutions (I think) are just workaround and patchwork. :(

Is any reason why is the LabelText unaccessible from GetNextAxisLabel event handler?

Best regards,

Gabor Varga

Posted: Thu May 17, 2007 3:39 pm
by narcis
Hi Gabor,
In this code I just see how to control where to put Label but it does not set the Label text.
LabelText is created when newDate variable is created from parsing date variable.

To achieve what you request I think the easiest way is using custom labels like this:

Code: Select all

			tChart1.Axes.Bottom.Labels.Items.Clear();
			//Add first label
			tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].MinXValue(), tChart1[0].Labels[0]);

			//Add intermediate labels without time
			for (int i = 1; i < tChart1[0].Count - 1; i++)
			{
				DateTime date = DateTime.FromOADate(tChart1[0].XValues[i]);
				string dateLabel = date.Hour.ToString() + ":" + date.Minute.ToString();
				tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].XValues[i], dateLabel);
			}

			//Add last label
			tChart1.Axes.Bottom.Labels.Items.Add(tChart1[0].MaxXValue(), tChart1[0].Labels[tChart1[0].Count - 1]);
You may also be interested in checking GetNextAxisLabel and GetAxisLabel descriptions on TeeChart for .NET v2's help files.

Thanks in advance.

Posted: Tue May 29, 2007 12:31 pm
by 9790349
Hi,

Quote from TeeChart Programmers Guide / Steema.TeeChart.TChart.GetNextAxisLabel Event
An GetNextAxisLabel event is used to define custom Axis Labels. Using this event you can customize Axis Labels positions and values.
You can use the TChart.GetAxisLabel event to override the default Axis Labels text with your preferred Axis Label string representation.
So, I want to customize Axis Labels positions and values _and_ override the default Axis Labels text at the same time.

Can you show me a method how can I do that?

Best regards,

Gabor Varga

P.S. I read the help but is not clear why is impossible to use GetNextAxisLabel and GetAxisLabel event at same time.

Posted: Tue May 29, 2007 1:24 pm
by narcis
Hi Gabor,

In that case you may be interested in the suggestions made at this thread.

Please notice that it is a pretty long thread and several approaches are being discussed here so I'd suggest you to read the full thread.

Thanks in advance.