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!

-1 votes
0 answers
153 views

When i go to zoom on my YAxis while a YAxis VisibleRangeLimit is baing set, the zoom does not work correctly. Once the zooming is finished it will reset back to the range limit. If i remove the range limit, the zooming then works as expected.

0 votes
258 views

I cannot get panning to work on the x axis which is a DateTimeAxis. I am databinding the visible range to a property on my view model and the zooming works ok. Also panning on the Y-axis works.

Here is my XAML:

<s:SciChartSurface x:Name="_sciChartSurface" Grid.Row="1" Grid.ColumnSpan="2" RenderableSeries="{s:SeriesBinding PlotViewModels}">
            <s:SciChartSurface.XAxis>
                <s:DateTimeAxis AxisTitle="{Binding HorizontalTitle}" VisibleRange="{Binding HorizontalRange, Mode=TwoWay}" AutoRange="Never"
                            IsStaticAxis="True" DrawMajorBands="False" TextFormatting="dd-MMM-yyyy" SubDayTextFormatting="H:mm:ss:tt"
                            AutoTicks="True"/>
            </s:SciChartSurface.XAxis>
            <s:SciChartSurface.YAxis>
                <s:NumericAxis AxisTitle="{Binding VerticalTitle}" AxisAlignment="Left"  VisibleRange="{Binding VerticalRange}"
                           AutoRange="{Binding AutoRange}" DrawMajorBands="False"/>
            </s:SciChartSurface.YAxis>

            <s:SciChartSurface.ChartModifier>
                <s:ModifierGroup>
                    <s:RubberBandXyZoomModifier IsXAxisOnly="False" 
                                            ZoomExtentsY="True" 
                                            IsAnimated="True" 
                                            RubberBandFill="#55FFFFFF" RubberBandStroke="#FFFFFFFF" RubberBandStrokeDashArray="2 2">
                    </s:RubberBandXyZoomModifier>

                    <s:ZoomPanModifier ExecuteOn="MouseRightButton" ClipModeX="None" XyDirection="XYDirection" IsEnabled="True" />
                    <!-- Allow Dragging YAxis to Scale -->
                    <s:YAxisDragModifier DragMode="Scale"/>
                    <!-- Allow Dragging XAxis to Pan -->
                    <s:XAxisDragModifier DragMode="Scale" IsEnabled="True"/>

                    <s:MouseWheelZoomModifier ActionType="Zoom" XyDirection="XYDirection"/>

                    <s:ZoomExtentsModifier IsAnimated="True" ExecuteOn="MouseDoubleClick"/>
                </s:ModifierGroup>
            </s:SciChartSurface.ChartModifier>
        </s:SciChartSurface>
0 votes
0 answers
411 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
362 views

Dear all,

I am trying to load my chart with a default zoom factor value. For that I have follow and modify the exemple shown by using key stroke.

My modifiier class is defined as below :

 public class SimpleZoomInOutModifier : ChartModifierBase
{
    public static readonly DependencyProperty ZoomFractionProperty 
        = DependencyProperty.Register("ZoomFraction", typeof(double), typeof(SimpleZoomInOutModifier), new PropertyMetadata(0.1));

    public double ZoomFraction
    {
        get { return (double)GetValue(ZoomFractionProperty); }
        set { SetValue(ZoomFractionProperty, value); }
    }

    void SciChart_PreviewKeyDown(object sender, KeyEventArgs e)
    {
        double factor = 0;

        if (e.Key == Key.Up)
        {
            // On CTRL+, Zoom In
            factor = -ZoomFraction;
        }
        if (e.Key == Key.Down)
        {
            // On CTRL-, Zoom Out
            factor = ZoomFraction;
        }

        using (ParentSurface.SuspendUpdates())
        {
            // Zoom the XAxis by the required factor
            XAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Zoom the YAxis by the required factor
            YAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Note.. can be extended for multiple YAxis XAxis, just iterate over all axes on the parent surface
        }
    }

    public override void OnAttached()
    {
        base.OnAttached();
        var scichart = ((SciChartSurface)ParentSurface);

        var mainWindow = FindLogicalParent<UserControl>(scichart);

        mainWindow.PreviewKeyDown -= SciChart_PreviewKeyDown;
        mainWindow.PreviewKeyDown += SciChart_PreviewKeyDown;
        mainWindow.Loaded += SciChart_Loaded; 
    }

