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

0 votes
89 views

Hi,

IĀ“ve encountered following problem. My application should visualize variables of a machine. The user can select those variables an organize them in goups. For each group a SciChartSurface should be visualized with the selected variable as DataSeries.

Therefore I created a ViewModel for those groups. Holding them in a ObservableCollection wich is bound to an ItemsControl:

<ItemsControl
        Grid.Row="1"
        Grid.Column="1"
        Grid.ColumnSpan="6"
        HorizontalContentAlignment="Stretch"
        VerticalContentAlignment="Stretch"
        PreviewMouseWheel="XAxis_MouseWheel"
        PreviewMouseUp="ListView_OnMiddleMouseUp"
        d:PreviewKeyDown="ListView_OnPreviewKeyDown"
        d:PreviewKeyUp="ListView_OnPreviewKeyUp"
        ItemsSource="{Binding ChartViewModels}"
        >
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="1"/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="traceControl:ChartViewModel">
                <Grid
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    >

                    <s:SciChartSurface Loaded="ChartSurface_Loaded" 
                                       Unloaded="ChartSurface_Unloaded"
                                       Background="White"

                                       >

                      <!-- Some other stuff is also in here, modifiers and axissetup -->

                    </s:SciChartSurface>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>

    </ItemsControl>

There is a Refresh-Action. It does clearing the the ViewModel Collection and creating new ViewModels depending on the configuration and fill them in the ViewModel Collection.

If both actionparts (clearing and filling data) were executed together in for example the ICommand of a button, the memory footprint is increasing each time the refresh button is hit.

If the actionparts were executed one by one, e.g. a clear button and a fill button, everything is fine.

Do I miss something?

Thanks in advance!

Markus

p.s. I was not allowed to add Screenshots of dotMemory

0 votes
116 views

The issue I’m having is that I seem to be running out of memory for 3D charts after a certain data size. What I will see is either my chart never renders at all or on occasion the entire application will crash (due to accessing out of bounds memory in the native dlls.)

I am using a SurfaceMeshRenderableSeries3D with a UniformGridDataSeries3D(int, float, int). With smaller sizes such as 320×240 (X,Z) I get results, but larger sizes such as 640×480 (X,Z).

This issue only seems to happen when compiling to 32-bit. I have seen the other questions regarding how AnyCPU is compiling to 32-bit. Some of our customers have to use 32-bit so I would like to know what the expected footprint is to hopefully try and work around it.

Thanks!

0 votes
333 views

Hi,
some time ago we update our application used WPF chart v 3.1 to version 4.2.2.9744. Now we realize that the application uses much more memory as before, sometimes it doubles the memory usage. The worst issue is that memory is not release aver after unloading the data series and even after closing the Tab which contains the Chart. Because we need to deploy the Application even on pc with 2 GB RAM it becomes an issue for us. Please advise what could we check to make sure memory will be released after unloading the data series and closing the tab with chart.

0 votes
401 views

Is there a way to make a screenshot from a chart without drawing the chart on screen?

I am making an application that will send an E-mail with alot of extra info, one of the attachements is a chart.
The application is running in a Windows service, so showing the chart to take a screenshot is not the way to go.

When I am sending the email I want to take the following steps:

  1. Get the data
  2. Render the data in memory (not on screen).
  3. Create an image of the chart.
  4. Include this image in my E-mail.

Can someone tell me if this is a possibility and how I can do this?

  • Kevin Goos asked 10 months ago
  • last active 10 months ago
1 vote
531 views

I am testing scichart and want to plot as much data as possible on a memory constrained system.

Our data is equi-time with no gaps in any of the series. It seems very memory wasteful to have to store an x value per data point per series when these could just be directly infered from the index of the point, this would allow memory usage to be halved.

Is it possible to achieve something similar to this in scichart.

Side question if I have a number of series that all share x values is it possible to use one set of x data for multiple series without it being duplicated in memory.

  • Hugoagogo asked 1 year ago
  • last active 1 year ago
0 votes
0 answers
2k views

