getting a stripline to show up at startdate
Thanks for using Syncfusion products.
We have created a simple sample using the code snippet provided by you but the reported issue is not reproduced. The sample can be downloaded from the following link.
DateTimeAxisVB.zip
We would like to know the following details, so that we can analyze further and provide a solution.
1. Would you please let us know whether the strip line is added to primary X axis strip line collection by debugging it?
2. Would you please let us know the values of properties "Start" and "End" of primary X axis range and "StartDate", "EndDate", "WidthDate" and "Period" properties of strip line?
The information provided would be of great help in providing a solution.
Please let us know if you have any concern.
Regards,
Anand
Attachment: stripline_662c8764.zip
Thanks for the update.
Query #1: Does the control have the ability to rotate the word 90 degrees?
Currently, support for rotating stripline text is not available. We can position text anywhere in the strip line using "TextAlignment" property either horizontally or vertically using "Vertical" property of strip line. Also text will be wrapped automatically, if displayed horizontally for a stripline in primary X axis because this is the default behavior.
Please refer the following code snippet to achieve this.
<code>
[VB]
'using content alignment to position text in strip line
stripLine.TextAlignment = ContentAlignment.MiddleRight
</code>
Query #2: can I change it from visible text to just have it show up on mouse hover, like how labels work?
We can use "ChartRegionMouseMove" event of chart control to hide or show text based on mouse hovering in stripline.
Please refer the following code snippet to achieve this.
<code>
[VB]
Private Sub chartControl1_ChartRegionMouseEnter(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Chart.ChartRegionMouseEventArgs) Handles ChartControl1.ChartRegionMouseHover
Dim startPoint As New Point
Dim endPoint As New Point
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).Text = "Stripline text"
Else
ChartControl1.PrimaryXAxis.StripLines(0).Text = ""
End If
ChartControl1.Refresh()
End Sub
</code>
We have also modified our sample in our previous update and it can be downloaded from the following link.
DateTimeAxis_VB_2
Could you please provide a screenshot of the description your exact requirement so that we can understand how stripline text should be placed? The information provided would be of great help in providing a solution.
Please let us know if you have any concern.
Regards,
Attachment: Capture1_a9685aa8.zip
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,
- 6 Replies
- 2 Participants
-
VM Vaughn Miller
- May 3, 2014 11:27 AM UTC
- May 8, 2014 05:55 PM UTC