Switching Bottom Axis Between Real Time and Accumulate Time

TeeChart for ActiveX, COM and ASP
Post Reply
tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Switching Bottom Axis Between Real Time and Accumulate Time

Post by tirby » Tue Mar 17, 2015 10:28 pm

Hi,

I'm using VB6-SP6, and TeeChart Pro v2013.0.1.4.131120 32 bit ActiveX, Windows 7 Professional/SP1.

I have my code setup such that the user can switch between Accumulated time (in minutes) or Real Time.

Following are the settings for both modes.
Accumulate Mode:

Code: Select all

TChart1.axis.Bottom.Maximum = JobInfo.PlotEndTime
TChart1.axis.Bottom.Minimum = JobInfo.PlotStartTime
TChart1.axis.Bottom.Labels.ValueFormat = "#,##0.00"
Real Time Mode (12 Hour):

Code: Select all

TChart1.axis.Bottom.Maximum = JobInfo.PlotEndTime
TChart1.axis.Bottom.Minimum = JobInfo.PlotStartTime
TChart1.axis.Bottom.Labels.ValueFormat = "#0:00"
TChart1.axis.Bottom.Labels.DateTimeFormat = "h:mm"
Real Time Mode (24 Hour):

Code: Select all

TChart1.axis.Bottom.Maximum = JobInfo.PlotEndTime
TChart1.axis.Bottom.Minimum = JobInfo.PlotStartTime
TChart1.axis.Bottom.Labels.ValueFormat = "#0:00"
TChart1.axis.Bottom.Labels.DateTimeFormat = "HH:mm"
The Labels across the bottom display correctly.
Accumulated Mode: 0.00, 1.00, 2.00, etc..
Real Time 12 Hr.: 3:14 pm, 3:15 pm, 3:16 pm, etc..
Real Time 24 Hr.: 15:14, 15:15, 15:16, etc..

Using Tchart1.ShowEditor, the X Data is as follows:
Accumulated Mode: 0, 0.017, 0.033, 0.05, etc..
Real Time 12 Hr.: 12:00:00 AM, 12:24:00 AM, 12:48:00 AM, 1:12:00 AM, 1:36:00 AM ......
Real Time 24 Hr.: 12:00:00 AM, 12:24:00 AM, 12:48:00 AM, 1:12:00 AM, 1:36:00 AM ......

The Accumulated Mode displays the traces as expected (Correct X Value).
The Real Time Modes display the traces well beyond the end of the graph (Incorrect X Values).
The Y Values for all 3 modes appears to be correct.

As I toggle through each of the different modes, and examine the data with the ShowEditor, the X Values remain constant as listed above.

I do not understand how to correct the X Values for the Real Time Modes.
Can you provide an answer?

Thanks!

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

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by Yeray » Wed Mar 18, 2015 11:56 am

Hello,

You can force the bottom axis to show a label per point in the series assigned to it setting the axis Labels.Style to talPointValue.
However, I'm afraid this constant hasn't been yet defined in TeeChart ActiveX so at the moment you'll have to set its value manually:

Code: Select all

TChart1.Axis.Bottom.Labels.Style = 5
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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by tirby » Wed Mar 18, 2015 6:38 pm

Yeray,

Thanks for looking at this.

I tried the .Labels.Style setting, but this is not what I'm trying to accomplish.

I have included screen shots in an effort to describe the issue.
The screen shots are from a test program I put together to work on this issue.
If necessary, I can upload the project files.

Thanks!
Attachments
ScreenShots.Zip
(325.4 KiB) Downloaded 1289 times

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

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by Yeray » Thu Mar 19, 2015 9:43 am

Hello,

Let me put your document here for better reading:
tirby wrote:Accumulated Mode:
accu.png
accu.png (18.76 KiB) Viewed 18104 times
Bottom Axis is correct.
data1.png
data1.png (27.49 KiB) Viewed 18106 times
Note X Column Data:
Data is correct.

Real Time 12 Hr. Mode:
12h.png
12h.png (29.64 KiB) Viewed 18102 times
Bottom axis is incorrect and should read:
(Now – What-ever the current time is.)
11:55 am 11:56 am 11:57 am 11:58 am 11:59 am 12:00 pm 12:01 pm 12:02 pm 12:03 pm 12:04 pm 12:05 pm
Also, the graph is spread out to over half of the chart. Width should not have changed.
data.png
data.png (30.71 KiB) Viewed 18106 times
Note the X column data:
Should be the same as the Bottom Axis labels. Note that the times skip by 24 Minutes.

Real Time 24 Hr. Mode:
24h.png
24h.png (29.83 KiB) Viewed 18105 times
Bottom axis is incorrect in a similar manner as the 12 Hr. Mode.
The data is the same as the 12 Hr. Mode data.
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

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

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by Yeray » Thu Mar 19, 2015 10:47 am

Hello again,
tirby wrote:Bottom axis is incorrect and should read:
(Now – What-ever the current time is.)
11:55 am 11:56 am 11:57 am 11:58 am 11:59 am 12:00 pm 12:01 pm 12:02 pm 12:03 pm 12:04 pm 12:05 pm
I've made a simple example showing a result similar to yours. The code below gives me this:
12h.png
12h.png (36.5 KiB) Viewed 18096 times
Here the code to produce it:

Code: Select all

Private Sub Form_Load()
  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False

  Dim i, j As Integer
  Dim tmpStart, tmpDate As Date
  
  tmpStart = Now
  
  For i = 0 To 3
    TChart1.AddSeries scLine
    TChart1.Series(i).Pen.Width = 2
    TChart1.Series(i).XValues.DateTime = True
    
    For j = 0 To 24
      tmpDate = tmpStart + (1 / 24 / 60) * 24 * j
      TChart1.Series(i).AddXY tmpDate, Rnd * 10, "", clTeeColor
    Next j
    
    If i > 0 Then
      TChart1.Series(i).Active = False
    End If
  Next i
  
  'TChart1.Axis.Bottom.SetMinMax tmpStart, tmpStart + (1 / 24 / 60) * 10
End Sub
Note the last line is commented. If you enable it you'll see that changing the bottom axis scale makes the labels to show an increment of one minute:
12h_2.png
12h_2.png (10.31 KiB) Viewed 18096 times
tirby wrote:Also, the graph is spread out to over half of the chart. Width should not have changed.
This also depends on the axis scale. You probably set a bottom axis scale for the "Accumulated Mode" that should be changed in this "Real Time 12 Hr. Mode".
And the same will probably be happening in the "Real Time 24 Hr. Mode".
tirby wrote:If necessary, I can upload the project files.
If you still find problems with this, yes please, attach a simple example project we can run as-is to reproduce the situation here.

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

tirby
Newbie
Newbie
Posts: 84
Joined: Mon Mar 16, 2009 12:00 am

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by tirby » Thu Mar 19, 2015 7:04 pm

Thanks for your help Yeray!

Sometimes even just the simplest statements can lead to a resolution.

I was able to modify the code you provided and create a small project.
My solution was to create a UDT and populate it with managed data, then load the TChart data table from the UDT.

Now everything looks right!

Here's the test project-

Thanks!
Attachments
PlotTest1.Zip
(3.42 KiB) Downloaded 1220 times
Last edited by tirby on Tue Apr 07, 2015 1:59 pm, edited 1 time in total.

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

Re: Switching Bottom Axis Between Real Time and Accumulate Time

Post by Yeray » Fri Mar 20, 2015 8:43 am

Hello,
tirby wrote:Now everything looks right!
Great news!
That's a reason to always ask for a simple example demo. It usually helps to find little mistakes or at least a better understanding of the problem.
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