A new type of chart available in Application Express 4.0 is the map chart. This allows users to present data on a geographical map. APEX 4.0 offers many maps from a world overview to maps of single countries.
Map charts allow applications a new way to visualize location-related data without much programming.
In this recipe, we will show you how to create a map that lists all contacts in the United States by state.
First we need to have a structure ready in our database tables that holds at least one geographical related column (for example, country, state, or province names). This will be the pointer for our chart to which it can relate its map.
For this recipe, we will reuse the APP_VW_CONTACTS
view. This view holds a column called STATE
that we can use in our chart.
Our starting point is again an empty page. The first thing to do is to add a new region.
This will bring up a window with a couple of main categories of maps. Selecting one of these categories will bring up a list of sub-categories that can be drilled-down even further.
select null link , STATE label , COUNT(CONTACT_ID) value from APP_VW_CONTACTS group by STATE [1346_01_06.txt]
As we can see, each state that contains one or more contacts is highlighted. APEX also generates labels containing the state name and number of contacts if there is room for it. The other labels can be viewed by hovering over the state with the mouse pointer.
Application Express uses AnyChart 5 for displaying its charts. This is different from earlier versions of APEX, so migrating applications that make use of charts from version 3.x to 4.0 is a little more complicated than migrating other functionality.
When using a Map chart it is important that a column for the label is used that contains the name of the geographical region that you want highlighted on the map. For the standard maps provided by APEX, it's not allowed to use abbreviations, but it has to be the full name (for example, New York instead of NY and Virginia instead of VA).
Just like any other chart type it is possible to create links to other pages. This can be used to create, for instance, a drill down type of structure. We could create a series of pages from a world map, to a continent map, to a country map, and so forth.
How such a link can be created is explained in the chart recipe before this one.
3.145.177.39