|
Private Sub chart_Loaded(sender As Object, e As RoutedEventArgs) Handles chart.Loaded
scrollBar = CType(chart.PrimaryAxis.GetType.GetField("sfChartResizableBar", BindingFlags.NonPublic Or BindingFlags.GetField Or BindingFlags.Instance).GetValue(chart.PrimaryAxis), SfChartResizableBar)
chart.RowDefinitions.Clear()
AddChartAreas()
SetChartRowHeights(chart)
End Sub
Sub SetChartRowHeights(inChart As SfChart)
Dim maxBuyVolume As Double = BaseTicker.Minutes.Max(Function(buy) buy.BuyVolume)
Dim maxSellVolume As Double = BaseTicker.Minutes.Max(Function(buy) buy.SellVolume)
inChart.RowDefinitions(1).Height = (2 * maxBuyVolume) / (maxBuyVolume + maxSellVolume) 'buy row
inChart.RowDefinitions(0).Height = (2 * maxSellVolume) / (maxBuyVolume + maxSellVolume) 'sell row
WinMainInstance.tbRowHeight0.Text = "ChartRow 0 height: " & inChart.RowDefinitions(0).Height
WinMainInstance.tbRowHeight1.Text = "ChartRow 1 height: " & inChart.RowDefinitions(1).Height
End Sub |
|
Class CustomDateTimeCategoryXAxis
Inherits DateTimeCategoryAxis
Dim previousVisibleRange As DoubleRange
..
'We need to update the secondary axis visible range after the primary axis actual range is updated.
Protected Overrides Sub CalculateVisibleRange(avalableSize As Size)
previousVisibleRange = VisibleRange
MyBase.CalculateVisibleRange(avalableSize)
..
If (VisibleRange.Start <> previousVisibleRange.Start OrElse VisibleRange.End <> previousVisibleRange.End) Then
SetChartRowHeights(sfChart)
Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, Sub() UpdateArea())
End If
End Sub
Private Sub UpdateArea()
If (sfChart IsNot Nothing) Then
sfChart.GetType().GetMethod("UpdateArea",
BindingFlags.InvokeMethod Or BindingFlags.NonPublic Or BindingFlags.Instance, Nothing,
New Type() {GetType(System.Boolean)},
Nothing).Invoke(sfChart, New Object() {True})
End If
End Sub
Sub SetChartRowHeights(inChart As SfChart)
Dim maxBuyVolume As Double = WinMainInstance.YAxisVolumeBuy.VisibleRange.End
Dim maxSellVolume As Double = WinMainInstance.YAxisVolumeSell.VisibleRange.End
inChart.RowDefinitions(1).Height = (2 * maxBuyVolume) / (maxBuyVolume + maxSellVolume) 'buy row
inChart.RowDefinitions(0).Height = (2 * maxSellVolume) / (maxBuyVolume + maxSellVolume) 'sell row
WinMainInstance.tbRowHeight0.Text = "ChartRow 0 height: " & inChart.RowDefinitions(0).Height
WinMainInstance.tbRowHeight1.Text = "ChartRow 1 height: " & inChart.RowDefinitions(1).Height
End Sub
End Class |