|
||||||||
You can also use this XYChart4_3.dep dependency file with your installation. Note for Windows XP SP2: If you are having problems registering ActiveX controls on Windows XP SP2, this is usually caused by the new security restrictions introduced in SP2. The solution is to log in as administrator and add regsvr32.exe (and possibly the ActiveX control being registered) to the Data Execution Prevention exception list (DEP OptOut list). Refer to Microsoft article http://support.microsoft.com/kb/875352 for more details.
|
|||||||||||||||||||||||||||||||||||||||||||||
| Format String | Result |
| h:mm:ss | 9:40:00 |
| hh:mm:ss.fff | 09:40:00.056 |
| hh:mm:ss AMPM | 09:40:00 AM |
| m/d/yy | 2/28/04 |
| dd-mmm-yyyy | 28-Feb-2004 |
| mmmm dd, yyyy hh:mm:ss AMPM | February 28, 2004 09:40:00 AM |
' The X scale formatting
can also be set programitically as per the following:
With XYChart
.XScale(1).FormatStyle = fsDateTime
.XScale(1).DateTimeFormat = "dd-mmm-yyyy
hh:mm:ss AMPM" ' X
value = 38045.40279 will display 28-Feb-2004 09:40:00 AM
End With
Print functionality is built into XY Chart ActiveX. The chart image is scaled to fit the printable area based on the paper size and the PrinterSettings properties - left, top, right and bottom margins and orientation (portrait or landscape). The aspect ratio (height-to-width) is maintained. The print dialog appears if PrintSettings.ShowDialog = True.
With XYChartCtrl
.PrintSettings.LeftMargin = 1 '
1 inch left margin
.PrintSettings.TopMargin = 1 '
1 inch top margin
.PrintSettings.RightMargin = 1 '
1 inch right margin
.PrintSettings.BottomMargin = 1
' 1 inch bottom margin
.PrintSettings.Orientation = poLandscape
' Landscape orientation
.PrintSettings.ShowDialog = True '
Print dialog will be displayed when the PrintChart method is called
or the Print toolbar button is selected
.PrintChart
End With
Dragging the scales directly is only permitted when the scale is zoomed in and the corresponding scrollbar visible property is false. I.e. If the horizontal scrollbar is not visible, then X Scale dragging is permitted. Likewise, if the vertical scrollbar is not visible, then Y Scale dragging is permitted. Copy this hand icon file into the same directory as your application and use the following code for the PlotMouseMove, YScaleMouseMove and XScaleMouseMove events.
' Y Scales
Private Sub XYChart4Ctl1_YScaleMouseMove(Button As Integer, Index
As Integer, xPos As Single, yPos As Single)
With XYChart4Ctl1
If Not .ScrollBars.VerticalVisible
And (.MinYValue(Index) > .AbsMinYValue(Index) Or .MaxYValue(Index)
< .AbsMaxYValue(Index)) Then
Dim
dScaleMargin As Double
Dim
YStack As Integer
dScaleMargin
= 20
YStack
= GetYStackGivenYScale(Index)
If
xPos < .YStack(YStack).Left - dScaleMargin And yPos > .YStack(YStack).Top
+ dScaleMargin And _
yPos < (.YStack(YStack).Top + .YStack(YStack).Height - dScaleMargin)
Then
If
Me.MousePointer <> vbCustom Then
Me.MousePointer
= vbCustom
If
Button <> vbLeftButton Then
Me.MouseIcon
= LoadPicture(App.Path + "\Hand.ico")
End
If
End
If
Else
If
Me.MousePointer <> vbDefault Then Me.MousePointer = vbDefault
End
If
Else
If
Me.MousePointer <> vbDefault Then Me.MousePointer = vbDefault
End If
End With
End Sub
' X Scales
Private Sub XYChart4Ctl1_XScaleMouseMove(Button As Integer, Index
As Integer, xPos As Single, yPos As Single)
With XYChart4Ctl1
If Not .ScrollBars.HorizontalVisible
And (.MinXValue(Index) > .AbsMinXValue(Index) Or .MaxXValue(Index)
< .AbsMaxXValue(Index)) Then
Dim
dScaleMargin As Double
dScaleMargin
= 20
If
xPos > (.YStack(1).Left + dScaleMargin) And xPos < (.YStack(1).Left
+ .YStack(1).Width) And _
yPos > (.YStack(Index).Top + .YStack(Index).Height + dScaleMargin)
Then
If
Me.MousePointer <> vbCustom Then
Me.MousePointer
= vbCustom
If
Button <> vbLeftButton Then
Me.MouseIcon
= LoadPicture(App.Path + "\Hand.ico")
End
If
End
If
Else
If
Me.MousePointer <> vbDefault Then Me.MousePointer = vbDefault
End
If
Else
If
Me.MousePointer <> vbDefault Then Me.MousePointer = vbDefault
End If
End With
End Sub
' Get YStack Given YScale
Private Function GetYStackGivenYScale(YScale As Integer) As Integer
Dim YStack As Integer
Dim YScaleCount As Integer
With XYChart4Ctl1
If .YStacking =
True Then
For
YStack = 1 To .NumYStacks
YScaleCount
= YScaleCount + .YStack(YStack).NumYScales
If
YScaleCount >= YScale Then
GetYStackGivenYScale
= YStack
Exit
For
End
If
Next
YStack
Else
GetYStackGivenYScale
= 1
End If
End With
End Function
' Reset mouse pan icon
to default
Private Sub XYChart4Ctl1_PlotMouseMove(Button As Integer, Index
As Integer, xPos As Single, yPos As Single)
Me.MousePointer = vbDefault
End Sub
The code shown below is for the PlotMouseMove event. It applies equally to the PlotMouseDown and PlotMouseUp events. It will calculate the X and Y values for any axis, and accounting for a linear or log scale.
Worth noting that YStack(YScale) gives the position and dimensions of the corresponding plot area. If YStacking = False, then there is only one plot area.
Private Sub XYChart4Ctl1_PlotMouseMove(Button
As Integer, Index As Integer, xPos As Single, yPos As Single)
With XYChart4Ctl1
Const YScaleRM As
Integer = 1 ' Right most Y scale (must be
1 to determine X values)
Dim YScale As Integer,
XScale As Integer, YScaleStack As Integer
Dim dXValue As Double,
dYValue As Double
XScale = 1 '
Change this value to any available XScale
If .YStacking Then
YScale
= Index ' Uses Index to determine the appropriate
YScale
YScaleStack
= YScale
Else
YScale
= 1 ' Change this value to any available YScale
YScaleStack
= 1 ' Only 1 plot area when YStacking = False
End If
'
Determine X & Y values
If .XScale(XScale).ScaleType
= stLinear Then
'
Linear X Scale
dXValue
= (xPos + Screen.TwipsPerPixelX - .YStack(YScaleRM).Left) / .YStack(YScaleRM).Width
* _
(.MaxXValue(XScale) - .MinXValue(XScale)) + .MinXValue(XScale)
Else
'
Log X Scale
dXValue
= 10 ^ ((xPos + Screen.TwipsPerPixelX - .YStack(YScaleRM).Left)
/ .YStack(YScaleRM).Width * _
(Log(.MaxXValue(XScale)) / Log(10) - Log(.MinXValue(XScale)) / Log(10))
+ Log(.MinXValue(XScale)) / Log(10))
End If
If .YScale(YScale).ScaleType
= stLinear Then
'
Linear Y Scale
dYValue
= .MaxYValue(YScale) - (yPos - .YStack(YScaleStack).Top) / .YStack(YScaleStack).Height
* _
(.MaxYValue(YScale) - .MinYValue(YScale))
Else
'
Log Y Scale
dYValue
= 10 ^ (Log(.MaxYValue(YScale)) / Log(10) - (yPos - .YStack(YScaleStack).Top)
/ .YStack(YScaleStack).Height * _
(Log(.MaxYValue(YScale)) / Log(10) - Log(.MinYValue(YScale)) / Log(10)))
End If
End With
End Sub
This is usually caused by the new security restrictions introduced in SP2. The solution is to log in as administrator and add regsvr32.exe (and possibly the ActiveX control being registered) to the Data Execution Prevention exception list (DEP OptOut list). Refer to Microsoft article http://support.microsoft.com/kb/875352 for more details.
Although XYChart is not officially supported for Windows NT, several developers have successfully implemented projects with XYChart in Windows NT, specifically with Windows NT 4.0 and SP5 or SP6.
The only issue that causes them problems is when they first start a project and attempt to place an XYChart on a form. An error occurs with the "Message: error accessing the system registry". This is resolved by referencing "OLE Automation" as shown below.
Swap X and Y scales by calling this routine:
Private Sub SwapScales()
' Function applies
to charts with 1 X Scale and 1 x Y Scale only
Dim arrXData As Variant
Dim arrYData As Variant
Dim XLabel As String
Dim YLabel As String
Dim ProfileNum As Integer
With XYChart4Ctl1
For ProfileNum =
1 To .NumProfiles
'
Profile Data
arrXData
= .ProfileXData(ProfileNum)
arrYData
= .ProfileYData(ProfileNum)
.ProfileXData(ProfileNum)
= arrYData
.ProfileYData(ProfileNum)
= arrXData
Next ProfileNum
'
Scale Labels
XLabel = .XScale(1).Label
YLabel = .YScale(1).Label
.XScale(1).Label
= YLabel
.YScale(1).Label
= XLabel
.Refresh
End With
End Sub
Yes. Each Y Scale can be made visible or hidden independent of the profiles mapped to it. The toolbar can also be hidden. This is usually done to save space, allowing the plot area to be larger. All scaling functions continue to work as though the Y Scale is displayed. See sample images below.
Y Scales Visible

Y Scales & Toolbar Hidden

This is a common problem experienced by XY Chart ActiveX users with Excel VBA. The typical sequence of events goes likes this... The Excel VBA application is first tested and/or developed using the XY Chart ActiveX Trial version. Then the XY Chart ActiveX Full version is purchased and installed, and the next time the Excel VBA application is opened, VBA displays the "cannot insert object" error. This is caused by the remanence of the Trial version control in the ..\Application Data\Microsoft\Forms folder.
To reset the XY Chart ActiveX settings for Excel VBA, follow the 3 steps in the image below. And if you cannot find XYChart4_4.exd, perform a file search for XYChart4_4.exd, and make sure to allow the search for system folders, hidden files and folders, etc.
