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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

0
0

Hi,

I have a form with two chart surfaces each displaying a chart. I have set their visible ranges to be the same but they have different Y Axis values. This causes the YAxis not to line up. Is there a way I can have the YAxis of both surfaces line up. I’m trying to sync both surfaces and am using the MouseManager.MouseEventGroup to do it. I set the Chart modifiers for the top chart in xaml like this:

<s:SciChartSurface.ChartModifier>
<s:ModifierGroup s:MouseManager.MouseEventGroup="MyCustomGroup">
<s:AnnotationCreationModifier x:Name="annotationCreation" AnnotationCreated="OnAnnotationCreated" YAxisId="Y1"/>
<s:XAxisDragModifier ClipModeX="None" />
<s:YAxisDragModifier IsEnabled="True" ReceiveHandledEvents="True" AxisId="Y1"/>
<s:ZoomPanModifier IsEnabled="True" ReceiveHandledEvents="True" />
<s:CursorModifier IsEnabled="{Binding ShowCursor}" ShowAxisLabels="False" ShowTooltip="True" ReceiveHandledEvents="True" />
<s:MouseWheelZoomModifier ReceiveHandledEvents="True" />
<s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick" />
</s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

and the bottom chart is created in the view model like this:

var scs = new SciChartSurface();
scs.XAxis = new CategoryDateTimeAxis() { DrawMajorGridLines = false, DrawMinorGridLines = false, AutoRange = AutoRange.Never,VisibleRange = ChartVisibleRange};
scs.YAxis = new NumericAxis() { Id = "Y1", DrawMajorGridLines=false,DrawMinorGridLines=false };
scs.Style = (System.Windows.Style)this.chartForm.sciChartControl.Resources["SciChartSurfaceStyle"];
SciChartGroup.SetVerticalChartGroup(scs, "myGroup");
var _chartModifiers = new ModifierGroup();

                MouseManager.SetMouseEventGroup(_chartModifiers, &quot;MyCustomGroup&quot;);

                ChartModifierBase[] chmodColl = this.GetDefaultChartModifiers();
                foreach (ChartModifierBase chmod in chmodColl)
                {
                    _chartModifiers.ChildModifiers.Add(chmod);

                }
                scs.ChartModifier = _chartModifiers;

and the function returning chartmodifiers returns

private ChartModifierBase[] GetDefaultChartModifiers()
{
var chartModifiers = new ChartModifierBase[7];

        XAxisDragModifier xAxisModifier = new XAxisDragModifier();
        xAxisModifier.ClipModeX = ClipMode.None;

        ZoomPanModifier zModifier = new ZoomPanModifier();
        zModifier.IsEnabled = true;
        zModifier.ReceiveHandledEvents = true;

        MouseWheelZoomModifier mwzoom = new MouseWheelZoomModifier();
        mwzoom.ReceiveHandledEvents = true;

        ZoomExtentsModifier zEModifier = new ZoomExtentsModifier();
        zEModifier.ExecuteOn = ExecuteOn.MouseDoubleClick;

        CursorModifier curModifier = new CursorModifier();
        curModifier.IsEnabled = false;
        curModifier.ShowAxisLabels = true;
        curModifier.ShowTooltip = false;
        curModifier.ReceiveHandledEvents = true;


        SeriesValueModifier serModifier = new SeriesValueModifier();
        //serModifier.YAxisId = &quot;Y1&quot;;
        serModifier.IsEnabled = true;

        AnnotationCreationModifier annoModifier = new AnnotationCreationModifier();
        annoModifier.YAxisId = &quot;Y1&quot;;
        annoModifier.IsEnabled = true;
        annoModifier.AnnotationCreated += annoModifier_AnnotationCreated;

        chartModifiers[0] = xAxisModifier;
        chartModifiers[1] = zModifier;
        chartModifiers[2] = mwzoom;
        chartModifiers[3] = zEModifier;
        chartModifiers[4] = curModifier;
        chartModifiers[5] = annoModifier;
        chartModifiers[6] = serModifier;

        return chartModifiers;
    }

The problem is both the charts don’t seem to be synchronised. When I zoom/pan the top chart, nothing happens in the MACD chart and vice versa. What am I doing wrong here ?

I have attached a screenshot of my application. Thanks for patiently answering all my queries so far, you guys are awesome.

Images
  • You must to post comments
0
0

Hi Deepak,

Sure, take a look at this forum post. Also thanks for the positive feedback! We’re here to help! 🙂

UPDATE 2014:
The examples demonstrating the desired behavior have been added to our example suite. Please, refer to the Sync Multi Chart Mouse and the Multi-pane Stock Chart examples.

Best regards,
Andrew

  • Andrew
    Hey by the way, you should consider using BandSeries for the MACD with semi-transparent band colors - as then you can get a shaded polygon between the two lines which changes colour depending on whether the MACD signal line is above/below the other.Best regards, Andrew
  • deepakb1
    Thanks Andrew, that worked like a charm. I will look into the BandSeries as well.Deepak
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.