# Step 2: Adding Data

## Content

**Chart3D for WPF** supports data values defined as a two-dimensional array of z-values where the first index corresponds to X and the second index corresponds to Y. One of the most common uses of a **Chart3D** is plotting 3D functions. Let's plot a function defined as the following:
`z(x,y) = x*x - y*y;`
`in the range`
`-1 <= x <= 1`
`-1 <= y <= 1`
To do this, follow these steps:

1. Select **View \| Code** in your project.
2. Add the following statement at the top of the page:

```csharp
using C1.WPF.Chart3D;
```

3. Add the following code to define the data:

```csharp
public MainWindow()
        {
            InitializeComponent();
            c1Chart3D1.Children.Clear();
            // create 2D array 10x10
            int xlen = 10, ylen = 10;
            var zdata = new double[xlen, ylen];
            double stepx = 2.0 / (xlen - 1);
            double stepy = 2.0 / (ylen - 1);
            // calculate function for all points in the range
            for (int ix = 0; ix < xlen; ix++)
                for (int iy = 0; iy < ylen; iy++)
                {
                    double x = -1.0 + ix * stepx; //  -1 <= x <= 1
                    double y = -1.0 + iy * stepy; //  -1 <= x <= 1
                    zdata[ix, iy] = x * x - y * y;
                }
            // create data series
            var ds = new GridDataSeries();
            ds.Start = new Point(-1, -1); // start for x,y
            ds.Step = new Point(stepx, stepy); // step for x,y
            ds.ZData = zdata; // z-values
            // add series to the chart
            c1Chart3D1.Children.Add(ds);
        }
```

In the next step you will change the appearance of the chart.

## See Also

[Step 3: Changing the Chart Appearance](/componentone/docs/wpf/online-chart3d/overview/getting-started/quick-start-chart3d-for-wpf-and-silverlight/Step3)