- Oracle APEX Cookbook(Second Edition)
- Marcel Van Der Plas Michel Van Zoest
- 524字
- 2021-07-23 15:34:37
Creating a map chart>
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.
Getting ready
First we need to have a structure ready in our database tables that holds at least one geography-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.
How to do it...
Our starting point is again an empty page. The first thing to do is to add a new region.
- Right-click on Regions and select Create.
- Select Map as the Region Type.
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 United States of America and click on Next:
- In the following list select click on the + sign to open Country Maps and click on States:
- Enter Contacts by State for the title and leave the rest with their default values and click on Next.
- Enter the same text as the Map Title.
- Enter the following query in the appropriate SQL Query area:
select null link , STATE label , COUNT(CONTACT_ID) value from APP_VW_CONTACTS group by STATE [9672_01_06.txt]
- Click on Create Region.
- Run the page to see the result:
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.
How it works...
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 functionalities.
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).
There's more...
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.
- 物聯網與北斗應用
- Aptana Studio Beginner's Guide
- 自動駕駛網絡:自智時代的網絡架構
- 智能網聯汽車V2X與智能網聯設施I2X
- Yii Application Development Cookbook(Second Edition)
- Working with Legacy Systems
- 紅藍攻防:構建實戰化網絡安全防御體系
- 網絡利他行為研究:積極心理學的視角
- 數據血緣分析原理與實踐
- 現代通信系統(第5版)
- Qt5 Python GUI Programming Cookbook
- Web用戶查詢日志挖掘與應用
- Building RESTful Web Services with .NET Core
- 世界互聯網發展報告2021
- 物聯網