    private void SciChart_Loaded(object sender, RoutedEventArgs e)
    {
        double factor = 0;
        // On CTRL+, Zoom In
        factor = -ZoomFraction;

        using (ParentSurface.SuspendUpdates())
        {
            // Zoom the XAxis by the required factor
            XAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Zoom the YAxis by the required factor
            YAxis.ZoomBy(factor, factor, TimeSpan.FromMilliseconds(500));

            // Note.. can be extended for multiple YAxis XAxis, just iterate over all axes on the parent surface
        }
    }

From the code above, the zoom in by using Up and Down keys is working perfectly well but when I try to force the zoom in inside the chart_loaded event, nothing happen.

Any idea what I am doing wrong ?

regards

  • sc sc asked 7 months ago
  • last active 7 months ago
0 votes
787 views

Hi, guys

My x axis is SCICategoryDateTimeAxis class type. And it’s limited by VisiableRangeLimit like:

[xAxis setVisibleRangeLimit:[[SCIDoubleRange alloc] initWithMin:SCIGeneric(firstItem – (lastItem – priorItem))
Max:SCIGeneric(lastItem + (lastItem – priorItem))]];

Also for scrolling my content inside chart:

SCIZoomPanModifier * zpm = [[SCIZoomPanModifier alloc] init];
[zpm setModifierName:@"PanZoom Modifier"];
[zpm setClipModeX:SCIZoomPanClipMode_ClipAtExtents];

Like a description SCIZoomPanClipMode_ClipAtExtents says:
“forces the panning operation to stop suddenly at the extents of the data” – but it’s not working constantly.
Sometimes it’s allow to scroll outside the range. Like on the attached image.

So my question is how to limit scrolling by min and max value?

Best regards,
Sushynski Andrei

0 votes
894 views

We are transitioning from using oxyplot to sci-chart for the increased performance it offers.

In oxyplot you are able to configure the plot to allow you to click and drag on an axis to zoom only that axis.

I have found RubberBandXyZoomModifier, and can see how it can be set up to only zoom the x or y axis, but cant see any way to allow zooming a specific x or y axis when the click and drag occurs on that axis.

Before I dive into the modifiers API and start to figure out how to do this from scratch, am I missing something, or do you have any pointers on how to achieve this functionality as I believe it is a pretty common use case.

  • Hugoagogo asked 2 years ago
  • last active 2 years ago
0 votes
816 views

I did modify this CustomAnnotationChartModifier. I added a databinding to bing the ShowLabelProperty to the IsSelectedProperty.

    // Recreate all annotations, called when LabelsSource property changes or when the
    // CustomAnnotationChartModifier is attached to the parent surface
    private void RebuildAnnotations() {
        if (base.ParentSurface == null || LabelsSource == null)
            return;
        var annotationCollection = base.ParentSurface.Annotations;
        annotationCollection.Clear();
        foreach (var item in LabelsSource) {
            var vla = new VerticalLineAnnotation();
            vla.DataContext = item;
            vla.SetBinding(AnnotationBase.X1Property, new Binding("X1") { Mode = BindingMode.OneWay });
            // bind ShowLabelProperty
            vla.SetBinding(VerticalLineAnnotation.ShowLabelProperty,
                new Binding("IsSelected") { RelativeSource = RelativeSource.Self, Mode=BindingMode.OneWay });
            vla.IsEditable = this.IsEditable;
            // after manipulation: write X1Property back to Viewmodel 
            vla.DragEnded += Annotation_DragEnded;
            vla.LabelPlacement = LabelPlacement.Top;
            // test to set directly ShowLabel = (bool)e.NewValue;
            //vla.Unselected += annotation_SelectionChanged;
            //vla.Selected += annotation_SelectionChanged; 
            if (this.MarkerManipulatedCommand != null)
                vla.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(manipulationCompleted_EventHandler);
            annotationCollection.Add(vla);
        }
    }

