Graph Sizing

TeeChart for ActiveX, COM and ASP
DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Graph Sizing

Post by DJ200 » Wed Dec 16, 2009 11:06 am

Hello all
I have a small problem that I can't find an answer to. Using VB6, Active Reports STD and TeeChart Pro 8

I have an Active Report that shows a series of TeeChart Pro 8 graphs that represent laboratory test. Each test graph show on the bottom axis the results obtained for analysis, and the left axis shows the number of observations. The results are obtained from a SQL Server 2005 database,and all works as expected. Please see my attachment.

The TeeCharts are drawn onto an Active Report form, and all are drawn the same size. However, when data fills the graphs, some of them shrink..as shown by the attachment that I have supplied. I don't want them to shrink.

I have set the bottom and Left axis Min, Max and Increment to Auto because I won't know in advance what the values for the X and Y axis will be.

I don't think that this is a coding problem, I think that the graph is automatically adjusting it's size to fit the increments on the Left axis..which I don't want it to do.

Thank you for your time.

Any help that you can give will be appreciated.

Regards

David
Attachments
Reagents.jpg
Reagents.jpg (188.48 KiB) Viewed 22503 times

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

Re: Graph Sizing

Post by Yeray » Thu Dec 17, 2009 11:46 am

Hi DJ200,

Have you tried to force the chart's position and size as follows?

Code: Select all

  With TChart1
    .Align = vbAlignNone
    .Left = 200
    .Top = 800
    .Height = 5000
    .Width = 8000
  End With
Is the whole Chart or the ChartRect (the rectangle defined by the axes) what is shrunk?
Could you please send us a simple example project we can run as-is to reproduce the problem here? (I suppose that with the Active Reports eval version we should be able to open a simple example project that uses it)
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Fri Dec 18, 2009 2:52 pm

Hello Yeray

Thanks for the reply

It is the ChartRect area that is shrinking, not the whole chart.

Also:

With TChart1
.Align = vbAlignNone

Errr..I don't have access to the .Align property, at least., it doesn't show up as an option when I type:

With TChart1
.Align

I will construct a small project to demonstrate this problem when I have some time..it is a huge database and I will have to play with the data to remove actual participant names etc.

Regards

David

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Fri Dec 18, 2009 3:11 pm

Sorry..I omitted to show you the graph with the panels coloured to demonstrate that it is the ChartRect that is shrinking

Regards

David
Attachments
Reagents2 Coloured panels.jpg
Reagents2 Coloured panels.jpg (141.88 KiB) Viewed 22414 times

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

Re: Graph Sizing

Post by Yeray » Mon Dec 21, 2009 9:53 am

Hi David,
DJ200 wrote:Errr..I don't have access to the .Align property, at least., it doesn't show up as an option when I type:

With TChart1
.Align
It's strange. We checked that and this property inherits from windows' TComponents class so it should be there.
DJ200 wrote:I will construct a small project to demonstrate this problem when I have some time..it is a huge database and I will have to play with the data to remove actual participant names etc.
Thanks for your time. We'll wait for it.
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Mon Dec 21, 2009 4:38 pm

Hello Yeray

No, I can't get the .Align property to show. I have checked and my TChart reference is registered..obviously otherwise I wouldn't be able to render my graphs! I have not installed the latest service pack as I would then have to re-check ALL of my reports to ensure that they are rendering correctly...see my last problem re Active Reports and strange rendering. So, I'm not sure why the .Aligh property is not showing.

I have found the problem with the "shrinking ChartRect:

My graphs show Overall Reagent values using previously calculated and stored increment steps plus individual reagents using the same previously calculated increments that make up the total Overall Reagent result within a particular increment range. These values are represented on using the Stacked bar graph. I then plot the individual participants value..(using their reagent) at the top of the appropriate Stack Bar. To get the individuals increment value, I need their result and then I have to compare it to a re-calculated increment so that the marker sits above the correct bar on the graph. I was assigning the re-calculate x-axis value onto the same graph. The figures for the previously calculated and the re-calculated values are the same, but obviously something is wrong. Either way, the x-axis values remained the same, the individual marker is in the correct place, but the graph had shrunk.

My code is as follows..original first followed by my correction:

'*Shrinking Graph code
Private Sub QPT_Graphs()

TChart3.Visible = False
TChart3.Series(0).DataSource = "" '*Clear out any old datasource
TChart3.Series(1).DataSource = "" '*Clear out any old datasource
TChart3.Series(2).DataSource = "" '*Clear out any old datasource
TChart3.Header.Text.Text = "QPT"

