Print Page | Close Window

Label Overlap

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Chart Control
Forum Description: Topics Related to Codejock Chart Control
URL: http://forum.codejock.com/forum_posts.asp?TID=17592
Printed Date: 21 November 2024 at 12:40pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Label Overlap
Posted By: jpbro
Subject: Label Overlap
Date Posted: 23 November 2010 at 11:21am
Are there any good ways to handle label overlap on a stacked bar chart?

Take this chart segment for example:



It would be nice if we had a way to change the z-order of a label on mouse-over or click. Is this possible now, or might it be in the future?


-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Replies:
Posted By: jpbro
Date Posted: 23 November 2010 at 11:49am
I've come up with a partial solution that hides/shows labels when you mouse over the bar point:


Private Sub ChartControl1_MouseMove(Button As Integer, Shift As Integer, x As Long, y As Long)
   Dim lt_Ht As ChartElement
   Dim lt_SeriesPt As ChartSeriesPoint
   Dim lt_SeriesPtFind As ChartSeriesPoint
   Dim lt_Series As ChartSeries
   Dim lt_Label As ChartBarSeriesLabel
  
   Set lt_Ht = UserControl.ChartControl1.HitTest(x, y)
  
   If lt_Ht Is Nothing Then
      Exit Sub
   End If
     
   If TypeOf lt_Ht Is ChartSeriesPoint Then
      Set lt_SeriesPt = lt_Ht
     
      For Each lt_Series In UserControl.ChartControl1.Content.Series
         For Each lt_SeriesPtFind In lt_Series.Points
            lt_Series.Style.Label.Visible = (lt_SeriesPt Is lt_SeriesPtFind)
         Next lt_SeriesPtFind
      Next lt_Series
   ElseIf TypeOf lt_Ht Is ChartBarSeriesLabel Then
      ' Need a way to tell if the mouse is over the point that the label is associated with
      ' Or a point to the right or left, so we can show a different label
   Else
      For Each lt_Series In UserControl.ChartControl1.Content.Series
         lt_Series.Style.Label.Visible = True
      Next lt_Series
   End If
        
End Sub


But there are some problems that maybe someone can help me with:

1) When you user moves the mouse over a label, but that label extends over another point so the mouse is actually over a different point than the label is for, I can't figure out a way to determine this.

2) Similarly, when the mouse moves over a label, I need a way to determine what point that label is associated with so I can hide the other labels. Is there anyway?

Some things that would be helpful:

1) A HitTestEx() method that returns a collection of objects in order of z-order - so if you mouse over a label, you would get a collection with: ChartBarSeriesLabel > ChartSeriesPoint, etc... that you are over. We could then loop through the collection to find the objects that we are interested in.

2) ChartObjects should have parent properties, so we can navigate easily through the object tree (For example, the ChartBarSeriesLabel and ChartSeriesPoint objects should have a Series object that gets us back up to the parent series.

Thanks for any replies.



-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net