Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Chart Control
  New Posts New Posts RSS Feed - xtpChartScaleDateTime with Zoom
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

xtpChartScaleDateTime with Zoom

 Post Reply Post Reply
Author
Message
Andrew666 View Drop Down
Groupie
Groupie


Joined: 15 October 2008
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andrew666 Quote  Post ReplyReply Direct Link To This Post Topic: xtpChartScaleDateTime with Zoom
    Posted: 03 April 2011 at 3:27pm
If the ArgumentScaleType = xtpChartScaleDateTime and the chart zoom is applied, dates are always displayed and never times. This means that when you zoom to less than one day in axis range, you just get the date repeated multiple times at the major tick points.  Not much use.
 
Is there a way to display time as well as date in these circumstances?  Thanks.
 
Here's a screen shot illustrating the issue:
 
Back to Top
mimue View Drop Down
Newbie
Newbie


Joined: 22 September 2008
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote mimue Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2011 at 2:54am
I have done this with a workaround. I use the CustomLabels. The sample sets the timelabels every 15 minutes.

Dim DateTimeMin As Date, DateTimeMax As Date, DateTimeAkt As Date

  DateTimeMin = [Min-DateTime of ChartSeries]
  DateTimeMax = [Max-DateTime of ChartSeries]
 
  DateTimeAkt = CDate(Int((CDbl(DateTimeMin) * 96) + 0.5) / 96)
  Diagram.AxisX.CustomLabels.Add Format(DateTimeAkt, "h:nn"), DateTimeAkt
  Do Until DateTimeAkt > DateTimeMax
     DateTimeAkt = DateTimeAkt + TimeSerial(0, 15, 0)
     Diagram.AxisX.CustomLabels.Add Format(DateTimeAkt, "h:nn"), DateTimeAkt
  Loop

Product: Xtreme SuitePro (ActiveX) version 15.0.1
Platform: Windows 7 (x64)
Language: Visual Basic 6.0
Back to Top
Andrew666 View Drop Down
Groupie
Groupie


Joined: 15 October 2008
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andrew666 Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2011 at 4:31am
Thanks for that - but it appears that every time the zoom changes I'd have to re-calculate this for the label periods to fit properly?  Looks like your solution would be fine on a fixed (no zoom allowed) axis though - thanks.
Back to Top
mimue View Drop Down
Newbie
Newbie


Joined: 22 September 2008
Location: Germany
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote mimue Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2011 at 4:58am
I use the zoom too, it works. Perhaps the rest of the code helps:

Dim DateTimeMin As Date, DateTimeMax As Date, DateTimeAkt As Date
Dim Style As New ChartLineSeriesStyle
Dim Series As ChartSeries

  If ChartControl.Content.Series.count > 0 Then
     ChartControl.Content.Series.DeleteAll
  End If
            
  Set Series = ChartControl.Content.Series.Add("")
  Series.ArgumentScaleType = xtpChartScaleDateTime
 
  Set Series = ChartControl.Content.Series.Add("")
  Series.ArgumentScaleType = xtpChartScaleDateTime
 
  'Fill Series
  DateTimeMin = [Min-DateTime of ChartSeries]
  DateTimeMax = [Max-DateTime of ChartSeries]
 
  '----> Do
  '---->    Series.Points.Add  CDate(chartArgument), chartValue
  '----> Loop
 
  'Set Style and some settings
  Set Series.Style = Style
 
  Style.Label.visible = False
  Style.Marker.Size = 5
  Style.Marker.visible = True 

  Set Diagram = ChartControl.Content.Diagrams(0)
  With Diagram
       .AllowScroll = True
       .AllowZoom = True
       With .AxisX
            With .Range
                 .AutoRange = True
                 .ViewAutoRange = True
            End With
       End With
       With .AxisY
            .AllowZoom = False
            With .Range
                 .AutoRange = True
                 .ViewAutoRange = True
            End With
       End With
  End With
 
  'CustomLabels
  DateTimeAkt = CDate(Int((CDbl(DateTimeMin) * 96) + 0.5) / 96)
  Diagram.AxisX.CustomLabels.Add Format(DateTimeAkt, "h:nn"), DateTimeAkt
  Do Until DateTimeAkt > DateTimeMax
     DateTimeAkt = DateTimeAkt + TimeSerial(0, 15, 0)
     Diagram.AxisX.CustomLabels.Add Format(DateTimeAkt, "h:nn"), DateTimeAkt
  Loop 

Product: Xtreme SuitePro (ActiveX) version 15.0.1
Platform: Windows 7 (x64)
Language: Visual Basic 6.0
Back to Top
Andrew666 View Drop Down
Groupie
Groupie


Joined: 15 October 2008
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andrew666 Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2011 at 5:20am
Interesting - I'll give that a try - thanks for taking the time to do the complete post.
Back to Top
Andrew666 View Drop Down
Groupie
Groupie


Joined: 15 October 2008
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andrew666 Quote  Post ReplyReply Direct Link To This Post Posted: 04 April 2011 at 9:30am

That appears to give me a fixed set of X-axis labels, 15 minutes apart.  This means that if the period is over a number of days I get hundreds of labels, which are increasingly removed as I zoom in, until eventually I can read them. 

Unfortunately the Chart control has no Zoom-related events, so I can't dynamically change this Ouch
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.