Set rsGeneric = Graphs.Get_Report_Variable_Graph_Data(Survey, LabID, GraphPrefix & "Graph_Data_QPT", "ReagentID", ResultPrefix & "QPTResults", "INRReagent", "Reagent")

If rsGeneric.State = adStateOpen Then
If rsGeneric.RecordCount > 0 Then
Position = Position + 1

Position_Graphs TChart3, Position '*Position the TChart

With TChart3.Series(0)
.Color = vbRed
.asBar.MultiBar = mbStacked
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(2).Name '*The Y Axis (Count)
.LabelsSource = rsGeneric.Fields(1).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

With TChart3.Series(1)
.Color = vbBlue
.asBar.MultiBar = mbStacked
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(3).Name '*The Y Axis (Total)
.LabelsSource = rsGeneric.Fields(1).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

TChart3.Header.Text.Text = "QPT (Ratio) " & rsGeneric!Reagent

'*Now fill in "Your Result"
Set rsGeneric = Nothing
Set rsGeneric = Graphs.Plot_Your_Screening_Result(Survey, LabID, GraphPrefix & "Graph_Data_QPT", ResultPrefix & "QPTResults", "Ratio")
With TChart3.Series(2)
.Color = vbGreen
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(1).Name '*The Y Axis (Total)
.LabelsSource = rsGeneric.Fields(0).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

End If
Else
TChart3.Header.Text.Text = "QPT"
End If

Set rsGeneric = Nothing

End Sub

'*Correctred Graph code
Private Sub QPT_Graphs()

TChart3.Visible = False
TChart3.Series(0).DataSource = "" '*Clear out any old datasource
TChart3.Series(1).DataSource = "" '*Clear out any old datasource
TChart3.Series(2).DataSource = "" '*Clear out any old datasource
TChart3.Header.Text.Text = "QPT"

Set rsGeneric = Graphs.Get_Report_Variable_Graph_Data(Survey, LabID, GraphPrefix & "Graph_Data_QPT", "ReagentID", ResultPrefix & "QPTResults", "INRReagent", "Reagent")

If rsGeneric.State = adStateOpen Then
If rsGeneric.RecordCount > 0 Then
Position = Position + 1

Position_Graphs TChart3, Position '*Position the TChart

With TChart3.Series(0)
.Color = vbRed
.asBar.MultiBar = mbStacked
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(2).Name '*The Y Axis (Count)
.LabelsSource = rsGeneric.Fields(1).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

With TChart3.Series(1)
.Color = vbBlue
.asBar.MultiBar = mbStacked
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(3).Name '*The Y Axis (Total)
' .LabelsSource = rsGeneric.Fields(1).Name '*The X Axis (Increment)
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

TChart3.Header.Text.Text = "QPT (Ratio) " & rsGeneric!Reagent

'*Now fill in "Your Result"
Set rsGeneric = Nothing
Set rsGeneric = Graphs.Plot_Your_Screening_Result(Survey, LabID, GraphPrefix & "Graph_Data_QPT", ResultPrefix & "QPTResults", "Ratio")
With TChart3.Series(2)
.Color = vbGreen
.DataSource = rsGeneric
.YValues.ValueSource = rsGeneric.Fields(1).Name '*The Y Axis (Total)
' .LabelsSource = rsGeneric.Fields(0).Name '*The X Axis (Increment) TAKE THIS LINE OUT AND ALL IS WELL!!
.Marks.Visible = False '*Don't show the individual values for each point
.ShowInLegend = False '*Don't show the Series title
End With

End If
Else
TChart3.Header.Text.Text = "QPT"
End If

Set rsGeneric = Nothing

End Sub


'*Overall totals and Individual Reagent Data:
Public Function Get_Report_Variable_Graph_Data(Survey As Integer, LabID As Long, strGraph_Data_Table As String, strVarIDName As String, strResultTable As String, strReagentTable As String, strVarName As String) As ADODB.Recordset
'*Get the data for this ReagentID/AssayID/Survey/Test

Dim VarID As Integer

With cnNEQAS
.Open
.CursorLocation = adUseClient

'*First get the ReagentID/AssayID/KitID for this participant/survey
strSQL = "SELECT " & strVarIDName & " " _
& "FROM " & strResultTable & " " _
& "WHERE (LabID = " & LabID & ") AND (Survey = " & Survey & ")"

Set rsGeneric = cnNEQAS.Execute(strSQL, , adCmdText)
Set rsGeneric.ActiveConnection = Nothing
strSQL = ""

