.netchartssurfacenevron

Nevron surface chart data source


I have been looking at the above metioned chart and I am trying to figure out how their "FillData" method on the snippet below works.

private void FillData(NGridSurfaceSeries surface)
        {
            double y, x, z;
            int nCountX = surface.Data.GridSizeX;
            int nCountZ = surface.Data.GridSizeZ;

            const double dIntervalX = 30.0;
            const double dIntervalZ = 30.0;
            double dIncrementX = (dIntervalX / nCountX);
            double dIncrementZ = (dIntervalZ / nCountZ);

            z = -(dIntervalZ / 2);

            for(int j = 0; j < nCountZ; j++, z += dIncrementZ)
            {
                x = -(dIntervalX / 2);

                for(int i = 0; i < nCountX; i++, x += dIncrementX)
                {
                    y = (x * z / 64.0) - Math.Sin(z / 2.4) * Math.Cos(x / 2.4);
                    y = 10 * Math.Sqrt( Math.Abs(y) );

                    if(y <= 0)
                    {
                        y = 1 + Math.Cos(x / 2.4);
                    }

                    surface.Data.SetValue(i, j, y);
                }
            }
        }

The documentaion is extremely sparse, and I would like to pass list of value in place of "Y", but I do not know what the rest of the code is doing, if anybody here has worked with this please shoot.


Solution

  • Actually you need only the surface.Data.SetValue method, the rest of the code just generates some data. The Grid Surface data storage is like a 2 dimensional table – i and j are indices that specify a data point and y is the value of the data point. For example the following code fills some data in a 3x2 grid surface:

    // first row
    surface.Data.SetValue(0, 0, 7.53);
    surface.Data.SetValue(1, 0, 6.19);
    surface.Data.SetValue(2, 0, 9.78);
    
    // second row
    surface.Data.SetValue(0, 1, 5.35);
    surface.Data.SetValue(1, 1, 4.71);
    surface.Data.SetValue(2, 1, 8.85);
    

    I hope this helps.