Pre loader

Tag: CoordinateCalculator

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

2 votes
12k views

I am using the SciChart control to render real-time data as it arrives from a data source. This source could be producing data many times per second. New values are appended to the series. If I leave my application running for a long time, the data series gets very long and rendering slows down. I can remove data points from the series when they are older than the VisibleRange and that certainly helps.

My problem is that the user might set the VisibleRange to span several days. If the data source is sending data at 10Hz then that would be 6 million data values per week, redrawing at 10Hz, which I guess will cause some CPU loading. I would like to be able to remove intermediate data from the series if new data being appended to the series would render in the same horizontal pixel as the previous data and is neither the maximum nor minimum Y value at that pixel. In order to do that I need to be able to examine the DateTime of the incoming value and determine its X pixel, then walk back through the existing data to see if it would be visible if rendered (in a new X pixel, or a new min or max in the same pixel as the previous value).

So, finally, to the question: Is there a method for determining the X,Y pixel coordinate for a give X and Y value?

  • asthomas asked 11 years ago
  • last active 9 years ago
0 votes
15k views

take the SciChart Trader as an example, x-Axis is type of CategoryDateTimeAxis. I want a way to show the index of the time in the collection, when mouse moves over the price bar in some mode like Rollover or Cursor.

regards
chunxi

  • chunxi asked 9 years ago
  • last active 9 years ago
1 vote
14k views

I have a chart with a range of 0..1000(xAxis)
Secondly i call;

var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(500);

xDataValue is for example equal 500;

Next step:
I change the range via:

XAxis.VisibleRange.SetMinMax(1000,2000)
// Secondly i call;
var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(1500);

xDataValue shall also be equal 500 or? (but it is negative -XXX)???

I call

SciChart.XAxis.VisibleRange.SetMinMax(min, max);

in my ChartViewModel and

var xCalc = this.XAxis.GetCurrentCoordinateCalculator();
double xDataValue = xCalc.GetCoordinate(1500);

in my ChartModifier..

1 vote
20k views

Hi all,

As the title indicates, I am trying to get mouse cursor position (Coordinates) from a SciChartSurface in MVVM manner.

I have lots of data bindings to my chart properties in my View Model in the background. This following snipped is a copy of my XAML code in which I have all the data bindings set:

<sci:SciChartSurface Grid.Row="0" Grid.Column="0"
                         RenderableSeries="{Binding SciChartSeriesViewModels}"     
                         Padding="0,8,0,2"                                         
                         sci:ThemeManager.Theme="BrightSpark"                                       
                         YAxes="{Binding SciChartYAxesCollection,Mode=TwoWay}"                                         
                         AutoRangeOnStartup="True"                                       
                         Annotations="{Binding ChartAnnotations}"                                     
                         Name="ApplicationSciChart"                                       
                         ChartModifier ="{Binding ChartModifierGroup}"
                         BorderBrush="LightSlateGray"
                         BorderThickness="1"
                         Visibility="{Binding ChartVisibility}">

        <sci:SciChartSurface.XAxis>
            <sci:TimeSpanAxis AxisTitle="Time"
                              AutoRange="Once" GrowBy="0.03,0.001"
                              TextFormatting=""/>
        </sci:SciChartSurface.XAxis>

  </sci:SciChartSurface>

