/// <summary>
        /// Returns a color between begin and end color. The coff parameter must be in the range [0, 1].
        /// </summary>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <param name="coeff"></param>
        /// <returns></returns>
        public static NArgbColorValue InterpolateColors(NArgbColorValue begin, NArgbColorValue end, float coeff)
        {
            int a1 = (int)((begin.Value >> 24) & 0xff);
            int r1 = (int)((begin.Value >> 16) & 0xff);
            int g1 = (int)((begin.Value >> 8) & 0xff);
            int b1 = (int)(begin.Value & 0xff);

            int a2 = (int)((end.Value >> 24) & 0xff);
            int r2 = (int)((end.Value >> 16) & 0xff);
            int g2 = (int)((end.Value >> 8) & 0xff);
            int b2 = (int)(end.Value & 0xff);

            int a3 = a1 + (int)((a2 - a1) * coeff);
            int r3 = r1 + (int)((r2 - r1) * coeff);
            int g3 = g1 + (int)((g2 - g1) * coeff);
            int b3 = b1 + (int)((b2 - b1) * coeff);

            return(new NArgbColorValue((UInt32)((r3 << 16) | (g3 << 8) | b3 | (a3 << 24))));
        }
        private void UpdateData()
        {
            int dataPointCount = 0;

            switch (DataPointCountPerLineComboBox.SelectedIndex)
            {
            case 0:
                dataPointCount = 10000;
                break;

            case 1:
                dataPointCount = 100000;
                break;

            case 2:
                dataPointCount = 500000;
                break;
            }

            int    lineCount = (int)NumberOfLinesUpDown.Value;
            NChart chart     = nChartControl1.Charts[0];

            chart.Series.Clear();
            Random random = new Random();

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
            {
                // setup surface series
                NVertexSurfaceSeries surface = new NVertexSurfaceSeries();
                chart.Series.Add(surface);

                surface.Name = "Surface";
                surface.SyncPaletteWithAxisScale       = false;
                surface.PaletteSteps                   = 8;
                surface.ValueFormatter.FormatSpecifier = "0.00";
                surface.FillMode        = SurfaceFillMode.CustomColors;
                surface.FrameMode       = SurfaceFrameMode.Dots;
                surface.FrameColorMode  = SurfaceFrameColorMode.CustomColors;
                surface.VertexPrimitive = VertexPrimitive.LineStrip;
                surface.Data.UseColors  = true;
                surface.Data.SetCapacity(dataPointCount);

                double x = 0.1;
                double y = 0;
                double z = 0;
                double a = 10.0;
                double b = 18 + lineIndex;        // 28.0 - ;
                double c = (lineIndex + 3) / 3.0; //8.0
                double t = lineIndex * (0.01 / lineCount) + 0.01;

                NArgbColorValue color1 = new NArgbColorValue(palette.SeriesColors[lineIndex % palette.SeriesColors.Count]);
                NArgbColorValue color2 = new NArgbColorValue(palette.SeriesColors[(lineIndex + 1) % palette.SeriesColors.Count]);

                unsafe
                {
                    fixed(byte *pData = &surface.Data.Data[0])
                    {
                        float *pVertex = (float *)pData;
                        uint * pColor  = (uint *)(pData + surface.Data.ColorOffset * 4);

                        for (int dataPointIndex = 0; dataPointIndex < dataPointCount; dataPointIndex++)
                        {
                            float xt = (float)(x + t * a * (y - x));
                            float yt = (float)(y + t * (x * (b - z) - y));
                            float zt = (float)(z + t * (x * y - c * z));

                            pVertex[0] = xt;
                            pVertex[1] = yt;
                            pVertex[2] = zt;
                            *pColor = InterpolateColors(color1, color2, (float)((yt + 40.0) / 80.0)).Value;

                            pVertex += 4;
                            pColor  += 4;

                            x = xt;
                            y = yt;
                            z = zt;
                        }
                    }
                }

                // notify series that data has changed as we've modified it directly using pointers
                surface.Data.SetCount(dataPointCount);
            }

            nChartControl1.Refresh();
        }