We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

getting a stripline to show up at startdate

I have a function that returns a chart stripline based on a startdate, and I want to put it into the horizontal date range.

    Function SetFeedChange(rDate As Date, note As String) As ChartStripLine
        Dim stripLine As ChartStripLine = New ChartStripLine()

        ''Customizing the Stripline
        stripLine.Enabled = True
        stripLine.Vertical = False
        stripLine.StartDate = rDate
        stripLine.EndDate = rDate
        stripLine.WidthDate = New TimeSpan(8, 0, 0) ' 35
        stripLine.Period = 1
        stripLine.Text = note
        stripLine.TextColor = Color.Cyan
        stripLine.TextAlignment = ContentAlignment.MiddleCenter
        stripLine.Font = New Font("Arial", 10, FontStyle.Bold)
        stripLine.Interior = New Syncfusion.Drawing.BrushInfo(230, New Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.Vertical, Color.OrangeRed, Color.DarkKhaki))

        Return stripLine
    End Function


And another function that calls the strip function:

        For Each row As DataRow In dtChartData.Select("ClientID = " & lstClients.SelectedItems.Item(0).Name)
            dt = row("DataDate")
            If setStart Then
                setStart = False
                rStart = dt
            End If
            rEnd = dt
            seriesTotalWeight.Points.Add(dt, Math.Round(row("TotalWeight"), 0))
            If Not NZ(row("ChangeNote")) = "" Then
                strip = New ChartStripLine
                strip = SetFeedChange(dt, row("ChangeNote"))
                chartTotalProduction.PrimaryXAxis.StripLines.Add(strip)
                Application.DoEvents()
            End If
        Next

        If Not rStart = rEnd Then
            chartTotalProduction.PrimaryXAxis.RangeType = ChartAxisRangeType.Set
            chartTotalProduction.PrimaryXAxis.DateTimeRange = New ChartDateTimeRange(rStart.AddDays(-1), rEnd.AddDays(1), 1, ChartDateTimeIntervalType.Days)
        End If


Sadly, no strip shows up

6 Replies

AT Anandaraj T Syncfusion Team May 5, 2014 05:15 AM UTC

Hi Andy,

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


VM Vaughn Miller May 5, 2014 02:40 PM UTC

Here's a screenshot of PrimaryXAxis.stripline(0) properties.

Hopefully this answers your question. If not let me know what else I can show you. In the mean time, I'll see if I can see whats different between yours and mine.

Attachment: stripline_662c8764.zip


VM Vaughn Miller May 5, 2014 03:02 PM UTC

Replaced my SetFeedChange function with yours, and it just worked without any other changes. I must have something wrong on mine.

It was to wide, so I then changed the width to 1 day, which did work, but now the words are a little crunched.
Does the control have the ability to rotate the words 90 degrees?
Otherwise, can I change it from visible text to just have it show up on mouse over, like how labels work?


AT Anandaraj T Syncfusion Team May 6, 2014 10:55 AM UTC

Hi Andy,

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,
Anand


VM Vaughn Miller May 7, 2014 04:06 AM UTC

The zip contains 2 files. Capture 1 shows how the stripline looks with the current data sample I'm using for testing.
Capture 2 shows what it could look like down the road when there are several months worth of data. 

I saw some stuff about different zoom levels I'm going to have to look into obviously. However, the stripline text probably isn't going to work unless it can float outside of the constraints of the stripline, at least on mouse over. Alternately, I could use your example and have the stripline text show up in a label or a message box on mouseclick. Not perfect, but better than what was available before.

Attachment: Capture1_a9685aa8.zip


AT Anandaraj T Syncfusion Team May 8, 2014 05:55 PM UTC

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,

Anand

Loader.
Live Chat Icon For mobile
Up arrow icon