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

0
0

Hi,
I’m loading my charts in an Observable collection in an itemscontrol.

I’ve successfully synchronize my charts with the ChartModifiers but I do not want the RubberBandXyZoomModifier to be synced.

I’ve set IsXAxisOnly=”False” and ReceiveHandledEvents=”False” for the RubberBandXyZoomModifier and this works perfectly in the first chart. I can drag zoom on the first chart and it will zoom on the X and Y-Axis for the first chart while zooming on the X-axis only for the other charts.

However when I try to drag zoom on subsequent charts the drag zoom is applied to the first chart only.

Setting ReceiveHandledEvents=”True” is not what I want because it applies the X and Y-Axis zoom on all the charts.

See attached.

How can I apply the RubberBandXyZoomModifier independently from other charts?

Johnny

Attachments
  • You must to post comments
0
0

Hi,

You need to extend existing zoom modifier in such a way:

    class RubberBandXyZoomModifierEx : RubberBandXyZoomModifier
    {
        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            // Start dragging only in the case when on master chart
            if (e.IsMaster)
            {
                base.OnModifierMouseDown(e);
            }
        }
    }

Use it for all subsequent charts. Hope this helps!

Best regards,
Yuriy

  • johnnyp112
    Thanks Yuriy, I put this in the code behind for ChartView.xaml.cs and call:
    <local:RubberBandXyZoomModifierEx ReceiveHandledEvents="False" IsXAxisOnly="False" ExecuteOn="MouseLeftButton"/>
    
    This seems to work as it does not show the drag box in the first chart and zooms in the second chart but it does not show the drag box in the second chart.What am I missing or what am I doing wrong?Johnny
  • Yuriy
    Hi Johnny,Just to be sure, do you want to zoom each chart separately? They shouldn't be synchronized neither on XAxis, nor on YAxis?RubberBandXyZoomModifier isn't synchronized now, but you have XVisibleRange shared across the charts, so changes in the first chart trigger changes in other charts.Best regards, Yuriy
  • johnnyp112
    I want the XAxis to be synchronized. The YAxis should not be synchronized though when using the RubberBandXyZoomModifier.Your solution above works but I am missing the drag box in subsequent charts.Thanks,Johnny
  • Yuriy
    Hi,Thanks for explanation, seems that I misunderstood you previously. OK, in this case you don't need custom modifier. Try to set IsXAxisOnly="True" for all RubberBandXyZoomModifiers except the one belonging to the main (first) chart.Please, let me know if this helps,Regards, Yuriy
  • johnnyp112
    I'm not sure how to implement what you are suggesting.From my example, I'm displaying the chart from an observable collection to allow adding charts dynamically. All charts are derived from the same ChartView so how can I set the RubberBandXyZoomModifier for any subsequent charts?From your first suggestion with extending the RubberBandXyZoomModifier, this functionally gives me what I needed but the visual drag box does not show in any subsequent charts. Please have a look at the previous attached zip file (not the first one) and try drag zooming on the second chart. You'll notice the second chart will zoom on both X and Y-Axis but no visual drag box is displayed and the first chart will zoom only on the X-Axis. Functionally this is what I want but I'm not getting the visual drag box on the second chart.Drag zoom on the first chart and it works just as I wanted.
  • You must to post comments
0
0

Hi,

Thanks for additional explanations 🙂 OK, what I suggest to do(and it seems to work properly), is the following:

                <s:ModifierGroup s:MouseManager.MouseEventGroup="myCustomGroup">
                    <local:RubberBandXyZoomModifierEx ReceiveHandledEvents="True" ExecuteOn="MouseLeftButton"/>

...

And modify extended modifier in such a way:

    public class RubberBandXyZoomModifierEx : RubberBandXyZoomModifier
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            log.Info("RubberBandXyZoomModifierEx");
            // Start dragging only in the case when on master chart

            log.Info("RubberBandXyZoomModifierEx:: Master Chart");

            // Perform zoom on XAxis only, except the Master Chart 
            IsXAxisOnly = !e.IsMaster;

            base.OnModifierMouseDown(e);
        }
    }

Does this work as desired? Please, let us know,

Best regards,
Yuriy

  • johnnyp112
    Perfect! That is exactly what I wanted. Thanks Yuriy! You guys are great!
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.