SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

Hello,

I was doing a custom pan zoom modifier to drag the chart by click and drop. The Y-axis works well and I can drag up and down but the X-axis instead of just moving it scales a lot.

The same thing happens when I implemented a mouse wheel scroll using the same functionality, is it possible that the last candle is anchored to the side of the graphic? or I’m just not using correctly the Scroll method?

Here is the code of the pan modifier

public override void OnModifierMouseMove(ModifierMouseArgs e)
    {
        if (_lastPoint == null)
            return;

        if (!ModifierSurface.IsPointWithinBounds(e.MousePoint))
            return;

        base.OnModifierMouseMove(e);

        var currentPoint = e.MousePoint;
        var xDelta = currentPoint.X - _lastPoint.Value.X;
        var yDelta = _lastPoint.Value.Y - currentPoint.Y;

        using (ParentSurface.SuspendUpdates())
        {
            XAxis.Scroll(XAxis.IsHorizontalAxis ? xDelta : -xDelta, SciChart.Charting.ClipMode.None);
            YAxis.Scroll(YAxis.IsHorizontalAxis ? -xDelta : yDelta, SciChart.Charting.ClipMode.None);
        }

        _lastPoint = currentPoint;
    }

This is the XAML code

<!--  Create the chart surface with candlestick and histogram bars around each candlestick  -->
    <s:SciChartSurface
        x:Name="sciChart"
        Grid.Column="1"
        Padding="0"
        BorderThickness="0"
        ViewportManager="{Binding ViewportManager}">


        <s:SciChartSurface.RenderableSeries>

            <s:FastHistoBarRenderableSeries
                DataSeries="{Binding DataSeries, Mode=TwoWay}"
                HistogramMode="{Binding HistogramBarMode, Mode=TwoWay}"
                HorizontalBarSpacing="20"
                MaxHistoBarCandles="240"
                PaletteProvider="{StaticResource VolumeLadderThresholdPaletteProvider}"
                TickSize="{Binding TickSize, Mode=TwoWay}"
                VerticalBarSpacing="{Binding VerticalBarSpacing, Mode=TwoWay}"
                StrokeUp="#FF84CFFB"
                StrokeDown="Red"
                AllowDrop="true">


                <s:FastHistoBarRenderableSeries.FillUp>

                    <SolidColorBrush Color="#FF00A2FF" />
                </s:FastHistoBarRenderableSeries.FillUp>

                <s:FastHistoBarRenderableSeries.FillDown>
                    <SolidColorBrush Color="Red" ></SolidColorBrush>
                </s:FastHistoBarRenderableSeries.FillDown>

                <s:FastHistoBarRenderableSeries.AskBarStyle>
                    <Style TargetType="s:HistogramBar">
                        <Setter Property="Stroke" Value="Black" />
                        <Setter Property="MinWidth" Value="200"/>
                        <Setter Property="MinHeight" Value="200"/>
                        <Setter Property="MaxHeight" Value="200"/>
                        <Setter Property="MaxWidth" Value="200"/>
                        <Setter Property="Height" Value="360"/>
                        <Setter Property="Margin"  Value="340"/>
                        <Setter Property="Fill" Value="red" />
                        <Setter Property="FontSize" Value="23" />
                        <!--<Setter Property=" Value="Red" />-->
                    </Style>
                </s:FastHistoBarRenderableSeries.AskBarStyle>

                <s:FastHistoBarRenderableSeries.BidBarStyle>
                    <Style TargetType="s:HistogramBar">
                        <Setter Property="Stroke" Value="Black" />
                        <Setter Property="Fill" Value="#FF00A2FF" />
                    </Style>
                </s:FastHistoBarRenderableSeries.BidBarStyle>

            </s:FastHistoBarRenderableSeries>
        </s:SciChartSurface.RenderableSeries>

        <!--  Create an X Axis  -->
        <s:SciChartSurface.XAxis>
            <s:CategoryDateTimeAxis GrowBy="0.0, 0.1" DrawMajorBands="True" />
        </s:SciChartSurface.XAxis>

        <!--  Create a Y Axis with GrowBy  -->
        <s:SciChartSurface.YAxis>
            <s:NumericAxis GrowBy="0.1, 0.1" DrawMajorBands="True" />
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.ChartModifier>

            <s:ModifierGroup s:MouseManager.MouseEventGroup="SciChartGroup">
                <!--<s:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" 
                                          ActionType="Zoom" 
                                          XyDirection="XYDirection"/>-->
                <!--<s:ZoomPanModifier x:Name="zoomPanModifier" 
                                   IsEnabled="False"
                                   ClipModeX="ClipAtExtents"                                   
                                   />-->
                <s:ZoomExtentsModifier x:Name="zoomExtentsModifier"/>
                <!--<s:RubberBandXyZoomModifier x:Name="rubberBandXyZoomModifier" 
                                            ZoomExtentsY="True"/>-->
                <cm:ZoomPanModifier/>
                <cm:MouseWheelHorizontalScroll/>
                <s:XAxisDragModifier DragMode="Scale"/>
                <s:YAxisDragModifier DragMode="Scale"/>
                <!--<s:RolloverModifier DrawVerticalLine="False"/>-->

            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>
    </s:SciChartSurface>

Thanks 🙂

Version
v6
Images
  • You must to post comments
0
0

Hi there,

For the WPF CategoryDateTimeAxis you cannot view a value earlier than index=0. Perhaps its clipping on the left side because of that?

The DateTimeAxis and DiscontinuousDateTimeAxis can view values earlier than index 0. However these axis types may not be suitable for all types of market in a trading application.

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.