BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Andy,
Thanks for providing the information.
When data is increased in chart, stripline width will not increase because start and end range for strip line remains the same. This will also affect the appearance of stripline text because this is the default behavior. As a workaround solution for displaying stripline text on mouse hover, we can use the graphics object of chart control to draw the text on chart when mouse is hovered over stripline.
Please refer the following code snippet to achieve this.
<code>
[VB]
'Event for chart region mouse move
Private Sub chartControl1_ChartRegionMouseEnter(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventArgs) Handles ChartControl1.ChartRegionMouseHover
currentPoint = e.Point
Dim startPoint As New Point
Dim endPoint As New Point
Dim gr = ChartControl1.GetGraphics()
Dim text As New String("Replace mollasses with corn")
Dim textFont = ChartControl1.PrimaryXAxis.StripLines(0).Font
startPoint = ChartControl1.ChartArea.GetPointByValue(New ChartPoint(ChartControl1.PrimaryXAxis.StripLines(0).Start, 0))
endPoint = ChartControl1.ChartArea.GetPointByValue(New ChartPoint(ChartControl1.PrimaryXAxis.StripLines(0).End, 0))
If e.Point.X > startPoint.X AndAlso e.Point.X < endPoint.X Then
ChartControl1.PrimaryXAxis.StripLines(0).ZOrder = ChartStripLineZorder.Over
If Math.Abs(currentPoint.X - previousPoint.X) < 5 AndAlso Math.Abs(currentPoint.Y - previousPoint.Y) < 5 Then
ChartControl1.Refresh()
'Drawing strip line text on mouse hover
DrawStripLineText(gr, text, textFont, e.Point)
Else
previousPoint = currentPoint
redraw = True
End If
Else
If redraw Then
ChartControl1.Refresh()
redraw = False
End If
ChartControl1.PrimaryXAxis.StripLines(0).ZOrder = ChartStripLineZorder.Behind
End If
End Sub
'Method for drawing text on mouse hover
Private Sub DrawStripLineText(gr As Graphics, text As String, textFont As Drawing.Font, point As Point)
Dim textSize = gr.MeasureString(text, textFont, point, StringFormat.GenericDefault)
Dim rect = New Rectangle(point.X, point.Y, textSize.Width + 20, textSize.Height + 20)
gr.FillRectangle(Brushes.AntiqueWhite, rect)
gr.DrawString(text, textFont, Brushes.Black, point.X + 10, point.Y + 10)
End Sub
</code>
For your convenience, we have modified our sample in our previous update to draw text on mouse hover. The sample can be downloaded from the following link.
http://www.syncfusion.com/downloads/support/directtrac/124642/DateTimeAxisVB_(2)-1379455729.zip
Please let us know if you have any concern.
Regards,