Surface series renders 2D density map. It uses ChartDataModel as its model. This series displays data as 2D image, where each pixel's color depends on a corresponding cell in a 2D matrix of double values.
Setting SurfaceSeries:
//Setting SurfaceSeries object named surfaceSeries where: // model is an instance of ChartDataModel and holds values that will be mapped SurfaceSeries surfaceSeries = new SurfaceSeries(model, new PlaneMapper2D()); |
Figure 4.1.3.1 Surface Series Demonstration
Null points in SurfaceSeries can be passed in data model either as Double.NaN or as null values. As the default color Color.WHITE will be designated to map Double.NaN and null values, so if you use Color.WHITE in you surface palette, you should set another color for null values, so that it would be possible to make that color transparent. For example:
surfaceSeries.getPaintStyle().setBackground(SurfacePaintTags.NULL,Color.yellow); |
There are two surface paint modes: SurfacePaintMode.DRAW_POLYGON_MAP and SurfacePaintMode.DRAW_IMAGE_MAP. DRAW_IMAGE_MAP is generally faster and doesn't have hot spots (image is rendered). DRAW_POLYGON_MAP is slower, but you don't need to specify color for the null points, since they are made automatically independent to your color palette. Also DRAW_POLYGON_MAP allows you to have hot spots. Here is how you can set the surface paint mode:
surfaceSeries.setSurfacePaintMode(SurfacePaintMode.DRAW_IMAGE_MAP); |
Surface color palette can be set using ColorPalette enumeration accordingly, where 12 is number of colors to use:
surfaceSeries.setColorPalette(ColorPalette.DEFAULT_SURFACE_PALETTE, 12); |
If there are some data values that are missing, but there is a need to interpolate them, Double.NaN must be set to data model and interpolation enabled.
Setting interpolation:
surfaceSeries.setInterpolationEnabled(true); |