    private void annotation_SelectionChanged(object sender, EventArgs e) {
        var vla = sender as VerticalLineAnnotation;
        if (vla == null) return;
        vla.ShowLabel =vla.IsSelected;
    }

Result: Select the annoation will show the label. Unselect will not remove the label.
I did try the unselected and selected-event to do the same on other way ->same result.
I can see also that each new selection lighter the label (is it shown more than one time?).

How can I add ToolTipLabel inside that CustomAnnotationChartModifier to see the y-values?

Frank

0 votes
1k views

I am using SciChart to draw some graph on my application.
I use ZoomPanModifier to be able to zoom and drag the graph (with range limit).

<s:ZoomPanModifier ClipModeX="ClipAtExtents" XyDirection="XYDirection" ZoomExtentsY="True" ExecuteOn="MouseLeftButton" IsEnabled="True"/>

But the problem is when I drag to the edge of the graph, it will scale up automatically when I keep dragging.

Is there any way so that I can zoom in/out, drag graph (after zooming in), and no dragging and scaling up when I get to the edge of graph?

0 votes
1k views

Hi,

I’ve got an issue with ChartModifiers in following scenario. I’ve got bunches of signals, where every signal carry data from different sensor. Bunches are recorded at individual sessions. I need to look at them collectively, so I choose some signals from one bunch and some signals from another bunch, where one signal = one SciChartSurface control and every SciChartSurface control is aligned in sequencer-like way (like yours Multi-Pane Stock Chart example), because I want to see signals one under another. I need to have some group of ChartModifiers acting on all choosen signals, because time scale should be preserved (as in yours example) – it works in my solution. But I also need to apply a modifier to pan, that should works only on signals that are part of certain bunch, because starting point in time of certain bunch signals don’t have to be preserved.

Assuming, zoom should works on every signal from every bunch, but panning should works only on signals from one bunch. I already gain zoom functionality by the means of ModifierGroup and MouseManager.SetMouseEventGroup(), but i don’t know how to add the panning. Could you give me any suggestions, how can I handle this?

I’m sending some screens below.

0 votes
1k views

I’ve created a custom rollover modifier, the aim being it only moves when the mouse is down. Pretty simple, here’s the code I have:

class Histogram2DSlicer : RolloverModifier
{
    public Histogram2DSlicer() : base()
    {
        ReceiveHandledEvents = true;
    }

    public override void OnModifierMouseMove(ModifierMouseArgs e)
    {
        Console.WriteLine(e.MouseButtons);
        if (e.MouseButtons == MouseButtons.Left)
        {
            base.OnModifierMouseMove(e);
        }
    }
}

However, the ModifierMouseArgs e.MouseButtons is “None” at all times, is this a bug or do the Modifiers not receive button events?

Joe

  • Ken Hobbs asked 2 years ago
  • last active 2 years ago
0 votes
2k views

Hi, Andrew. sorry to bother you.

if i changed the YValue by drag the point on series(http://support.scichart.com/index.php?/Knowledgebase/Article/View/17239/32/custom-chartmodifiers—part-5—select-and-drag-a-data-point), i want to set data repository dirty. how to notify the viewmodel, by even, or binding. could you tell me the better( rational, even best ) way?

sorry, i’m a newer to WPF.

many thanks

0 votes
2k views

I have a set of ChartModifiers on my SciChartSurface, carefully configured to work together like so:

<s:SciChartSurface.ChartModifier>
    <s:ModifierGroup>
        <s:LegendModifier x:Name="LegendModifier" />
        <s:ZoomPanModifier ExecuteOn="MouseRightButton" ClipModeX="None" />
        <s:RubberBandXyZoomModifier ExecuteOn="MouseLeftButton" />
        <s:SeriesSelectionModifier />
        <s:ZoomExtentsModifier ExecuteOn="MouseDoubleClick" />
        <s:MouseWheelZoomModifier />
    </s:ModifierGroup>
</s:SciChartSurface.ChartModifier>

I also have a pair of VerticalLineAnnotations, which I create in the C#. These are used to select points on the series that has been selected with the SeriesSelectionModifier.

The problem is that after the sliders are dragged, the mouse up event causes the selected series to be unselected. How can I prevent this from happening?

1 vote
4k views

I am currently playing with a Polar Plot that is from 0-360 degrees for it’s XAxis (phase). I am trying to determine the “next” coordinates on a keypress.

Currently I am trying:

        ModifierSurface.Clear();

        foreach (var series in this.ParentSurface.RenderableSeries)
        {
            var nextPhase = (double)series.DataSeries.XValues[_phaseIndex];
            var nextAmp = (double)series.DataSeries.YValues[_phaseIndex];

            var xCoordinate = series.XAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextPhase);
            var yCoordinate = series.YAxis.GetCurrentCoordinateCalculator().GetCoordinate(nextAmp);

            DrawCursor(xCoordinate, yCoordinate, nextPhase, nextAmp);
        }

Unfortunately I am not getting the point coordinate I am expecting for drawing my next “cursor info” window.

_phaseIndex is currently 340, and I want to increment it to 341 and get the next X/Y pair location. But I can’t seem to get the location.

Any help would be great!

Thanks!
Geranon

0 votes
3k views

We implemented a custom TooltipModifier. We want to fade out the tooltip after a defined timespan if the mouse doesn’t move. Is there something predefined or how to implement this? It should be something like ToolTipService.ShowDuration from WPF.

0 votes
0 answers
3k views

Hi! 🙂

I’m having some trouble with my annotations. This is the case:

I have a chart modifier with a dependency property that, when set or changed, manipulates its parent surface annotation collection directly. Currently I’m only adding/removing annotations of type VerticalLineAnnotation on a DateTimeAxis. My first problem is that only a single annotation is shown at any given time (the first one added). When i inspect the bindings and annotation collection on the sci chart surface everything seems to be in order (all annotations are present and their values are correct).

My second issue is that the first time my annotation is painted it is not properly displayed (only partly visible in the left upper corner). I have to force a repaint, through a re-size or zoom action, for my annotation to display correctly.

This is the type of annotations I’m adding to the AnnotationCollection:

var verticalAnnotation = new VerticalLineAnnotation
 {
        Tag = annotation.Tag,
         X1 = annotation.X1,
         StrokeThickness = annotation.StrokeThickness,
         Stroke = annotation.Stroke,
         LabelPlacement = LabelPlacement.Right
  };

Any idea about what I’m doing wrong?

1 vote
4k views

I want to highlight a single bar in a plot with multiple StackedColumnRenderableSeries (or FastColumnRenderableSeries). I want to do this when the user clicks a bar. I’ve created a “ClickSelectionModifier” that is able to detect what series + data series index the user clicks, but I have not been able to highlight the clicked bar. A few nudges in the right direction would be appreciated 🙂

Example of single highlighted bar

1 vote
6k views

Hello,

I have a SciChart with multiple y-axes. Thanks to the ZoomPanModifier the user can pan the whole chart by dragging (holding the left mouse button down and moving the mouse). Good! But it should also be possible for the user to pan a certain axis (meaning : changing the min and max values of the axis) and that doesn’t seem to be possible with the built-in ChartModifiers.

So then I thought, no problem, I make my own ChartModifier to handle this (I already implemented two other modifiers for other mouse interactions before, so I get the hang of this :-)). But I don’t get this to work correctly.

