A MapChartModel can control how map regions are treated when there are no corresponding response (Color) values associated with them. By default, only regions that have associated data are shown.
![]() |
![]() |
To show regions without data, use the setEmptyPolicy() method. The default value is GraphConstants.AUTOMATIC, which behaves the same as GraphConstants.FALSE. A TRUE value for the policy indicates that the empty regions are to be shown.
The following code fragment tells the MapChart to show all of the regions, regardless of whether they have associated data:
MapChartModel graphModel=mapChart.getGraphModel();
graphModel.setEmptyPolicy(com.sas.graphics.GraphConstants.TRUE);
Like the Empty Policy, the MapChartModel can control how regions with Missing values are treated. By default, only regions with non-missing values are charted. In other words, missing-value regions are treated as an Empty region. They adhere to the Empty Policy setting.
![]() |
![]() |
For example, assume the response data have missing values for West Virginia and Kentucky. By default, the Empty Policy is FALSE and those regions do not appear in the map. To display those regions, set the missing policy to TRUE.
MapChartModel graphModel=mapChart.getGraphModel();
graphModel.setMissingPolicy(com.sas.graphics.GraphConstants.TRUE);
The MapChartModel can be used to change a map chart's general display properties, as shown in the following example:
MapChart mapChart = new MapChart();
MapChartModel mapChartModel = mapChart.getGraphModel();
// Change the map region outline color
mapChartModel.getDataElementStyles().getOutlineLineStyle().setColor(Color.blue);
// Define a new set of solid fills for the
// region elements to be [red, green, blue].
FillStyles[] fillStyles = new FillStyles[] {
new FillStyle(Color.red)
, new FillStyle(Color.green)
, new FillStyle(Color.blue)
};
mapChartModel.getDataElementStyles().setFillStyles(fillStyles);
Note: The MapChart does not support gradient fills.
Rather than changing individual properties, it may be easier to use the MapChart to set a graph style, which makes it easier to manage multiple display properties.
A MapChartModel can be used to modify the line style (color, width, visibility, etc.) of any of the various lines in a MapChart.
The following table shows the lines you can set and the method(s) to call to access and/or set the line attributes.
| To change ... | Call ... |
|---|---|
| map region outlines | getDataElementStyles().setOutlineLineStyle(LineStyle) |
| legend frame | getLegendModel().setFrameLineStyle(LineStyle) |
| column axis lines (available when ColumnVariable role is used) |
getColumnAxisModel().setFrameLineStyle(LineStyle) |
| row axis lines (available when RowVariable role is used) |
getRowAxisModel().setFrameLineStyle(LineStyle) |
| frame lines around column/row cells
(available when ColumnVariable and/or RowVariable roles are used) |
setFrameLineStyle(LineStyle) |
The following code fragment specifies a 3-point red line for region outlines:
MapChartModel graphModel=mapChart.getGraphModel();
LineStyle lineStyle=new LineStyle(
java.awt.Color.red,
new com.sas.measures.BaseLength(3, "pt"),
com.sas.components.GraphConstants.TRUE);
graphModel.getDataElementStyles().setOutlineLineStyle(lineStyle);
A MapChartModel can be used to modify the line style (color, width, visibility, etc.) and fill style (texture, solid fill of any of the various lines in a MapChart. By default, the empty outlines will inherit their properties from the data element styles outline properties. The empty fill style will be non-visible by default.
Note: The MapChart does not support gradient fills.
The following table shows how to change the empty region attributes:
| To change ... | Call ... |
|---|---|
| empty region outlines | setEmptyOutlineLineStyle(LineStyle) |
| empty region fills | setEmptyFillStyle(FillStyle) |
The following code fragment specifies a gray line for empty region outlines and turns on the fill style for empty regions:
MapChartModel graphModel=mapChart.getGraphModel();
LineStyle ls = new LineStyle( java.awt.Color.gray );
graphModel.setEmptyOutlineLineStyle( ls );
graphModel.getEmptyFillStyle().setVisibility( true );
Warning: getEmptyOutlineLineStyle() may return null. In the case that the empty Line Style is null, it means that it will inherit its Line Style properties from the DataElementStyles.
MapChartModel properties are bound properties. Modifying a property triggers a PropertyChangeEvent. The MapChart asynchronously updates when a PropertyChangeEvent is received from the MapChartModel. Similarly, modifying a property in any of the MapChartModel's contained models triggers a PropertyChangeEvent. A PropertyChangeEvent from contained models will bubble up to cause a PropertyChangeEvent to be fired from the MapChartModel.
For example, the following call
mapChartModel.getEmptyOutlineLineStyle().setColor(java.awt.Color.yellow);
would cause the empty outline's line style model to fire a "color" PropertyChangeEvent, causing graph model to fire a "valueTextStyle" PropertyChangeEvent, causing the MapChartModel to fire a "legendModel" PropertyChangeEvent. This bubbling up of events enables the graph or any other listener to manage updates at a higher level of containment.