Have a good day!

We are working with scichart render context to create 2d sprite. We have already optimized our code, but there is still problem.
When we put annotation, where we bind our image, outside the function, the image stops rendering. We’ve made that you had told us to do in previous post
( https://www.scichart.com/questions/question/memory-usage-part-2 ), but it doesn’t make a sense. We’ve found out that when we create
this annotation inside the function and when we pan the image it takes too many memory resources. It is caused by creating many annotations of this type
and therefore there is queue to the garbage collector. That’s why our goal is to put this annotation outside the function and just change image that is binded
to the annotation. Is there any way to solve it?

Code snippets:

Annotation outside the function (image shows, but doesn't render, it takes less memory)

        BackgroundImageAnnotation backgroundImage = null;

        private void OnRedrawWellSection(object sender, IRenderContext2D e)
        {
            e.Clear();
            e.SetPrimitvesCachingEnabled(false);
            double density;                        
            double density1;                        
            var minThltest = (double)SciChartSurface.XAxis.VisibleRange.Min;
            var maxThlTest = (double)SciChartSurface.XAxis.VisibleRange.Max;
            var minTvdTest = -2000;
            var maxTvdTest = -700;
            var xCalc = SciChartSurface.XAxis.GetCurrentCoordinateCalculator();
            var yCalc = SciChartSurface.YAxis.GetCurrentCoordinateCalculator();

            density = SciChartSurface.GridLinesPanel.Height/(double) SciChartSurface.YAxis.VisibleRange.Diff;

            density1 = SciChartSurface.GridLinesPanel.Width/(double)SciChartSurface.XAxis.VisibleRange.Diff;

            using (SciChartSurface.SuspendUpdates())
            {
                if (backgroundImage == null)
                {
                    backgroundImage = new BackgroundImageAnnotation
                    {
                        CoordinateMode = AnnotationCoordinateMode.Relative,
                        X1 = 0,
                        Y1 = 0,
                        AnnotationCanvas = AnnotationCanvas.BelowChart,
                    };
                }

                var mainWindow = Application.Current.MainWindow;
                var source = PresentationSource.FromVisual(mainWindow);
                if (source == null || source.CompositionTarget == null) return;

                var width = (int)SciChartSurface.ActualWidth;
                var height = (int)SciChartSurface.ActualHeight;
                if ((int)SciChartSurface.ActualWidth == 0)
                    width = 1;
                if ((int)SciChartSurface.ActualHeight == 0)
                    height = 1;
                WriteableBitmap writeableBmp = BitmapFactory.New(width, height);
                var color = Colors.Blue;
                for (double i = minTvdTest; i < maxTvdTest; i=i+density)
                {
                    var t1 = (int) xCalc.GetCoordinate(minThltest);
                    var t2 = (int) yCalc.GetCoordinate(i);
                    var t3 = (int) xCalc.GetCoordinate(maxThlTest);
                    var t4 = (int) yCalc.GetCoordinate(i);
                    if (i<-1500)
                    {
                        color = Colors.Green;
                    }
                    else
                    {
                        if (i<-1000)
                        {
                            color = Colors.Red;
                        }
                        else
                        {
                            color = Colors.Orange;
                        }
                    }
                    writeableBmp.DrawLineBresenham(t1, t2, t3, t4, color);
                }
                backgroundImage.ImageSource = writeableBmp;
                var sprite = e.CreateSprite(backgroundImage);
                e.DrawSprite(sprite, new Rect(0, 0, width, height), new Point(0, 0));
                e.Layers.Flush();
                writeableBmp = null;
                backgroundImage.ImageSource = null;
                e.DisposeResourceAfterDraw(sprite);
            }
        }

Annotation inside the function (image shows, renders, but when we pan, it takes many resources and it doesn’t invoke destructor at once)

// We put the declaration of annotation in the function scope
// BackgroundImageAnnotation backgroundImage = null;

private void OnRedrawWellSection(object sender, IRenderContext2D e)
{
    e.Clear();
    e.SetPrimitvesCachingEnabled(false);
    double density;                        
    double density1;                        
    var minThltest = (double)SciChartSurface.XAxis.VisibleRange.Min;
    var maxThlTest = (double)SciChartSurface.XAxis.VisibleRange.Max;

    ...

    using (SciChartSurface.SuspendUpdates())
    {

        BackgroundImageAnnotation backgroundImage = null;
        if (backgroundImage == null)
        {
            backgroundImage = new BackgroundImageAnnotation
            {
                CoordinateMode = AnnotationCoordinateMode.Relative,
                X1 = 0,
                Y1 = 0,
                AnnotationCanvas = AnnotationCanvas.BelowChart,
            };
        }

        var mainWindow = Application.Current.MainWindow;
        ....
  • Egor asked 2 years ago
0 votes
2k views

Hello again!
In addition to the ticket https://www.scichart.com/questions/question/memory-usage-1

I’ve modified my project to run faster. I’ve put BackgroundImageAnnotation, from which we create sprite, outside the function. But when I run the application, the image freezes and doesn’t redraw.
What is the reason? And how can I fix it?

I’ve attached modified project below.
Link: https://yadi.sk/d/TSsZuDTbipP7y

  • Egor asked 2 years ago
  • last active 2 years ago
0 votes
3k views

In my application I remove lines from SciChartSurface, but Resharper still shows that data not removed from memory.
How completely remove from memory, that GC would collect it?

Edited:

I found smth strange, don’t even know if it’s my issue or not.
The structure shows what keeps my data alive.

using (sciChart.SuspendUpdates())
                {
                    for (var i = 0; i < pavadinimai.Count; i++)
                    {
                        if (pavadinimai[i] != null)
                        {
                            this.Dispatcher.Invoke((Action)(() =>
                            {
                                var sarasas = new List<Duomenys>(LinijuSarasas);
                                var line = sarasas.SingleOrDefault(p => p.Linija.Name == pavadinimai[i]);
                                try
                                {
                                        string pavadin = pavadinimai[i];
                                        var Ynauj = Ynauji[i].Select(p => (double)p).ToList();
                                        line.XyAsiesTaskai.Append(Xnauji, Ynauj);
                                }
                                catch (Exception e)
                                {
                                    MessageBox.Show(e.ToString());
                                }
                            }));
                        }
                    }
                }

And

var asis = asiesNr.ToString();
            using (sciChart.SuspendUpdates())
            {
                for (var i = 0; i < YdtSeries.Count; i++)
                {
                    if (pavadinimai[i] != null)
                    {
                        var dataSeries = MasyvasIXySeries(XdtSeries, YdtSeries[i], pavadinimai[i]);
                        var rnd = new Random().Next(0, 10);
                        var Fast = new FastLineRenderableSeries() { SeriesColor = spalvuMasyvas[i], DataSeries = dataSeries, Name = pavadinimai[i], YAxisId = asis, StrokeThickness = 1 };
                        PridetiLinijaPrieSaraso(dataSeries, asiesNr, asis, Fast, true, false);
                        sciChart.RenderableSeries.Add(Fast);
                        //sciChart.ZoomExtents();
                    }
                }
            }
0 votes
3k views

Have a good day.

I’m working with scichartsurface, where I’m drawing a lot of lines with the help of IRenderContext2D. I’ve found out that this way of drawing took too much memory. For example when I displayed only surface, it took only ~80 Mb (Image 1), but when I displayed the graph using checkbox, began to scroll and pan my graph, the usage of memory increased to ~160 Mb (Image 2).
What is the reason of such behaviour?

Thanks in advance

I’ve attached the project: https://yadi.sk/d/cYP6RFVXhfjRS

  • Egor asked 2 years ago
  • last active 2 years ago
Showing 9 results
This template supports the sidebar's widgets. Add one or use Full Width layout.
SciChart WPF v5 is here! Use the discount code SCICHARTV5 to get 15% off WPF Charts until December 31st!Read More
+