My first attempt was to derive from ChartModifierBase and then handle events like OnModifierMouseDown and OnModifierMouseUp. Problem there is that OnModifierMouseUp doesn’t get called when the mouse is not over the chart surface anymore. That is a problem because the user can release the mouse button when the mouse is over another part of the WPF window or even outside of the application window and somewhere else on the screen.

My second attempt was to inherit from ZoomPanModifierBase because the ZoomPanModifier handles these ‘mouseups’ correctly. I try by overriding the Pan(System.Windows.Point currentPoint, System.Windows.Point lastPoint, System.Windows.Point startPoint) method but this method only gets called when the panning starts on the chart area itself, not on one of the axes, so it doesn’t seem to be a solution either.

 public class AxisPanModifier : ZoomPanModifierBase
{
    public override void Pan(System.Windows.Point currentPoint, System.Windows.Point lastPoint, System.Windows.Point startPoint) {
        // Does not get called when the dragging starts on an axis.
    }
}

Can someone give me a tip on how to proceed or does someone already have a solution for this ? Thanks for any help in advance. 🙂

Best greetings,
Stefaan

  • srillaert asked 4 years ago
  • last active 4 years ago
4 votes
6k views

Hi guys,

After adding a YAxis to the left of my SciChart I’ve noticed that this code no longer functions as I expect:

        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            base.OnModifierMouseDown(e);

            if (ParentSurface.RenderableSeries.First().XAxis == null)
                return;

            if (!_mouseDragged && IsFunctional)
            {
                _mouseDragged = true;
                _selectionStart = (DateTime) ParentSurface.RenderableSeries.First().HitTest(e.MousePoint).XValue;
            }
        }

_selectionStart should be a Date under the cursor where the user has just clicked. Instead it’s a Date approx. 40pixels to the right of where the user has just clicked because the Left YAxis is approx. 40 pixels, and the ModifierMouseArgs.MousePoint is considering the YAxis space into it’s X coordinate value.

So when I take that point and perform a HitTest, I am not getting the expected result here.

I will write a fix for this to take into account a Left Y Axis if one exists and modify the point’s X coordinate value, but I thought to give you a heads-up in case this is outside of expected functionality and is indeed a bug.

Cheers,
Miles

  • bstapylton asked 6 years ago
  • last active 3 years ago
4 votes
6k views

I am trying to add Zoom capability to application that is based on ECG Monitor sample. As ECG Monitor manages VisibleRange, I need to stop setting VisibleRange when zoom is started. I am setting flag in RubberBandXyZoomModifier.OnModifierMouseDown.

Is there any way to create a custom ChartModifier to be notified when the user clicks mouse down on the chart, or axis?

Showing 19 results
This template supports the sidebar's widgets. Add one or use Full Width layout.