Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set Y axis value dynamically

Status
Not open for further replies.

addsd

Programmer
Oct 12, 2001
33
0
0
US
Hi,

Have created a Grpah in Crystal Report Professional 7.0 and being called from my VB applciation using Activex Control.

I need to set Graph's Y axis values within VB program prior to execute Crpt.Action command.

Could you please help me out...

Regards,
Ahmed Jewahar
 
Do you mean the scale or the group values themselves?
Can you give an example?
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
I have a similar problem, (but with the x axis) I have a set of data whose x values I dont know until the report is run. For now I have manually set the x axis as -1500 to +1500 (I want it to be symmetrical around 0) but if a value in the future falls outside this range then it will not show

Any help who be appreciated

Andy
 
you can do it in the Section Format Event of the Report, here is a VB Code example where im resizing a BlobField Image to keep the same ratio of its original width and height to keep it from being stretched out of proportion.

Option Explicit
' ***** Modular Declarations
Private WithEvents m_rptSection As CRAXDRT.Section
' ***** End Modular Declarations

Private Sub m_rptSection_Format(ByVal pFormattingInfo As Object)
Dim rptReportObjects As CRAXDRT.ReportObjects
Dim rptBlobField As CRAXDRT.BlobFieldObject
Dim rptPicObj As CRAXDRT.OLEObject
Dim Index As Integer
Dim sngImgWidthRatio As Single
Dim sngImgHeightRatio As Single
Dim sngWidthRatio As Single
Dim sngHeightRatio As Single
Dim sngImgWidth As Single
Dim sngImgHeight As Single
Dim sngWidth As Single
Dim sngHeight As Single
Set rptReportObjects = m_rptSection.ReportObjects
For Index = 1 To rptReportObjects.Count
If rptReportObjects(Index).Kind = crBlobFieldObject Then
Set rptBlobField = rptReportObjects(Index)
' have to convert the Image from vbHimetric to vbTwips...
' so that we can get our calculations correct...
sngImgWidth = frmPicture.ScaleX(frmPicture.picImage.Picture.Width, vbHimetric, vbTwips)
sngImgHeigt = frmPicture.ScaleY(frmPicture.picImage.Picture.Height, vbHimetric, vbTwips)
sngWidth = rptBlobField.Width
sngHeight = rptBlobField.Height
' setting 2 variables here as the Ratio of how many vbTwips...
' the Width/Height has compared to the other basically...
' telling us for every Twip in Width/Height it takes this many Width/Height vbTwips to match...
sngImgWidthRatio = sngImgWidth / sngImgHeight
sngImgHeightRatio = sngImgHeight / sngImgWidth
' calculating the Image to BlobField Ratio's, same as above...
sngWidthRatio = sngWidth / sngImgWidth
sngHeightRatio = sngHeight / sngImgHeight
' checking the Ratio to see which calculation to use...
' this will stretch an image as well as shrink it...
' could rework this to not do so to a certain extent...
If sngWidthRatio < sngHeightRatio Then
rptBlobField.Width = (sngWidthRatio * sngImgWidth)
rptBlobField.Height = (sngImgHeightRatio * sngWidth)
' making sure the Horizontal and Veticle stays the same as well...
rptBlobField.Left = rptBlobField.Left + ((sngWidth - rptBlobField.Width) / 2)
rptBlobField.Top = rptBlobField.Top + ((sngHeight - rptBlobField.Height) / 2)
Else
rptBlobField.Width = (sngImgWidthRatio * sngHeight)
rptBlobField.Height = (sngHeightRatio * sngImgHeight)
' making sure the Horizontal and Veticle stays the same as well...
rptBlobField.Left = rptBlobField.Left + ((sngWidth - rptBlobField.Width) / 2)
rptBlobField.Top = rptBlobField.Top + ((sngHeight - rptBlobField.Height) / 2)
End If
End If
Next
End Sub
 
also bear in mind i was looking for that blobfield and when i found it i set the current section = to the withevent section, but if i had multiple formatting in diffrent sections i set the withevents section = nothing before i set the current section = to it
 
Hi Ken,

Thanks for your reply...

Actully I want to set the Min and Max. for Data values of Y Axis. If you click the &quot;Axis&quot; option from Chart Expert you can find the following options (2) Data Values (3) Number of Divisions etc.... Under Data values there is an option that can be setup manually or autimatic. If you cliack manually, your can define your values so Y axis will consider that values as Y axis (scale) to plot the graphs.

I forwarded the the screen where we can set up the options by emal for your kind review better reference.

Appreciate your kind help on this matter..

Regards,

Ahmed Jewahar
ajewahar@sa.dhl.com
 
I don't know if that propoerty is available at runtime. I would be surprised if the ActiveX gave that much control. The RDC is more likely to have this available - and even then it might not. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Ken,

I'm sure that property can be set at run-time !. I'll let u know once I found out th solution...

Regards,

Ahmed Jewahar
Business analyst
ajewahar@sa.dhl.com
 
yes it can be set at runtime thats why i posted some of the code for it there, and crystal doesn't exactly tell you that you can but i trialed and errored through it till i was able to do just about anything at runtime
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top