Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Oracle APEX Cookbook : Second Edition

You're reading from   Oracle APEX Cookbook : Second Edition Get straight into developing modern web applications, including mobile, using the recipes in this brilliant cookbook for Oracle Application Express (APEX). From the basics to more advanced features, it's a reference book and guide in one.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher
ISBN-13 9781782179672
Length 444 pages
Edition Edition
Languages
Arrow right icon
Toc

Table of Contents (21) Chapters Close

Oracle APEX Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Creating a Basic APEX Application 2. Themes and Templates FREE CHAPTER 3. Extending APEX 4. Creating Websheet Applications 5. APEX Plug-ins 6. Creating Multilingual APEX Applications 7. APEX APIs 8. Using Web Services 9. Publishing from APEX 10. APEX Environment 11. APEX Administration 12. Team Development 13. HTML5 and CSS3 14. Mobile Index

Creating a chart


In many reports it's required to show some (or all) of the figures in charts. This will give users the opportunity to quickly see the data and possibly take actions accordingly.

This recipe will show how to create a chart and some possibilities to configure them.

Getting ready

In the earlier recipes, we created the regions while building a new page. Of course, it's also possible to add regions on existing pages. To do so in this example, first prepare an empty page which will hold the region with the chart.

How to do it...

  1. Create a new region by right-clicking on the Regions label and choose Create.

  2. Select Chart and click on Next.

  3. Choose Flash chart and click on Next.

  4. Select Pie & Doughnut and click on Next.

  5. Select 3D Pie and click on Next.

  6. Enter Employees in a department in the title, leave the other fields with the default values and click on Next.

  7. Enter Employees in a department in the Chart title, leave the other fields the default values and click on Next.

    We are going to select all employees per department, so we will enter a query that will get us that data into the chart.

  8. Enter the following query into the SQL Query field:

    select null link
         , dept.name label
         , COUNT(emp.ID) value1
      from APP_EMPLOYEES emp
         , APP_DEPARTMENTS dept
     where emp.dept_id = dept.id
     group by dept.name
    [9672_01_04.txt]
  9. Click on Create Region.

  10. Run the page.

The page shows a graphical representation of the number of employees in each department:

There's more...

There are a number of possibilities to change and enhance this chart. Besides the 3D pie we have created here, there are dozens of other chart types. But there is a catch. Once a chart is created, the number of types it can be changed to is limited. When we would like to use a completely different chart type, the chart region has to be re-created.

This recipe can be easily expanded with a link to another page which can be clicked inside the chart.

To do this, first navigate to the Chart Series by expanding the tree view under the Chart region or by clicking on the edit link in the chart properties page. Edit the query on which the chart is based and change the first column. If we, for example, would have a page with ID 888, a query with a link to that page would look like the following:

select 'f?p=&APP_ID.:888:&APP_SESSION.::NO::P888_DEPT_ID:'||dept.id link
     , dept.name label
     , COUNT(emp.ID) value1
  from APP_EMPLOYEES emp
     , APP_DEPARTMENTS dept
 where emp.dept_id = dept.id
 group by dept.name, dept.id
[9672_01_05.txt]

We have chosen to show a dynamically generated link here. A few of the parameters need an explanation:

  • APP_ID is the ID for this application.

  • APP_ SES SION is the ID for the current session.

  • P888_DE PT_ID is the fictitious item on page 888 that holds the dept_id.

It is also possible to create a link by altering the Action Link region on the Chart Series page. The same items will be filled by this process, but it is easier to use when it is a relatively simple application:

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image