Chart / Charts / Chart Types / Cartesian / Series / Fast Series / Fast Series Overview
In This Topic

    Fast Series Overview

    In This Topic

    NOV Chart for .NET contains several series types that are specifically optimized for the display of large amounts of data using the GPU. These series are referred to as Fast Series in the documentation. The set of fast series currently includes the NFastBarSeries, NFastLineSeries, NFastPointSeries, and the different surface series types (NGridSurfaceSeries, NMeshSurfaceSeries, NTriangulatedSurfaceSeries and NVertexSurfaceSeries.

    The common in those series is the way data is organized and stored in memory to facilitate efficient rendering on the GPU. The data of the fast series is organized in memory blocks that have one or more data channels. The data for those channels is stored interleaved in the chart memory. The following picture shows how some sample data for a series containing three data points with XY values and a color per data point is stored in memory:

     Adding Data With Managed Code

    The different fast series have several methods that allow you to add data to the series using managed code. These functions usually contain the name of the data channel and the data to add to this data channel for a specific data point index. For example, SetValue will modify the Y value at the specified index, whereas SetXValue will modify the X value respectively.

    Copy Code
    NFastLineSeries fastLineSeries = new NFastLineSeries();
    chart.Series.Add(fastLineSeries);
    fastLineSeries.Data.HasXValues = true;
    fastLineSeries.Data.HasColors = true;
    fastLineSeries.Data.SetCount(3);
    fastLineSeries.Data.SetXYValue(0, 0, 0);
    fastLineSeries.Data.SetXYValue(1, 1, 1);
    fastLineSeries.Data.SetXYValue(2, 2, 2);
    fastLineSeries.Data.SetColor(0, NColor.Red);
    fastLineSeries.Data.SetColor(1, NColor.Green);
    fastLineSeries.Data.SetColor(2, NColor.Blue);
    
     Adding Data Using Unmanaged Code

    You can also add data to fast series by directly manipulating the data channels contained in its memory block. This involves using unmanaged code so your application must have "Allow Unsafe Code" checked in the project build settings. The following code shows how to add the same data as in the previous example to a fast line series but this time using unmanaged code:

    Copy Code
    NCartesianChart chart = (NCartesianChart)nChartViewWithRibbonControl1.View.Surface.Charts[0];
    NFastLineSeries fastLineSeries = new NFastLineSeries();
    chart.Series.Add(fastLineSeries);
    fastLineSeries.Data.HasXValues = true;
    fastLineSeries.Data.HasColors = true;
    fastLineSeries.Data.SetCount(3);
    unsafe
    {
        fixed (byte* pData = &fastLineSeries.Data.Data[0])
        {
            int dataItemSize = fastLineSeries.Data.DataItemSize;
            float* pXValues = (float*)fastLineSeries.Data.GetDataChannelPointer(ENSeriesDataChannelName.XValueF, pData);
            float* pYValues = (float*)fastLineSeries.Data.GetDataChannelPointer(ENSeriesDataChannelName.YValueF, pData);
            uint* pColors = (uint*)fastLineSeries.Data.GetDataChannelPointer(ENSeriesDataChannelName.Color, pData);
            // add x values
            *pXValues = 0;
            pXValues += dataItemSize;
            *pXValues = 1;
            pXValues += dataItemSize;
            *pXValues = 2;
            pXValues += dataItemSize;
            // add y values
            *pYValues = 0;
            pYValues += dataItemSize;
            *pYValues = 1;
            pYValues += dataItemSize;
            *pYValues = 2;
            pYValues += dataItemSize;
            // add colors
            *pColors = 0xFF0000FF;
            pColors += dataItemSize;
            *pColors = 0xFF00FF00;
            pColors += dataItemSize;
            *pColors = 0xFFFF0000;
            pColors += dataItemSize;
        }
    }
    fastLineSeries.Data.OnDataChanged();
    
     Shader Rendering

    All fast series rendering by default is performed using OpenGL shaders. This means that logical-to-view coordinate transformations, colors, normals, lighting effects, etc . are performed through a custom vertex, geometry, and fragment pipeline. This offloads the CPU from many calculations and is in most cases faster than normal rendering in which the control uses the fixed OpenGL pipeline. In cases when you want to revert to the fixed pipeline you can turn off shader rendering using:

    Copy Code
    someFastSeries.EnableShaderRendering = false;
    
    See Also