If rsGeneric.RecordCount > 0 Then

VarID = rsGeneric.Fields(0)

Set rsGeneric = Nothing

SELECT TOP (100) PERCENT dbo.Graph_Data_QPT.Survey, dbo.Graph_Data_QPT.Increment, dbo.Graph_Data_QPT.Count, dbo.Graph_Data_QPT.Total,
dbo.Graph_Data_QPT.ReagentID, dbo.INRReagent.Reagent
FROM dbo.Graph_Data_QPT INNER JOIN
dbo.INRReagent ON dbo.Graph_Data_QPT.ReagentID = dbo.INRReagent.ReagentID
WHERE (dbo.Graph_Data_QPT.Survey = 179) AND (dbo.Graph_Data_QPT.ReagentID = 27)
ORDER BY dbo.Graph_Data_QPT.Increment

Set rsGeneric = cnNEQAS.Execute(strSQL, , adCmdText)
Set rsGeneric.ActiveConnection = Nothing
strSQL = ""

Set Get_Report_Variable_Graph_Data = rsGeneric

End If

VarID = 0
Set rsGeneric = Nothing

.Close
End With

End Function

'*Get the individual participants result and fit it into an increment range. Show on top of the appropriate bar graph:

Public Function Plot_Your_Screening_Result(Survey As Integer, LabID As Long, strGraphTable As String, strResultTable As String, strTest As String) As ADODB.Recordset
'*Plot the participants results onto the appropriate Screening test graph

Dim NewRS As New ADODB.Recordset 'New recordset to write results to
Dim rsIncrements As New ADODB.Recordset

Dim NewResult As Single
Dim NewTotal As Variant

Dim IncrementMinus As Single
Dim IncrementPlus As Single

Dim Result As Single '*Use this variable to hold all results irrespective of the test
Dim Step As Single

With cnNEQAS
.Open
.CursorLocation = adUseClient

NewRS.LockType = adLockOptimistic
NewRS.CursorType = adOpenKeyset

With NewRS.Fields
.Append "Increment", adSingle, 6
.Append "Total", adInteger, 4, adFldMayBeNull
End With

With NewRS
.Open
End With

'* First get the Increments for this test/survey. Use the Max function to get the Total count for each Increment Group
strSQL = "SELECT Increment, MAX(Total) AS Total " _
& "FROM " & strGraphTable & " " _
& "WHERE (Survey = " & Survey & ") " _
& "GROUP BY Increment"

Set rsIncrements = cnNEQAS.Execute(strSQL, , adCmdText)
Set rsIncrements.ActiveConnection = Nothing
strSQL = ""

rsIncrements.MoveFirst
IncrementMinus = rsIncrements!Increment
rsIncrements.MoveNext
IncrementPlus = rsIncrements!Increment

Step = IncrementPlus - IncrementMinus
Step = Step / 2 '*STEP MUST BE ROUNDED UP OR DOWN AS CUSP RESULTS WILL NOT SHOW. IAN
IncrementPlus = 0
IncrementMinus = 0

rsIncrements.MoveFirst

'*Now get the Result, and put it into the "Increment" group

strSQL = "SELECT LabID, Survey, " & strTest & " " _
& "FROM " & strResultTable & " " _
& "WHERE (LabID = " & LabID & ") And (Survey = " & Survey & ")"

Set rsGeneric = cnNEQAS.Execute(strSQL, , adCmdText)
Set rsGeneric.ActiveConnection = Nothing
strSQL = ""

If rsGeneric.RecordCount > 0 Then
If rsGeneric.Fields(2) = -1 Then '*Don't show on the graph
NewResult = 0
NewTotal = Null
Else
Result = rsGeneric.Fields(2) '*Use Result to hold all test results irrespective of the test.
End If

With rsIncrements
rsIncrements.MoveFirst
Do While Not rsIncrements.EOF
IncrementMinus = rsIncrements!Increment - Step
IncrementPlus = rsIncrements!Increment + Step

If Result >= IncrementMinus And Result < IncrementPlus Then

NewResult = rsIncrements!Increment
NewTotal = rsIncrements!Total + 10 '*(Add the plus 10 to elevate the Total for this participant above the overall Total

Else
NewResult = rsIncrements!Increment
NewTotal = Null
End If

With NewRS
.AddNew
!Increment = NewResult
!Total = NewTotal
.Update
End With

NewResult = 0
NewTotal = 0
rsIncrements.MoveNext
Loop
End With
End If

Set Plot_Your_Screening_Result = NewRS

