The Surface plot is usually displayed in a 3D representation. The number of
points determines the width of the chart while the number of series determines
the depth of the chart. For example, if we want to display a 3D surface chart
with 10 Points and 10 Points per series with all values set to zero, it would
look like:

As depicted in the figure, you must now locate which data points you want to
change in order for the chart to start looking like a surface plot. For
example, if we change the value of the points and series highlighted in the
figure, the chart will look like:

In order to achieve the chart displayed in the figure shown above, your code
should look like:
chart1.setGallery(Gallery.SURFACE);
chart1.openData(COD.VALUES, 10, 10); for (int i=0;i<10;i++) for (int j=0;j<10;j++) chart1.setValue(i, j, 0);
chart1.setValue(1, 1, 9);
chart1.setValue(5, 8, 20);
chart1.setValue(7, 5, 15); chart1.closeData(COD.VALUES);
Surface mySurface = (Surface) chart1.getGalleryObj(); mySurface.setShowBorders(true);
chart1.getAxisY().setMax(20); chart1.getAxisY().setMin(-20); chart1.getAxisY().setStep(10);
chart1.setChart3D(true); chart1.setView3D(true); chart1.setAngleX(25); chart1.setAngleY(40);
|
Handling Level Colors
One of the most important settings in a surface plot is the level of detail that
the chart contains. Displaying different colors according to the value of each
data point increases the detail of the chart. The color will gradually change from the Color of
the first series to its AlternateColor.
Notice that although values have been set, the level of detail shown in the
chart may not be enough for the scale selected for the Y-axis (-20, 20).
What we need is the surface plot to show more colors according to the height of each
point.
To achieve this, simply change the step of the primary Y-axis to achieve the
level of detail you need in the surface plot. For example, in the figure shown
above the step has been set to 10, not allowing the surface to display enough
colors. However, changing the Step to 2 as follows will allow greater detail to
be displayed:
chart1.getAxisY().setStep(2);
|
An alternative way to do this is by using the axis MinorStep property to get a
gradual change in color without modifying axis Step:
chart1.getAxisY().setMinorStep(2);
|
The result can be seen in the next figure.

Automatic Labeling & Scaling
Because most surface and contour chart displays levels, we have included a way
to allow automatic point labeling according to a specific scale factor.
Setting the AutoCountourLabels property for the UserLegendBoxObj will
automatically assign legends based on the chart Step. When step is not
set, the legends will be automatically assigned with a best fit step chosen by
Chart FX for Java.
Note: When invoking this method, Chart FX will assign user legends indicating the color for each level in the
Contour Plot. So be aware that any user legend you previously had in the chart
will be erased when invoking this method.
When you invoke this method as follows:
chart1.setUserLegendBox(true); chart1.getUserLegendBoxObj().setAutoContourLabels(true);
|
A contour chart will look like:

|