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 NFastAreaSeries, NFastBarSeries, NFastLineSeries, NFastPointSeries, and the different surface series types (NGridSurfaceSeries, NMeshSurfaceSeries, NTriangulatedSurfaceSeries and NVertexSurfaceSeries.

     Controlling the Filling

    The fast series filling from the ShowFill property and FillColorMode properties . When ShowFill is  to true (the default) the type of filling displayed by the series is controlled by the combination of FillColorMode, Fill and Palette properties of the properties in the same way as described in the Surface Series Overview topic.

     Controlling the Stroke

    Frame rendering in fast series is supported only by the NFastLineSeries, as the other series types display only the filled objects. Line visibility is controlled by the ShowFrame property. When ShowFrame is  set to true (the default), the stroke rendered by the line series is determined by the combination of the FrameColorModeStroke and Palette properties of the properties in the same way as described in the Surface Series Overview topic.

     Series Memory Organization

    The common aspect across these series is the way data is organized and stored in memory to enable efficient GPU rendering. Data in the FastSeries is organized into memory blocks containing one or more data channels. The data for these channels is stored in an interleaved format within the chart memory. The following figure illustrates how sample data for a series containing three data points with XY values and a per–data point color is stored in memory:

    The Fast Series support two ways of adding data - using managed and unmanaged code (which is recommended only when performance is critical).

    Adding Data Using Managed Code

    The different FastSeries provide several methods for adding data using managed code. These methods typically include the name of the data channel along with the value to be assigned for a specific data point index. For example, SetValue modifies the Y value at the specified index, while SetXValue modifies the corresponding X value.

    C#
    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 the FastSeries by directly manipulating the data channels in its memory block. This requires the use of unmanaged code, so the first step is to ensure that the Allow Unsafe Code option is enabled in your project’s build settings. The following code shows how to add the same data as in the previous example to a FastLineSeries, this time using unmanaged code:

    C#
    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();
    
    It is important to call the data object OnDataChanged method to notify the series that the data has changed so that the control can repaint.
     Shader Rendering

    By default, all FastSeries rendering is performed using OpenGL shaders. This means that logical-to-view coordinate transformations, colors, normals, lighting effects, and other calculations are handled through a custom vertex, geometry, and fragment pipeline. This approach offloads many computations from the CPU and is, in most cases, faster than standard rendering, which uses the fixed OpenGL pipeline. If you need to revert to the fixed pipeline, you can disable shader rendering using:

    Copy Code
    someFastSeries.EnableShaderRendering = false;
    
    See Also