In a nine series graph, we need a legend only for 6 of 9 series, we do not need to display the other three. How can we customize this?
Best regards,
JAV
Customizing series on legend
Re: Customizing series on legend
Hello, we just found that grouping series using SeriesGroup could be a way to solve our need, but we have the following issue:
Please refer to Ejecucion1.jpg:
In this graph, the gray series belongs to the group named "PILOTO", the green line to "1", violet line to "2" and blue line to "3", but how can we assign a color to a series group?
and how can we display the color on a legend ?(but one color for each group).
Another issue: Any time that we click on the graphic to regenerate it (in the case we want another random color), the legend doesn't refresh but remains and cumulates with each click. How can the legend be refreshed and cleaned (Ejecucion4.jpg: note how after four clicks we now have the leyend four times).
Best regards,
JAV
Please refer to Ejecucion1.jpg:
In this graph, the gray series belongs to the group named "PILOTO", the green line to "1", violet line to "2" and blue line to "3", but how can we assign a color to a series group?
and how can we display the color on a legend ?(but one color for each group).
Another issue: Any time that we click on the graphic to regenerate it (in the case we want another random color), the legend doesn't refresh but remains and cumulates with each click. How can the legend be refreshed and cleaned (Ejecucion4.jpg: note how after four clicks we now have the leyend four times).
Best regards,
JAV
- Attachments
-
- Ejecucion4.jpg (Second issue)
- Ejecucion4.JPG (54.55 KiB) Viewed 11991 times
-
- Ejecucion1.jpg (First issue)
- Ejecucion1.JPG (51.33 KiB) Viewed 11976 times
Re: Customizing series on legend
Hello,
However, you can always use custom drawing techniques to draw your symbols manually. Something as follows:
If you still have problems with this, please try to arrange a simple example project we can run as-is to reproduce the problem here.
You could use the ShowInLegend property. For example:JAV wrote:In a nine series graph, we need a legend only for 6 of 9 series, we do not need to display the other three. How can we customize this?
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
Dim i As Integer
For i = 0 To 8
TChart1.AddSeries scLine
TChart1.Series(i).FillSampleValues
If i > 5 Then
TChart1.Series(i).ShowInLegend = False
End If
Next i
TChart1.Legend.Alignment = laBottom
TChart1.Legend.CheckBoxes = True
End Sub
I'm afraid it's not possible to set a series group legend symbol. Note that a series group can be formed by different series types so TeeChart can't decide what symbol to use.JAV wrote:Hello, we just found that grouping series using SeriesGroup could be a way to solve our need, but we have the following issue:
Please refer to Ejecucion1.jpg:
In this graph, the gray series belongs to the group named "PILOTO", the green line to "1", violet line to "2" and blue line to "3", but how can we assign a color to a series group?
and how can we display the color on a legend ?(but one color for each group).
However, you can always use custom drawing techniques to draw your symbols manually. Something as follows:
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.SeriesList.AddGroup "First group"
TChart1.SeriesList.AddGroup "Second group"
Dim i As Integer
For i = 0 To 8
TChart1.AddSeries scLine
TChart1.Series(i).FillSampleValues
TChart1.SeriesList.Groups.Items(i Mod 2).Add i
Next i
TChart1.Legend.Alignment = laBottom
TChart1.Legend.CheckBoxes = True
TChart1.Legend.LegendStyle = lsSeriesGroups
End Sub
Private Sub TChart1_OnAfterDraw()
Dim i As Integer
For i = 0 To TChart1.SeriesList.Groups.Count - 1
TChart1.Canvas.Pen.Color = TChart1.SeriesList.Groups.Items(i).Series.Items(0).Color
TChart1.Canvas.DrawLine TChart1.Legend.Item(i).SymbolRect.Left, TChart1.Legend.Item(i).SymbolRect.Top + 5, TChart1.Legend.Item(i).SymbolRect.Right, TChart1.Legend.Item(i).SymbolRect.Top + 5
Next i
End Sub
I suspect you are recreating the series each time the chart is clicked, without clearing the chart. That's the easier explanation for your "increasing legend" problem. However, I'm not sure if that is really the problem as I haven't seen the project, and I'm not sure either if what you would like to do is to refresh the series data or completely destroy all the series and recreate them.JAV wrote:Another issue: Any time that we click on the graphic to regenerate it (in the case we want another random color), the legend doesn't refresh but remains and cumulates with each click. How can the legend be refreshed and cleaned (Ejecucion4.jpg: note how after four clicks we now have the leyend four times).
If you still have problems with this, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Customizing series on legend
Hello Yeray:
Thanks for replying. I think your suggestion is good, but in the next line I get the error attached in the picture. What am I doing wrong?
Regarding the latter point, indeed, I am recreating the series each time the chart is clicked, i don't know how clear the chart. I'm using:
Something I'm doing wrong
It is possible to change the color of the series without regenerate the graph?
Thanks a lot!
Best regards,
JAV
Thanks for replying. I think your suggestion is good, but in the next line I get the error attached in the picture. What am I doing wrong?
Code: Select all
TChart1.Canvas.DrawLine TChart1.Legend.Item(i).SymbolRect.Left, TChart1.Legend.Item(i).SymbolRect.Top + 5, TChart1.Legend.Item(i).SymbolRect.Right, TChart1.Legend.Item(i).SymbolRect.Top + 5
Code: Select all
TChart1.RemoveAllSeries
TChart1.SeriesList.ClearValue
It is possible to change the color of the series without regenerate the graph?
Thanks a lot!
Best regards,
JAV
- Attachments
-
- error.jpg (10.89 KiB) Viewed 11916 times
Re: Customizing series on legend
Hello Yeray:
I solved the error attached in the previous message by changing the original code:
by:
Perhaps the error occurred because I'm working with version 8 and not the last one.
Please, only I need to know how clear the chart, or how to change the color of the series without regenerate the graph?
Thanks a lot!
JAV
I solved the error attached in the previous message by changing the original code:
Code: Select all
TChart1.Canvas.DrawLine TChart1.Legend.Item(i).SymbolRect.Left, TChart1.Legend.Item(i).SymbolRect.Top + 5, TChart1.Legend.Item(i).SymbolRect.Right, TChart1.Legend.Item(i).SymbolRect.Top + 5
Code: Select all
TChart1.Canvas.DrawLine TChart1.Legend.Item(i).Left - 15, TChart1.Legend.Item(i).Top + 5, TChart1.Legend.Item(i).Left - 5, TChart1.Legend.Item(i).Top + 5
Please, only I need to know how clear the chart, or how to change the color of the series without regenerate the graph?
Thanks a lot!
JAV
Re: Customizing series on legend
Hello JAV,
To change a series color:
Regarding the cleaning problem, I'm not sure to understand why do you need to remove the series. You don't need to remove all the series and recreate them to change their color.
Could you please explain your situation? Or even better, could you please arrange a simple example project we can run as-is to reproduce the situation here?
To change a series color:
Code: Select all
TChart1.Series(0).Color = vbRed
Could you please explain your situation? Or even better, could you please arrange a simple example project we can run as-is to reproduce the situation here?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Customizing series on legend
Thanks a lot for your time. It has been a great help and have solved the problems
Best regards,
JAV
Best regards,
JAV
Re: Customizing series on legend
Hi JAV,
You're welcome. I'm glad to hear that
You're welcome. I'm glad to hear that
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |