Last Updated: 09 Nov 2016 08:18 by ADMIN
Created on: 07 Nov 2016 08:45
Category: ChartView
Type: Bug Report
FIX. RadChartView - unable to pan along the entire axis if the orientation of the area is set to Horizontal and the PanZoomMode to Vertical
How to reproduce:
Dim table As New DataTable()
table.Columns.Add("Name", GetType(String))
table.Columns.Add("X", GetType(Integer))
For i As Integer = 0 To 99
    table.Rows.Add($"User {i}", i)
Dim series As New BarSeries()
series.DataSource = table
series.CategoryMember = "Name"
series.ValueMember = "X"
CType(RadChartView1.Area, CartesianArea).Orientation = Orientation.Horizontal
Dim panZoomController As New ChartPanZoomController()
panZoomController.PanZoomMode = ChartPanZoomMode.Vertical
RadChartView1.Zoom(1, 8)

Workaround: create a custom ChartPanZoomController
Dim panZoomController As New MyChartPanZoomController()
panZoomController.PanZoomMode = ChartPanZoomMode.Vertical

Public Class MyChartPanZoomController
    Inherits ChartPanZoomController

    Protected Overrides Function OnMouseMove(e As MouseEventArgs) As ActionResult

        Dim cartesianArea As CartesianArea = TryCast(Me.Area, CartesianArea)
        If cartesianArea Is Nothing Then
            Return MyBase.OnMouseMove(e)
        End If

        Dim panPoint As Point? = Me.GetType().BaseType.GetField("panPoint", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)

        If e.Button = MouseButtons.Left AndAlso panPoint.HasValue Then
            Dim offsetX As Double = Me.GetType().BaseType.GetField("offsetX", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)

            Dim currentOffsetX As Double = offsetX
            Dim defaultAxis As Axis = If(cartesianArea.Orientation = Orientation.Horizontal,
                                         Me.Area.GetType().GetMethod("GetDefaultFirstAxis", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me.Area, New Object() {}),
                                         Me.Area.GetType().GetMethod("GetDefaultSecondAxis", BindingFlags.Instance Or BindingFlags.NonPublic).Invoke(Me.Area, New Object() {}))

            If Me.PanZoomMode = ChartPanZoomMode.Horizontal OrElse Me.PanZoomMode = ChartPanZoomMode.Both Then
                currentOffsetX += (panPoint.Value.X - e.Location.X) * -1

                If currentOffsetX > 0 Then
                    currentOffsetX = 0
                End If

                If currentOffsetX < defaultAxis.Model.LayoutSlot.Width * (DirectCast(cartesianArea.View, IChartView).ZoomWidth - 1) Then
                    currentOffsetX = -defaultAxis.Model.LayoutSlot.Width * (DirectCast(cartesianArea.View, IChartView).ZoomWidth - 1)
                End If
            End If

            Dim offsetY As Double = Me.GetType().BaseType.GetField("offsetY", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(Me)
            Dim currentOffsetY As Double = offsetY
            If Me.PanZoomMode = ChartPanZoomMode.Vertical OrElse Me.PanZoomMode = ChartPanZoomMode.Both Then
                currentOffsetY += (panPoint.Value.Y - e.Location.Y) * -1

                If currentOffsetY > 0 Then
                    currentOffsetY = 0
                End If

                If currentOffsetY < -defaultAxis.Model.LayoutSlot.Height * (DirectCast(cartesianArea.View, IChartView).ZoomHeight - 1) Then
                    currentOffsetY = -defaultAxis.Model.LayoutSlot.Height * (DirectCast(cartesianArea.View, IChartView).ZoomHeight - 1)
                End If
            End If

            cartesianArea.View.Pan(currentOffsetX, currentOffsetY)
        End If

        Return Controller.Empty

    End Function

End Class
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)