Large number of line series?

Need help in implementing some specific function to your LightningChart Ultimate powered application? Post a question and get code snippets from other LightningChart Ultimate community members.

Moderator: Queue Moderators

Post Reply
hariselio
Posts: 2
Joined: Fri Jun 30, 2017 11:48 am

Large number of line series?

Post by hariselio » Fri Jun 30, 2017 12:12 pm

I'm trying to create 10000 pointlineseries with 1000 points each, but i couldn't succeed in creating the chart. I tried wpf non-bindable and winform version, both takes several GB of memory and takes ages. So i had to terminate the process. I guess i'm doing something wrong? Any hints how to achieve this? For reference, my old library is C1 which creates the chart in ~5 minutes time with usage of ~500MB memory. These memory calculations are just rough one which shown in the task manager.

Thanks in advance.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Large number of line series?

Post by ArctionPasi » Fri Jun 30, 2017 1:56 pm

Hi Hariselio,

Here's Winforms example... appears within a couple of seconds in my system.

When having lots of series, keep LegendBox visible = false.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Arction.WinForms.Charting;
using Arction.WinForms.Charting.Views.ViewXY;
using Arction.WinForms.Charting.SeriesXY;
using Arction.WinForms.Charting.Axes; 

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        LightningChartUltimate _chart;
        Random _rand = new Random();

        public Form1()
        {
            InitializeComponent();

            _chart = new LightningChartUltimate();
            _chart.Parent = this;
            _chart.Dock = DockStyle.Fill;
            
            _chart.BeginUpdate();

            ViewXY v = _chart.ViewXY;

            AxisX xAxis = v.XAxes[0];
            AxisY yAxis = v.YAxes[0];
            
            v.LegendBoxes[0].Visible = false;

            List<PointLineSeries> list = new List<PointLineSeries>(); 

            for (int seriesIndex = 0; seriesIndex < 10000; seriesIndex++)
            {
                PointLineSeries pls = new PointLineSeries(v, xAxis, yAxis);
                pls.LineStyle.Color = DefaultColors.SeriesForBlackBackground[seriesIndex % DefaultColors.SeriesForBlackBackground.Length];
                pls.LineStyle.Width = 1;
                pls.LineStyle.AntiAliasing = LineAntialias.None;
                pls.ShowInLegendBox = false;
                pls.PointsVisible = false;
                pls.MouseInteraction = false; 
                pls.Points = GeneratePoints(seriesIndex);
                list.Add(pls); 
            }
            v.PointLineSeries.AddRange(list); 

            xAxis.SetRange(0, 1000);
            yAxis.SetRange(0, 1500);

            _chart.EndUpdate(); 
        }

        SeriesPoint[] GeneratePoints(double baseLevel)
        {
            int count = 1000;
            SeriesPoint[] points = new SeriesPoint[count];

            for (int i = 0; i < count; i++)
            {
                points[i].X = i;
                points[i].Y = baseLevel +(_rand.NextDouble() -0.5)* 10.0; 
            }
            return points;
        }
    }
}

LightningChart Support Team, PT

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Large number of line series?

Post by ArctionPasi » Mon Jul 03, 2017 11:48 am

The data point arrays themselves take approx. 240 MB. If preferring low memory footprint, replace PointLineSeries with SampleDataSeries. Set SampleFormat = SingleFloat. Data array memory requirement will drop from 24 bytes / data point to 4 bytes / data point.

Also setting series.LineStyle.Width = 1 will drop memory requirement.
LightningChart Support Team, PT

hariselio
Posts: 2
Joined: Fri Jun 30, 2017 11:48 am

Re: Large number of line series?

Post by hariselio » Tue Jul 04, 2017 5:39 am

thanks, I did try sample data series with line width =1 and anti alias is false. memory consumption is less, but still around 1GB for maximized full screen view. Also noticed, the memory usage is getting increased for every resize of the plotting window and most of the time, it does not reduce after redrawing is completed. For eg, when i first start the application in maximized state, the usage is around 800MB, but after couple of resizing, the usage stands around 1GB.

Another thing noticed in my machine, when i run sample application which uses lightening chart, the overall system feels very sluggish. Looks like cause of parallelization? Is there a way to set how many maximum parallel cores can be used by lightening chart?

Also as mentioned in my mail to support, there are too many sharpdx exceptions when anti-aliasing is enabled and no plotting happens. I understand, that no use in setting anti-aliasing when so many series has been shown. But we may need this, when some part of the series is zoomed in.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: Large number of line series?

Post by ArctionPasi » Tue Jul 04, 2017 6:29 am

Hello,

LC uses lots of parallel computation, and it will bog down the CPU in this kind of application with that many series. Max core count can be configured only from LC source code, it's defined as constant there. Currently it is 'All available cores'.

Another reason for sluggishness is GPU. It has to calculate about 10000 x 1000 = 10M line segments. And calculate pixels from them by using interpolation between line end points. You need a fast GPU for this app.

To disable antialiasing totally, set chart.RenderOptions.AntialiasLevel = 0.

What comes to memory, the DirectX scene itself takes about 200 MB memory. Then vertex buffers have to be allocated etc. Take they lots of memory. I think there no way to run this app under 600 MB. Memory management of .NET and garbage collection will drop the process size when ever it sees necessary. It doesn't happen instantly...
LightningChart Support Team, PT

Post Reply