Time axis the same for several charts
Time axis the same for several charts
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
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
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
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
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
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
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
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
Hi,
Thanks for reply. I tried this before but forgot to specify the columnWidthAuto to FALSE !!
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
Thanks for reply. I tried this before but forgot to specify the columnWidthAuto to FALSE !!
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
Have you tried to get the ColumnWidths in the OnGetLegendRect event ?
Josep Lluis Jorge
http://support.steema.com
Josep Lluis Jorge
http://support.steema.com
?? 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
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
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
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
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Not true ... try code similar to the following:9079002 wrote:Ok, it seems that it's not possible to know the legend width....
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
Christopher Ireland.