Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Chart Control
  New Posts New Posts RSS Feed - Label Overlap
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Label Overlap

 Post Reply Post Reply
Author
Message
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Topic: Label Overlap
    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

Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.