This is a migrated thread and some comments may be shown as answers.

ChartTrackballController

2 Answers 39 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jan Skovhus
Top achievements
Rank 1
Jan Skovhus asked on 11 Dec 2014, 04:49 PM
How can I Show Trackball for each series?

For i = 0 To Me.RadListView1.Items.Count - 1
                If RadListView1.Items(i).CheckState = Telerik.WinControls.Enumerations.ToggleState.On Then
                   Dim lii As Integer = RadListView1.Items(i).Value
                    Dim liText As String = RadListView1.Items(i).Text
                    ''SingleHistory = MeasureWS.SingleHistory(lii.ToString, TextBoxStart.Text, TextBoxEnd.Text, "120")
                    SingleHistory = MeasureWS.SingleHistory(lii.ToString, "", TextBoxStart.Text, TextBoxEnd.Text, "120")

                    Dim LineSeriesY As New LineSeries()
                    LineSeriesY.LegendTitle = liText
                    'LineSeriesY.Name = liText
                    Dim LineSeriesX As New LinearAxis()
                    LineSeriesX.HorizontalLocation = AxisHorizontalLocation.Left
                    LineSeriesX.AxisType = AxisType.Second
                    'LineSeriesX.Title = ""
                    LineSeriesY.VerticalAxis = LineSeriesX
                    LineSeriesY.HorizontalAxis = horizontalAxis
                    RadChartView1.Series.Add(LineSeriesY)

                    LineSeriesY.CategoryMember = "DateTime"
                    LineSeriesY.ValueMember = "PV"

                    LineSeriesY.DataSource = SingleHistory
                    'Form2.DataGridView1.DataSource = SingleHistory

                    Dim controler As New ChartTrackballController()
                    AddHandler controler.TextNeeded, AddressOf controler_TextNeeded
                    RadChartView1.Controllers.Add(controler)


                End If
            Next


Private Sub controler_TextNeeded(sender As Object, e As TextNeededEventArgs)
        Dim dataPoint As CategoricalDataPoint = TryCast(e.Points(0).DataPoint, CategoricalDataPoint)
        e.Text = String.Format("{0} : {1}", dataPoint.Category, dataPoint.Value)
End Sub

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Dec 2014, 10:24 AM
Hello Jan,

Thank you for writing.

You should add only one ChartTrackballController to the RadChartView.Controllers collection. Thus, in the ChartTrackballController.TextNeeded event you can specify the text which will be displayed:
Sub New()
    InitializeComponent()
 
    Dim lineSeries As New LineSeries()
    lineSeries.DataPoints.Add(New CategoricalDataPoint(20, "Jan"))
    lineSeries.DataPoints.Add(New CategoricalDataPoint(22, "Apr"))
    lineSeries.DataPoints.Add(New CategoricalDataPoint(12, "Jul"))
    lineSeries.DataPoints.Add(New CategoricalDataPoint(19, "Oct"))
    Me.RadChartView1.Series.Add(lineSeries)
 
    Dim lineSeries2 As New LineSeries()
    lineSeries2.DataPoints.Add(New CategoricalDataPoint(18, "Jan"))
    lineSeries2.DataPoints.Add(New CategoricalDataPoint(15, "Apr"))
    lineSeries2.DataPoints.Add(New CategoricalDataPoint(17, "Jul"))
    lineSeries2.DataPoints.Add(New CategoricalDataPoint(22, "Oct"))
    Me.RadChartView1.Series.Add(lineSeries2)
 
    Dim controler As New ChartTrackballController()
    AddHandler controler.TextNeeded, AddressOf controler_TextNeeded
    RadChartView1.Controllers.Add(controler)
End Sub
Private Sub controler_TextNeeded(sender As Object, e As TextNeededEventArgs)
    Dim sb As New StringBuilder()
    For Each point As DataPointInfo In e.Points
        Dim dataPoint As CategoricalDataPoint = TryCast(point.DataPoint, CategoricalDataPoint)
        sb.AppendLine(String.Format("{0} : {1}", dataPoint.Category, dataPoint.Value))
    Next
    e.Text = sb.ToString()
End Sub

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Jan Skovhus
Top achievements
Rank 1
answered on 17 Dec 2014, 11:21 AM
It works,

Thanks
Tags
ChartView
Asked by
Jan Skovhus
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Jan Skovhus
Top achievements
Rank 1
Share this question
or