Step = 0
NewTotal = 0
NewResult = 0
IncrementPlus = 0
IncrementMinus = 0

Set NewRS = Nothing
Set rsGeneric = Nothing

.Close
End With

End Function

Any comments?

Thank you for your time and help.

Best regards

David
Attachments
Corrected Reagent Graphs.jpg
Corrected Reagent Graphs.jpg (65.92 KiB) Viewed 22394 times

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

Re: Graph Sizing

Post by Yeray » Tue Dec 22, 2009 3:38 pm

Hi DJ200,

Thanks for the explanation, the code and the pictures. I'm afraid I haven't been able to run your code since it uses a database I can't access.
On the other hand, I'm not sure to understand if you are still suffering the problem or not. Does the "'*Correctred Graph code" section means that you've solved the problem completely? If not, please try to arrange a simple example project we can run as-is here to reproduce the problem here.
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Tue Dec 22, 2009 4:37 pm

Thank you Yeray

Yes, using the "Correct Graph Code" does correct the shrinking problem. Adding the LabelSource in the "Your Result" section produced the error (highlighted in red and bold in my code.

Still of concern is the fact that I can't get the Align property. I have checked on another computer, and I can't get the Align property there either. Was this something that was added in the latest ActiveX service pack?

VB6 SP5 plus Windows XP-Pro

Another property that I can't use is TChart5.ChartRect

If I type TChart5.ChartRect (30,40,50,60) for example, I get an error that says Expected:=
Why is that?

Thank you for your time

Regards

David

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

Re: Graph Sizing

Post by Yeray » Wed Dec 23, 2009 9:45 am

Hi DJ200,

Have you noticed this problem in another computer? I've tested it in WinXP and Win7 with VB6 SP6 (and also without any Service Pack) and I always can access to these properties.
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Wed Dec 23, 2009 12:33 pm

Hello Yeray

Yes, I have the same problem on another computer that also runs Windows XP Professional SP3 and VB6 SP5

Regards

David

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

Re: Graph Sizing

Post by Yeray » Thu Dec 24, 2009 11:32 am

Hi David,

As this hasn't been reported until now, and we aren't able to reproduce it, at this moment I can only think on that it has to be a problem related to a particular configuration. Could it be possible that those environments where you can't find that properties would have any default reference disabled in VB6? Note that here we've made the tests in VB6 with the default settings, only with TeeChart installed and present in the components toolbox.
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Thu Dec 24, 2009 12:37 pm

Hello Yeray

I can't see anything that has been disabled, and I certainly haven't disabled any default settings in VB. Perhaps you could supply a list of the references/dependencies that should be "default" in VB6 for these properties to show? Other than that, I can't see what is missing.

Thank you

Best regards

David

Later:
Hummm interesting. When I start a brand new project, I can get the .Align property to show OK, but

TChart1.ChartRect(30,40,50,60) still gives an "Expected: = error"

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

Re: Graph Sizing

Post by Yeray » Thu Dec 24, 2009 2:24 pm

Hi DJ200,

I have in Project/References active:
- Visual Basic For Applications.
- Visual Basic runtime objects and procedures
- Visual Basic objects and procedures
- OLE Automation

But if a new project doesn't reproduce the problem, this will probably be due to a missing reference in the project, more than in the IDE.

Please, try to attach here this new simple sample project that reproduces the ChartRect problem and we'll take a look at it.
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

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Tue Dec 29, 2009 7:54 am

Good morning Yeray

Here is a very small application for you to see the TChart.ChartREct problem. As you will see, all of the references that you said should be present are present in this small project.

Best wishes

David

Later: Please see next post
Last edited by DJ200 on Tue Dec 29, 2009 8:30 am, edited 1 time in total.

DJ200
Newbie
Newbie
Posts: 39
Joined: Thu Feb 28, 2008 12:00 am

Re: Graph Sizing

Post by DJ200 » Tue Dec 29, 2009 8:29 am

Hello Yeray

I think that I have found the answer!

If I type TChart1.ChartRect 20,30,40,50
instead of TChart1.ChartRect(20,30,40,50)
then all works OK.

From the help file, it is is implied that the syntax should be TChart1.ChartRect (30, 40, 50, 60)

Also, another discovery: the TChart1.Align shows on a VB6 form, but not on an Active Report (ActiveX)
I have attached a new zip for you to look at..just go to the AR and type TChart1.Align and you will see that it is not presented as an option.

Regards

David
Attachments
TChart Demo File.zip
(8.1 KiB) Downloaded 708 times

Post Reply