hi ,
We have a legend with check boxes and i am trying to get the index or text of series by checking any one of these check box but i have not get any result so please help us to resolve this issue.
Thanks
how to get legend index or text
-
- Newbie
- Posts: 57
- Joined: Thu Jun 02, 2011 12:00 am
Re: how to get legend index or text
Hi,
I'm not sure about what are you exactly trying to do but you may be interested on looking at the OnGetLegendText event ot the Item array as shown in the example at "All Features\Welcome !\Miscellaneous\Legend\Items property".
If you still have problems with it, please try to explain what are you exactly trying to achieve.
I'm not sure about what are you exactly trying to do but you may be interested on looking at the OnGetLegendText event ot the Item array as shown in the example at "All Features\Welcome !\Miscellaneous\Legend\Items property".
If you still have problems with it, please try to explain what are you exactly trying to achieve.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: how to get legend index or text
Hi Yeray,
Thanks for your response. Actually we have already explored this possibility. But this gives us text and index of all the legends.
Rather what we are looking forward is that, when we click on any of the check boxes of the legend, then we can find the index of that check box on which we clicked.
Or, if there is any available solution to find out from the given legend, the index of those check boxes which are checked and indexes of those which are not checked. So that on the basis of the checked state of each check box, we can perform user defined operations.
Thanks
Thanks for your response. Actually we have already explored this possibility. But this gives us text and index of all the legends.
Rather what we are looking forward is that, when we click on any of the check boxes of the legend, then we can find the index of that check box on which we clicked.
Or, if there is any available solution to find out from the given legend, the index of those check boxes which are checked and indexes of those which are not checked. So that on the basis of the checked state of each check box, we can perform user defined operations.
Thanks
Re: how to get legend index or text
Hello amol,
I'm afraid you should calculate manually the index of the clicked series in the legend. Here you'll find a discussion with some examples that will show you how to calculate the rectangles in the legend that correspond to a series:
http://www.teechart.net/support/viewtop ... 956#p37956
I'm afraid you should calculate manually the index of the clicked series in the legend. Here you'll find a discussion with some examples that will show you how to calculate the rectangles in the legend that correspond to a series:
http://www.teechart.net/support/viewtop ... 956#p37956
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: how to get legend index or text
Hi Yeray,
We are on TeeChart 7 ActiveX. Does the latest version of TeeChart ActiveX provide this functionality of detecting which legend checkbox has been clicked? That is - detecting status of each legend checkbox.
We are on TeeChart 7 ActiveX. Does the latest version of TeeChart ActiveX provide this functionality of detecting which legend checkbox has been clicked? That is - detecting status of each legend checkbox.
Re: how to get legend index or text
Hi amol,
No, but if each item in the legend corresponds to a series, and you know the relation between the series and the legend items, you can check if the corresponding series is active or not (TChart1.Series(i).Active)
No, but if each item in the legend corresponds to a series, and you know the relation between the series and the legend items, you can check if the corresponding series is active or not (TChart1.Series(i).Active)
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: how to get legend index or text
Hello Amol,
I think next code will be useful for you :
Previous code,as you see, returns the index of series aren't active. And you like know that you can use it code with last version of TeeChartActivex and Version 7. Please, can you confirm us, if previous code works as you expected?
Thanks,
I think next code will be useful for you :
Code: Select all
Private Sub Form_Load()
TChart1.Aspect.View3D = False
TChart1.AddSeries scLine
TChart1.AddSeries scLine
TChart1.AddSeries scLine
TChart1.Series(0).FillSampleValues 10
TChart1.Series(1).FillSampleValues 10
TChart1.Series(2).FillSampleValues 10
TChart1.Legend.CheckBoxes = True
End Sub
Private Sub TChart1_OnClickLegend(ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim i As Integer
Dim Index As String
For i = 0 To TChart1.SeriesCount - 1
If (Not TChart1.Series(i).Active) Then
Index = Index & " " & TChart1.Series(i).Name
End If
Next
Caption = Index
End Sub
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 57
- Joined: Thu Jun 02, 2011 12:00 am
Re: how to get legend index or text
Hi Yeray/Sandra,
Many thanks for your suggestions. We tried the Series(i).Active approach and while the solution seems logical this would require some extra effort since we are showing only some series in the legend at one time.
We got our work done using the tip provided earlier by Yeray regarding manually calculating rectangles in the legend. While almost everything is working now, we got another issue. We have to also correctly identify the check box clicked when there is more number of legends and user scrolls the legend window and then clicks on a check box. We have handled this scenario by using ScrollBar.GetPosition(). This is working fine on Win XP but strangely this is always 0 on Win 7 which fails our logic. The reason seems to be an exception coming in a core file (oledisp1.cpp) on Win 7. The code snippet that we are using is shown below:
1. void OnClickLegendTchart1(long Button, long Shift, long X, long Y)
2. {
3. int CheckBoxesSeparation = 17;
4. int CheckBoxesSize = 12;
5. int FirstItemTopLegend1 = 56;
6. int FirstItemTopLegend2 = 131;
7. int CheckBoxesMargin = 4;
8. int ValueIndex = 0;
9. bool bFound = false;
10. Y = Y+XScrollPos*CheckBoxesSeparation;
11. int countser = m_Chart1.GetSeriesCount();
12. for(int i=0;i<countser;i++)
13. {
14. if (Y > (FirstItemTopLegend1 + (ValueIndex*CheckBoxesSeparation)) &&
15. Y < (FirstItemTopLegend1 + (ValueIndex*CheckBoxesSeparation) + CheckBoxesSize))
16.
17. {
18. iCurrentWell = ValueIndex + 1;
19. m_vectBLegendChkBoxStatus[ValueIndex] = !m_vectBLegendChkBoxStatus[ValueIndex];
20. break;
21. }
22. ValueIndex++;
23. }
24. }
25.
26. void OnLegendScrollBarToolScrolledTchart1()
27. {
28. CToolList toolList = m_Chart1.GetTools();
29. CTools tools= toolList.GetItems(2);
30. CLegendScrollBarTool cLegendScrollBar = tools.GetAsLegendScrollBar();
31. XScrollPos = cLegendScrollBar.GetPosition();
32. }
Line 31 is giving problem on Win 7. Any help would be highly appreciated.
Regards
Amol
Many thanks for your suggestions. We tried the Series(i).Active approach and while the solution seems logical this would require some extra effort since we are showing only some series in the legend at one time.
We got our work done using the tip provided earlier by Yeray regarding manually calculating rectangles in the legend. While almost everything is working now, we got another issue. We have to also correctly identify the check box clicked when there is more number of legends and user scrolls the legend window and then clicks on a check box. We have handled this scenario by using ScrollBar.GetPosition(). This is working fine on Win XP but strangely this is always 0 on Win 7 which fails our logic. The reason seems to be an exception coming in a core file (oledisp1.cpp) on Win 7. The code snippet that we are using is shown below:
1. void OnClickLegendTchart1(long Button, long Shift, long X, long Y)
2. {
3. int CheckBoxesSeparation = 17;
4. int CheckBoxesSize = 12;
5. int FirstItemTopLegend1 = 56;
6. int FirstItemTopLegend2 = 131;
7. int CheckBoxesMargin = 4;
8. int ValueIndex = 0;
9. bool bFound = false;
10. Y = Y+XScrollPos*CheckBoxesSeparation;
11. int countser = m_Chart1.GetSeriesCount();
12. for(int i=0;i<countser;i++)
13. {
14. if (Y > (FirstItemTopLegend1 + (ValueIndex*CheckBoxesSeparation)) &&
15. Y < (FirstItemTopLegend1 + (ValueIndex*CheckBoxesSeparation) + CheckBoxesSize))
16.
17. {
18. iCurrentWell = ValueIndex + 1;
19. m_vectBLegendChkBoxStatus[ValueIndex] = !m_vectBLegendChkBoxStatus[ValueIndex];
20. break;
21. }
22. ValueIndex++;
23. }
24. }
25.
26. void OnLegendScrollBarToolScrolledTchart1()
27. {
28. CToolList toolList = m_Chart1.GetTools();
29. CTools tools= toolList.GetItems(2);
30. CLegendScrollBarTool cLegendScrollBar = tools.GetAsLegendScrollBar();
31. XScrollPos = cLegendScrollBar.GetPosition();
32. }
Line 31 is giving problem on Win 7. Any help would be highly appreciated.
Regards
Amol
Re: how to get legend index or text
Hello Amol,
I couldn't reproduce your problem here, using versions 7 and last version of TeeChartActivex. Please, can you send us your project, because we could reproduce your problem here?
Thanks,
I couldn't reproduce your problem here, using versions 7 and last version of TeeChartActivex. Please, can you send us your project, because we could reproduce your problem here?
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |