Pre loader

Tag: SciChartSurface

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

0 votes
16k views

I deleted my prior question and instead provide code that reproduces the error. I just whipped up two SciChartSurfaces in xaml and bind to properties provided in code behind. Can you please take a look and see whether you also can RubberBandXyZoom but not correctly use ZoomPan? ZoomPan is not synced between the two charts. Its been a very frustrating couple hours….without finding the bug.

public partial class TestControl : UserControl
{
    private ILabelProvider _xAxisFormat;
    private string yAxisFormat;
    private ObservableCollection<IChartSeriesViewModel> _series1;
    private ObservableCollection<IChartSeriesViewModel> _series2;
    private DateRange _sharedXRange;

    public TestControl()
    {
        //SciChartSurface.SetLicenseKey(
        //    @"
        //    <LicenseContract>
        //      ....License Code goes here
        //    </LicenseContract>

        //    ");

        XAxisFormat = new DateTimeLabelProvider();
        YAxisFormat = "0.00";

        Series1 = new ObservableCollection<IChartSeriesViewModel>(new List<IChartSeriesViewModel>() { GenerateSampleLineSeries() });
        Series2 = new ObservableCollection<IChartSeriesViewModel>(new List<IChartSeriesViewModel>() { GenerateSampleLineSeries() });

        //set shared xRange
        SharedXRange = new DateRange((DateTime) Series1.First().DataSeries.XMin, (DateTime) Series1.First().DataSeries.XMax);

        InitializeComponent();
    }

    public ObservableCollection<IChartSeriesViewModel> Series1
    {
        get { return _series1; }
        set
        {
            _series1 = value;
        }
    }

    public ObservableCollection<IChartSeriesViewModel> Series2
    {
        get { return _series2; }
        set
        {
            _series2 = value;
        }
    }

    public DateRange SharedXRange
    {
        get { return _sharedXRange; }
        set
        {
            _sharedXRange = value;
        }
    }

    public ILabelProvider XAxisFormat
    {
        get { return _xAxisFormat; }
        set
        {
            _xAxisFormat = value;
        }
    }

    public string YAxisFormat
    {
        get { return yAxisFormat; }
        set
        {
            yAxisFormat = value;
        }
    }

    private IChartSeriesViewModel GenerateSampleLineSeries()
    {
        var seriesName = "TestLineSeries" + (new Random((int)DateTime.Now.Ticks)).Next();
        List<DateTime> timeStamps = new List<DateTime>();
        List<double> values = new List<double>();
        Random rand = new Random((int)DateTime.Now.Ticks);
        DateTime currentDt = DateTime.Now;
        double currentValue = 0;

        for (int index = 0; index < 1000; index++)
        {
            currentDt = currentDt.AddMinutes(1);
            currentValue = currentValue + (rand.NextDouble() - 0.5);

            timeStamps.Add(currentDt);
            values.Add(currentValue);
        }

        var dataSeries = new XyDataSeries<DateTime, double>();
        dataSeries.SeriesName = seriesName;
        dataSeries.Append(timeStamps, values);


        var renderSeries = new FastLineRenderableSeries() { Name = dataSeries.SeriesName, DataSeries = dataSeries, AntiAliasing = false, StrokeThickness = 2 };

        return new ChartSeriesViewModel(dataSeries, renderSeries);
    }
}


<UserControl x:Class="MattLibrary.ChartLibrary.Views.TestControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:s="http://schemas.abtsoftware.co.uk/scichart"
         mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300"
         DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>

    <Grid.RowDefinitions>
        <RowDefinition Height="1*"/>
        <RowDefinition Height="1*"/>
    </Grid.RowDefinitions>

    <s:SciChartSurface Grid.Row="0" SeriesSource="{Binding Series1}">

        <s:SciChartSurface.XAxis>
            <s:DateTimeAxis 
                            Visibility="Visible"
                            LabelProvider="{Binding XAxisFormat}" 
                            VisibleRange="{Binding SharedXRange}"
                            GrowBy="0.01, 0.01"/>
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis 
                            Visibility="Visible"
                            AxisAlignment="Right"
                            TextFormatting="{Binding YAxisFormat}" 
                            GrowBy="0.03, 0.03" 
                            AutoRange="Always"/>
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.ChartModifier>

            <s:ModifierGroup s:MouseManager.MouseEventGroup="SharedMouseGroup">

                <s:ZoomPanModifier IsEnabled="True" ReceiveHandledEvents="True" XyDirection="XDirection" ExecuteOn ="MouseLeftButton"/>
                <s:RubberBandXyZoomModifier IsEnabled="True" ReceiveHandledEvents="True" IsXAxisOnly="True" ExecuteOn="MouseRightButton"/>

            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>

    </s:SciChartSurface>



    <s:SciChartSurface Grid.Row="1" SeriesSource="{Binding Series2}">

        <s:SciChartSurface.XAxis>
            <s:DateTimeAxis 
                            Visibility="Visible"
                            LabelProvider="{Binding XAxisFormat}" 
                            VisibleRange="{Binding SharedXRange}"
                            GrowBy="0.01, 0.01"/>
        </s:SciChartSurface.XAxis>

        <s:SciChartSurface.YAxis>
            <s:NumericAxis 
                            Visibility="Visible"
                            AxisAlignment="Right"
                            TextFormatting="{Binding YAxisFormat}" 
                            GrowBy="0.03, 0.03" 
                            AutoRange="Always"/>
        </s:SciChartSurface.YAxis>

        <s:SciChartSurface.ChartModifier>

            <s:ModifierGroup s:MouseManager.MouseEventGroup="SharedMouseGroup">

                <s:ZoomPanModifier IsEnabled="True" ReceiveHandledEvents="True" XyDirection="XDirection" ExecuteOn ="MouseLeftButton"/>
                <s:RubberBandXyZoomModifier IsEnabled="True" ReceiveHandledEvents="True" IsXAxisOnly="True" ExecuteOn="MouseRightButton"/>

            </s:ModifierGroup>
        </s:SciChartSurface.ChartModifier>



    </s:SciChartSurface>

</Grid>

  • bbmat asked 8 years ago
  • last active 8 years ago
0 votes
0 answers
16k views

Hello again. We have an application that has many tabs with scichart surface. Our goal is creating a report: screenshots of all scichart surfaces in tabs. But we found out, when scichartsurface was not active, all tick labels didn’t render on screenshots.
Here is our code snippet for creating screenshot:

double actualHeight = source.RenderSize.Height;
            double actualWidth = source.RenderSize.Width;
            double renderHeight = actualHeight * scale;
            double renderWidth = actualWidth * scale;

            RenderTargetBitmap renderTarget = new RenderTargetBitmap((int)renderWidth, (int)renderHeight, 96, 96, PixelFormats.Pbgra32);
            VisualBrush sourceBrush = new VisualBrush(source);
            DrawingVisual drawingVisual = new DrawingVisual();

            using (var drawingContext = drawingVisual.RenderOpen())
            {
                drawingContext.PushTransform(new ScaleTransform(scale, scale));
                drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
            }
            renderTarget.Render(drawingVisual);
            JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder();
            jpgEncoder.QualityLevel = quality;
            jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));

            Byte[] _imageArray;
            using (MemoryStream outputStream = new MemoryStream())
            {
                jpgEncoder.Save(outputStream);
                _imageArray = outputStream.ToArray();
            }
            return _imageArray;

How can we fix it?

Thanks in advance

  • Egor asked 8 years ago
0 votes
7k views

We currently have up to 4 charts that are stacked vertically and the data flows horizontally. However, we need to reverse it so that they are stacked horizontally and the data flows vertically. We currently have a grid setup for the charts to be set to but I can’t seem to figure out how to reset the Grid.Row and Grid.Column of each SciChartSurface at runtime.

Example:
Horizontally, this is how it looks…

<s:SciChartSurface x:Name="sciChartSurface1" Grid.Row="0" Grid.Column="1">

Vertically, it needs to be this…

<s:SciChartSurface x:Name="sciChartSurface1" Grid.Row="1" Grid.Column="0">

Is this possible to do at runtime/from the backend code?

1 vote
19k views

Hello,

Out team have several question about the framework:

  1. Is there a way to make SCIChartSurfaceView background transparent so that the user could see underlying views? We tried using background brush of clear color on SCIChartSurface and making SCIChartSurfaceView backgroundColor transparent but no avail.

  2. Is it possible to add translate/rotate/scale animation to markers/annotations from code?

  3. When using gradient brush with mountain renderable series we found a strange visual artifact (“Gradient artifact” image). Is there a way to fix it?

