Print Page | Close Window

xtpChartScaleDateTime with Zoom

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Chart Control
Forum Description: Topics Related to Codejock Chart Control
URL: http://forum.codejock.com/forum_posts.asp?TID=18159
Printed Date: 27 April 2024 at 11:54pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: xtpChartScaleDateTime with Zoom
Posted By: Andrew666
Subject: xtpChartScaleDateTime with Zoom
Date 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:
 



Replies:
Posted By: mimue
Date 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


Posted By: Andrew666
Date 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.


Posted By: mimue
Date 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


Posted By: Andrew666
Date Posted: 04 April 2011 at 5:20am
Interesting - I'll give that a try - thanks for taking the time to do the complete post.


Posted By: Andrew666
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net