Time axis the same for several charts

TeeChart for ActiveX, COM and ASP
Post Reply
Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Time axis the same for several charts

Post by Ced » Tue Nov 18, 2003 12:35 pm

Hi,

I have several charts below one other. I need to fix the left axes and the rigth axis at the same position for all charts. I know how to do for the left axes (I set the margin). But I need a legend that must be displayed on the right of the chart (not on the chart).
So the legends are not the same width for all charts. How can I fix the right axis at the same position then ??

Thanks

Pep
Site Admin
Site Admin
Posts: 3301
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Nov 19, 2003 11:43 am

Hi,

you use the following trick :

Private Sub Form_Load()
With TChart1
.Aspect.View3D = False
.AddSeries scLine
.Series(0).FillSampleValues (100)
.Series(0).VerticalAxis = aBothVertAxis
End With
With TChart2
.Aspect.View3D = False
.AddSeries scLine
.Series(0).FillSampleValues (10)
.Series(0).VerticalAxis = aBothVertAxis
End With
End Sub

Private Sub Check1_Click()
If Check1.Value = 1 Then
With TChart1.Axis.Left
.Labels.Size = 40
.TitleSize = 20
End With
With TChart2.Axis.Left
.Labels.Size = 40
.TitleSize = 20
End With
With TChart1.Axis.Right
.Labels.Size = 40
.TitleSize = 20
End With
With TChart2.Axis.Right
.Labels.Size = 40
.TitleSize = 20
End With
Else
With TChart1.Axis.Left
.Labels.Size = 0
.TitleSize = 0
End With
With TChart2.Axis.Left
.Labels.Size = 0
.TitleSize = 0
End With
With TChart1.Axis.Right
.Labels.Size = 0
.TitleSize = 0
End With
With TChart2.Axis.Right
.Labels.Size = 0
.TitleSize = 0
End With
End If
End Sub

Josep Lluis Jorge
http://support.steema.com

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Wed Nov 19, 2003 2:23 pm

Hi,

Ok, I knew it when I don't have any Legend. But here I need a legend (or not, depend of the graph) and the legend must be on the side of the graph.

So, I thought I could check for the largest legend and retrieve the position of the rigth axis for this chart, then update the rigth axis from all other charts.

Any idea of how I could do this ?

Thanks

Marc
Site Admin
Site Admin
Posts: 1271
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Wed Nov 19, 2003 3:10 pm

Hello,

One option would be to fix the Legend width

eg. Combine the following with the code sent by Josep Lluis.
<pre>
With TChart1
.Legend.ColumnWidthAuto = False
.Legend.ColumnWidths(0) = 50
End With
With TChart2
.Legend.ColumnWidthAuto = False
.Legend.ColumnWidths(0) = 50
End With
</pre>

If you are not sure what Max width to set the Columns to you could step through the Points in the Charts and get the FormattedValue.

eg.
<pre>
TChart1.Legend.FormattedValue(0, 0)
</pre>

Regards,
Marc Meumann
Steema support

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Wed Nov 19, 2003 3:53 pm

Hi,

Thanks for reply. I tried this before but forgot to specify the columnWidthAuto to FALSE :oops: !!

So, now this could work but I have some troubles with GetColumnWidth ?? It returns me 0. So, if I could know the Width of the legends on all charts, my problem will be solved (I just have to update the legend width for all other charts).
I tried also posting a message that call a function in wich I retrieves the Widths (so after charts have been drawn) but it stil doesn't work.

Thanks for reply :)

Pep
Site Admin
Site Admin
Posts: 3301
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Nov 20, 2003 11:17 am

Have you tried to get the ColumnWidths in the OnGetLegendRect event ?

Josep Lluis Jorge
http://support.steema.com

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Mon Nov 24, 2003 12:55 pm

?? I don't understand ??? This event is 'called' when the user asks for the width of the legend isn't? So if I call for the width of the legend in this function this will lead to a neverending loop :?

Or perhaps, I need to supply myself a value for the legend width in this event ???

No, what I need is to let every charts draws their legend automatically, then ask to all charts the size of their legend, and finally update all the charts legends with the largest width.

Is it possible to simply know the exact size of the legend ?
Thanks for your response

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Tue Nov 25, 2003 1:55 pm

Ok, it seems that it's not possible to know the legend width.... :(

So, another solution can be to specify the same legend width for all charts (an arbitrary size). But now the problem is that if the text is larger than the legend, it is not clipped inside !!! The text goes outside the legend and this is very ugly !! Is there a way to clip the text inside the legend ??

I really need to have legends on the charts and I really need also to have the time axis the same (it's not just to make it look great...).

Thanks

Christopher
Site Admin
Site Admin
Posts: 1349
Joined: Thu Jan 01, 1970 12:00 am
Location: Riudellots de la Selva, Catalonia
Contact:

Post by Christopher » Wed Nov 26, 2003 10:12 am

9079002 wrote:Ok, it seems that it's not possible to know the legend width.... :(
Not true :D ... try code similar to the following:

Code: Select all

Private Sub Form_Load()
With TChart1
    .AddSeries scBar
    .Series(0).FillSampleValues 20
    
    .Environment.InternalRepaint
    Label1.Caption = "LEGEND WIDTH = " & .Legend.ShapeBounds.Right - .Legend.ShapeBounds.Left
End With
End Sub
Best regards,

Christopher Ireland.

Ced
Newbie
Newbie
Posts: 25
Joined: Fri Nov 15, 2002 12:00 am

Post by Ced » Wed Nov 26, 2003 12:47 pm

Great !!
After such a long search, it finally works ;-)

Thanks :D

Post Reply