Lineseries - Get the mouse over DataPoint in code

Feb 17, 2010 at 7:06 PM

Hi

I have this XAML code:

<charting:Chart Name="Chart2" MouseMove="Chart2_MouseMove" >
                        <charting:LineSeries Name="Chart1"  MouseMove="Chart1_MouseMove"  IndependentValuePath="Freq" DependentValuePath="Value" ItemsSource="{Binding}">
                            <charting:LineSeries.DataPointStyle>
                                <Style TargetType="charting:DataPoint">
                                    <Setter Property="Background" Value="Blue"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter Property="BitmapEffect">
                                                <Setter.Value>
                                                    <OuterGlowBitmapEffect GlowColor="Red" GlowSize="5"/>
                                                </Setter.Value>
                                            </Setter>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </charting:LineSeries.DataPointStyle>
                        </charting:LineSeries>
                    </charting:Chart>

And this gets a glow over an Item that the mouse is over. How can I get the selscted point in code?

 

Feb 19, 2010 at 10:22 AM

Ok I found a way to do this, but....

Private Sub Chart1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
        Dim dep As DependencyObject = DirectCast(e.OriginalSource, DependencyObject)

        If TypeOf (e.OriginalSource) Is System.Windows.Shapes.Ellipse Then
            dep = VisualTreeHelper.GetParent(dep)
            dep = VisualTreeHelper.GetParent(dep)

            Dim d As System.Windows.Controls.DataVisualization.Charting.LineDataPoint = TryCast(dep, System.Windows.Controls.DataVisualization.Charting.LineDataPoint)
            Dim newnumber As Integer = DirectCast(d.DataContext, test).Freq
            If oldnumber = Nothing Then
                AllValuesInColChart.Clear()
                oldnumber = DirectCast(d.DataContext, test).Freq
                Dim i As Integer = 0
                For Each item As Double In Profile.Item(oldnumber)
                    Dim f As New okt
                    f.Freq = Okt132(i)
                    f.Value = item
                    AllValuesInColChart.Add(f)
                    i += 1
                Next
                Try
                    ColChart.ItemsSource = AllValuesInColChart
                Catch ex As Exception

                End Try

            ElseIf newnumber = oldnumber Then
                Exit Sub
            Else
                ColChart.ItemsSource = Nothing
                AllValuesInColChart.Clear()
                newnumber = DirectCast(d.DataContext, test).Freq
                Dim i As Integer = 0
                For Each item As Double In Profile.Item(newnumber)
                    Dim f As New okt
                    f.Freq = Okt132(i)
                    f.Value = item
                    AllValuesInColChart.Add(f)
                    i += 1
                Next
                ColChart.ItemsSource = AllValuesInColChart
                oldnumber = newnumber
            End If
        End If
    End Sub

There is got to be an easyer way of doing this... Does anybody know if a slider can be implemented?