Best regards,
Vasiliy

0 votes
10k views

Hi,

I am developing a real-time application which needs multiple charts in some tab Items. I create a user control contain a ScichartSurface and RenderableSeries for each chart. Then apply this user Control as a list item of a list box in each tab. I inspired from 50-Channel EEG example.

The problem is the performance is too low and my tab items have a considerable delay on changing. So if I use one surface per tab item and use stacked YAxis to show series then does it make any difference?

Any insight would be much appreciate.

  • maryam zoj asked 4 years ago
  • last active 4 years ago
0 votes
0 answers
9k views

I use a similar multi-pane setup as your multi-pane stock chart demo and specify the ChartModifier within SciChartSurface.ChartModifier as follows:

<s:SciChartSurface.ChartModifier>
                        <s:ModifierGroup s:MouseEventGroup="SharedMouseGroup">
                            <s:RubberBandXyZoomModifier IsAnimated = "False" IsXAxisOnly = "True" ExecuteOn = "MouseRightButton"/>
                            <s:ZoomPanModifier XyDirection="XYDirection" ClipModeX = "ClipAtExtents" ExecuteOn ="MouseLeftButton" />
                            <s:MouseWheelZoomModifier XyDirection = "XYDirection"/>
                            <s:ZoomExtentsModifier IsAnimated = "False" ExecuteOn = "MouseDoubleClick" />
                            <s:CursorModifier SourceMode="AllSeries"  UseInterpolation="True" ShowAxisLabels="True"/>
                            <s:LegendModifier Name="GeneralLegend" ShowLegend="True" LegendPlacement ="Inside" GetLegendDataFor="AllSeries" Margin="10" LegendItemTemplate="{StaticResource LegendItemTemplate}"/>

                            <s:SeriesSelectionModifier ReceiveHandledEvents="True">
                                <s:SeriesSelectionModifier.SelectedSeriesStyle>
                                    <Style TargetType="s:BaseRenderableSeries">
                                        <Setter Property="StrokeThickness" Value="10"/>
                                    </Style>
                                </s:SeriesSelectionModifier.SelectedSeriesStyle>
                            </s:SeriesSelectionModifier>

                        </s:ModifierGroup>
                    </s:SciChartSurface.ChartModifier>

The problem I have is that the vertical chart modifier (a vertical line as part of the crosshair that vertically tracks the mouse cursor) is only visible within the respective pane where the mouse cursor is currently located at. When I move the mouse cursor onto another pane then the vertical line of the cross hair tracks in this different pane but only within this specific pane. I want the vertical line to be visible across all panes just like in your multi-pane stock chart demo. When I pan or zoom any of the panes then all panes are responding accordingly and in synchronized fashion, so I am sure the panes’ xaxis are all correctly linked to the primary xAxis.

What am I doing wrong?

Thanks

  • bbmat asked 9 years ago
  • last active 9 years ago
1 vote
15k views

I found a post on here regarding this topic but the link to the solution was a dead link.

I want to Autorange without affecting my zoom abilities. If I set AutoRange=”Always”, then I can’t zoom. If I set AutoRange=”Once”, then it does it the first time but I have to double click every time after that. What is the solution to this issue (This is an issue!). Fixing this would not be adding a new feature, it would be removing a problem within the code.

Edit: I think a solution would be to fire an event on DataSeries Changed. Is there an event that corresponds to this? I searched through the dependency properties and couldn’t find anything like that.

Edit: I used the Rendered event and called scichart.ZoomExtents(). I thought this would work, but it doesn’t resize properly either.

Edit: I want to add that I understand the use case for real time data, but I am looking at a snapshot. I can choose different snap shots but they don’t change once chosen. I need to update the range on each choice but then allow me to zoom in between.

Edit: I think that the scichart is being zoomed before the new dataseries is set. I can’t prove it, but that is what my gut tells me.

  • Ryan Woods asked 8 years ago
  • last active 8 years ago
0 votes
13k views

I want to handle mouse click event on ChartSurface. I need to detect when clicked on chart whether series was clicked or chartsurface was clicked. I handled previewmouseleftbutton on chartsurface but it is not giving clicked element information. Can you pls help?

  • KC asked 6 years ago
  • last active 6 years ago
Showing 51 - 58 of 58 results