As can be seen from the code above, the ChartModifier property is one of the items that has Data binding to an instance of a ModiferGroup I have created in my View-Model in the background. The following code is a method that adds members to that ModiferGroup (called ChartModiferGroup in my View-Model):

 private void CreateChartModifiers()
    {
        var rubberBandXyZoomModifier = new RubberBandXyZoomModifier
        {
            ExecuteOn = SciChart.Charting.ChartModifiers.ExecuteOn.MouseLeftButton,
            RubberBandFill = (SolidColorBrush)(new BrushConverter().ConvertFrom("#33FFFFFF")),
            RubberBandStroke = Brushes.SteelBlue, 
            RubberBandStrokeDashArray = new DoubleCollection {2.0, 2.0}
        };

        var zoomPanModifier = new ZoomPanModifier
        {
            ExecuteOn = SciChart.Charting.ChartModifiers.ExecuteOn.MouseMiddleButton,
            ClipModeX = SciChart.Charting.ClipMode.None
        };

        var yAxisDragModifier = new YAxisDragModifier
        {
            DragMode = SciChart.Charting.AxisDragModes.Scale
        };

        var xAxisDragModifier = new XAxisDragModifier
        {
            DragMode = SciChart.Charting.AxisDragModes.Pan
        };

        var mouseWheelZoomModifier = new MouseWheelZoomModifier();

        var zoomExtentsModifier = new ZoomExtentsModifier
        {
            ExecuteOn = SciChart.Charting.ChartModifiers.ExecuteOn.MouseDoubleClick
        };

        var cursorModifier = new CursorModifier
        {
            ReceiveHandledEvents = true,
            ShowAxisLabels = false
        };


        var probeline = new VerticalLineAnnotation()
        {
            Stroke = Brushes.LightSlateGray,
            IsEditable = true,
            ShowLabel = true,
            LabelPlacement = LabelPlacement.Axis,
            Visibility = Visibility.Visible,
            IsHidden = false,
            IsEnabled = true,
            X1 = TimeSpan.FromMilliseconds(-100),
            YAxisId = "Triggered",
            StrokeDashArray = new DoubleCollection { 2.0,2.0},
            StrokeThickness = 1
        };

        var verticalSliceModifier = new VerticalSliceModifier
        {
            IsEnabled = true,
            ShowAxisLabels = true,
            Style = probeline.Style
        };
        verticalSliceModifier.VerticalLines.Add(probeline);


        ChartModifierGroup.ChildModifiers.Add(rubberBandXyZoomModifier);
        ChartModifierGroup.ChildModifiers.Add(rubberBandXyZoomModifier);
        ChartModifierGroup.ChildModifiers.Add(zoomPanModifier);
        ChartModifierGroup.ChildModifiers.Add(yAxisDragModifier);
        ChartModifierGroup.ChildModifiers.Add(xAxisDragModifier);
        ChartModifierGroup.ChildModifiers.Add(mouseWheelZoomModifier);
        ChartModifierGroup.ChildModifiers.Add(zoomExtentsModifier);
        ChartModifierGroup.ChildModifiers.Add(verticalSliceModifier);
        ChartModifierGroup.ChildModifiers.Add(cursorModifier);
    }

What I am trying to do next, is to add functionality in my application, such that I can add more VerticalSliceModifiers to my ChartModifierGroup when a button is pressed. In order to do that, I will require having access to the Mouse cursor position of my SciChartSurface to set the X1 property of the VerticalLineAnnotation, that would be used for the VerticalSliceModifiers (to be created).

In simple words, every time I press a button, I need the position of the mouse pointer to get captured and used as the location of the new VerticalSliceModifer that I am going to create.

I have already read many of the examples and documentation of Sci-Chart such as: Vertical Slice Tooltips Example. However, in this example, the mouse pointer location is accessed is under the xaml.cs and not inside an actual View-Model.

I was wondering if anybody could let me know how I can get access to my SciChartSurface mouse pointer position using true MVVM model.

0 votes
8k views

Hi.

I need to know the position of mouse click in axes coordinates. I’ve created a modifier for this:

public class CustomPointSelectionModifier : SeriesSelectionModifier
{
    public override void OnModifierMouseUp(ModifierMouseArgs e)
    {
        base.OnModifierMouseUp(e);
        var xcalc = ParentSurface.XAxes.First().GetCurrentCoordinateCalculator();
        var ycalc = ParentSurface.YAxes.First().GetCurrentCoordinateCalculator();
        var poistionPoint = Mouse.GetPosition((IInputElement)ParentSurface);

        var point = new Point()
        {
            X = xcalc.GetDataValue(poistionPoint.X),
            Y = ycalc.GetDataValue(poistionPoint.Y),
        };
        ((SciChartMvvmBindingsViewModel)DataContext).OnMouseUp(e, point);
    }
}

And it works well if axes width is zero. Otherwise, it provides values shifted by axes width (or height for Y-axis)
In my example, it should add an arrow annotation in a click point. Instead of this, it adds an arrow with shifted coordinates.

What am I doing wrong?
Thanks

Showing 5 results

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies