Page 1 of 1

Time axis the same for several charts

Posted: Tue Nov 18, 2003 12:35 pm
by 9079002
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

Posted: Wed Nov 19, 2003 11:43 am
by Pep
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

Posted: Wed Nov 19, 2003 2:23 pm
by 9079002
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

Posted: Wed Nov 19, 2003 3:10 pm
by Marc
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

Posted: Wed Nov 19, 2003 3:53 pm
by 9079002
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 :)

Posted: Thu Nov 20, 2003 11:17 am
by Pep
Have you tried to get the ColumnWidths in the OnGetLegendRect event ?

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

Posted: Mon Nov 24, 2003 12:55 pm
by 9079002
?? 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

Posted: Tue Nov 25, 2003 1:55 pm
by 9079002
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

Posted: Wed Nov 26, 2003 10:12 am
by Chris
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.

Posted: Wed Nov 26, 2003 12:47 pm
by 9079002
Great !!
After such a long search, it finally works ;-)

Thanks :D