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

0
0

Hi!
I’ve recently updated to version 2 and I’m trying to sync a rollover modifier between multiple graphs.
I’m aware of the SciTrader demo, but I think that my situation is a bit different. My graphs are created dynamically by the user (imagine a “New Graph” button). That means that they are instantiated in code behind. So far only Graph B is in sync with graph A (not vis versa). However there seem to be an issue. In my use case, Graph A and Graph B can be of different width. The Rollover modifier seems to not scale properly (see attached screenshot). It seems to be dependent on the size of Graph A instead of the position in the series.

Is this a bug or am I doing something wrong?

Thank you!

Images
  • You must to post comments
0
0

Hi,

To synchronize modifiers, you need to set MouseEventGroup property on ModifierGroup instance and add all modifiers into ModifierGroup.ChildModifiers collection (like you can do it in XAML). Also, you could take a look at Sync rollover between dynamically created charts thread, probably you can find there some useful info.

Concerning the issue you experience, it is expected behavior, because modifiers synchronization via MouseManager.MouseEventGroup is based on actual coordinates(pixels), not chart coordinates… it was intended to be used on charts with synchronized width (using either SciChartGroup.VerticalChartGroup=”myCharts” or any other way).

In this case you need to implement own synchronization. For example, the code below should do this:

public class RolloverModifierEx : RolloverModifier
{
    private static Tuple<IComparable, IComparable> _masterChartCoords;

    public override void OnModifierMouseMove(ModifierMouseArgs e)
    {
        // To synchronize rollovers, transform mouse point into chart coords and save it
        // For charts, which aren't covered with mouse, transform back to pixels
        if (e.IsMaster)
        {
            var xDataCoord = XAxis.GetDataValue(e.MousePoint.X);
            var yDataCoord = YAxis.GetDataValue(e.MousePoint.Y);

            // Save coords in chart coordinates
            _masterChartCoords = new Tuple<IComparable, IComparable>(xDataCoord, yDataCoord);
        }
        else
        {
            // Transform chart coords into pixel coords
            var xCoord = XAxis.GetCoordinate(_masterChartCoords.Item1);
            var yCoord = YAxis.GetCoordinate(_masterChartCoords.Item2);

            e.MousePoint = new Point(xCoord, yCoord);
        }

        base.OnModifierMouseMove(e);
    }
}

You can implement it in your own way using this idea.

Hope the above helps!

Best regards,
Yuriy

  • You must to post comments
0
0

Hi,
I was trying this solution in order to synchronize X-Axis rollover for charts with different widths.
My main problem is that it seems that the GetDataValue method is returning a value that is not correct: in my master chart I place the cursor over an X coordinate that is near to 2, but when I execute the GetDataValue method I get 4.8 which in my chart is a pretty far point(currently the chart is displaying values from 0 to 10 on the x-axis). It seems that the mouse point is considering also the size of the Y axis on the left (if I try to remove from the mouse coordinates the width of the Y-axis I get a nearer value of 2.5).

Is there a method that can get the right value without the need to manually consider axis sizes? (The charts in our application are configurable and there can be more than one Y axis and it can also be placed on the right, so calculating manually the coordinates is not a simple solution)

Thanks

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.