Recent Posts

Creating interactive graphics in APEX with Raphaël (RaphaelJS)

Von Tobias Arnhold → 9.21.2016
Some of you may know of my personal interest for SVG interaction in APEX applications. I have been working with a JavaScript library called "Raphaël" (RaphaelJS, raphael.js or just raphael) for a while now. It is an amazing plugin to create all kind of customized business solutions. But before I show you how I have used Raphaël I tell you how I came to the technology and what happened in the last few years.

5 years ago an APEX developer called "Matt Nolan" created an impressive example how you can use Raphaël for a custom business case: SVG Body Chart Plugin

Inspired by his example I started looking for this library called Raphaël.

What does the library do?
It creates dynamic SVG graphics with Javascript and JSON.

Why is it so special?
From an APEX developer point of view it gives you great possibilities to create SVG graphics right from the data out of your database and Raphaël itself brings you several ways to create more or less complex solutions. Just go on reading and you will find out.

How to integrate Raphaël?
Upload the JavaScript file and include it in your APEX page.
/* Implementation: Page > JavaScript > File URLs */
Add a new APEX region from type "Static Content" and add a DIV element:
<div id="svg_example1"></div>
Finally add the Raphaël-JavaScript code below the DIV region:
  document.addEventListener("DOMContentLoaded", function(){ 
    /* Set up raphael svg area and save it in variable rc (raphael container)*/
    var rc = new Raphael(document.getElementById('svg_example1'), 200, 180);
    /* add new svg element */
    var el = rc.path("M 170 120 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z");
    /* Add attributes to element */
            fill: '#F2621B',
            stroke: '#2F3E66',
            'stroke-width': 10,
            'stroke-linejoin': 'round',
            rotation: -90
 }, false);


Who made this library?
The developer behind Raphaël is Dmitry Baranovskiy. Compared to the APEX community he is the Patrick Wolf for SVG solutions using JavaScript. At least in my mind. :)
After the success of Raphaël he joined Adobe. There he created an library called Snap which is quite similar to Raphael and real powerful. Unfortunately it seems that the Snap library is not further developed anymore. The last release is from 2 years ago.

The last Raphael release is from July 2016. Having questions use "Stack Overflow".

Why not creating the same kind of solution as Matt did?
It took me a while before I had the time thinking about the possibilities and purpose in business applications. I mean not every developer can create an example as Matt did. So I had some reasons to consider about:

1. No sources available
The typical company does not have SVG graphics to visualize their custom business situations. Mostly they use some advanced Excel files including some graphical parts to visualize their business cases. So if you create an APEX application based on those Excel solutions, the customers want their "beautiful" visualization in the APEX application as well.
For example an "workshop plan".

2. Complexity
It is really complicated to create a SVG graphic for the typical APEX developer.
Interacting with SVG graphics is also not the typical activity for an APEX developer.
Moving an SVG to the database to build it with Raphael is not easy either.
You may have to use Raphaël with other JavaScript libraries to enhance the user experience.

3. Time and Money
The more complex the example the more times it takes creating a result and it will become more expensive in the first run and on future updates.

4. Maintenance
Could a decent APEX developer take my solution and extend it? This is an important question to me.

What did I do?
2 Years ago I created an example application for the DOAG 2014.
There I published several examples how you can use Raphaël on top of an existing image file. I only created a few moving SVG components to interact with the application user.

- It is really easy to integrate.
- You do not need an SVG out of your Excel file to publish it in APEX.
- Less code because of the static background image

- The image can't be responsive
- It can never be as beautiful as the example from Matt

The solutions looked like this:

Harbor example (Source:

Bridge example (Source:  
Power grid example (Source: Dirk Witthaut, MPI für Dynamik und Selbstorganisation,

The image, the data and the Raphael code comes directly from inside the database. Published with a PL/SQL procedure:
procedure generate_harbor (in_image_id number)
  v_image_filename           varchar2(100);
  v_image_name                varchar2(100);
  v_image_width              number;
  v_image_height               number;
  v_background_color varchar2(100);
  s_proc_name := 'RJS_DEMO.GENERATE_HARBOR';
  s_parameter := 'in_image_id: ' || to_char(in_image_id);
  s_action := 'Image selection';
  select image_filename, image_name, image_width, image_height
  into   v_image_filename,v_image_name, 
         v_image_width, v_image_height
  from   rjs_image
  where  id = in_image_id;
  s_action := 'HTML generation';
    #wrapper {
        position: relative;
        width: ' || v_image_width || 'px;
        height: ' || v_image_height || 'px;
        padding: 0;
        outline: 1px solid #999;
    #wrapper img {
        position: absolute;
        top: 0;
        left: 0;
        position: absolute;
        top: 0;
        left: 0;
   <div id="wrapper">
    <img src="' || v('WORKSPACE_IMAGES') || v_image_filename ||'">
    <div id="canvas">

  s_action := 'JS open';
    document.addEventListener("DOMContentLoaded", function(){ 
      var canvas = Raphael(document.getElementById("canvas"), ' || v_image_width || ', ' || v_image_height || ');

  s_action := 'JS data loop';
  for rec_k in (
         select rownum, image_id, coordinate_id, 
                result_type, text, c_x, c_y, c_t, c_x_text, c_y_text
         from vw_rjs_harbor
         where image_id = in_image_id
  ) loop
      s_action := 'txt'||rec_k.rownum || ' generation.';
      htp.p ('
        var txt'||rec_k.rownum||' = canvas.text('||(rec_k.c_x_text)||', '||(rec_k.c_y_text)||', "'||rec_k.text||'");
        txt'||rec_k.rownum||'.attr({ "font-size": '||'"9"'||','
                                   || ' "font-family": "Arial, Helvetica, sans-serif",'
                                   || ' "fill": "black",'
                                   || ' transform:"r-'||rec_k.c_t||'"});  
        var box'||rec_k.rownum||' = txt'||rec_k.rownum||'.getBBox();
        var img'||rec_k.rownum||' = canvas.image("'|| v('WORKSPACE_IMAGES')||rec_k.result_type||'.png", '
                                                   || rec_k.c_x||', '||rec_k.c_y||', '||'26'||', '||'19'||')'
                                                   || '.attr({transform:"r-'||rec_k.c_t||'"}).glow({width:1,opacity:0.8});

  end loop;
  s_action := 'JS close';
    }, false);

when others then   
      rollback; s_ora_error := sqlerrm;
      s_custom_error := 'Internal error occured. Processing stopped.';
      add_err; commit;raise_application_error(-20001, s_custom_error);
APEX itself needs a region from type: "PL/SQL Dynamic Content"
The source is simple:
The result looked like this:

From my point of view:
You get a new way publishing data in a decent amount of time and low complexity in the source code.

This was two years ago.

On this years DOAG 2016 I will tell you how you can achieve even more powerful examples.
Using the Raphael extension Mapael for custom map visualizations or how to create an own SVG and convert it real fast towards APEX. And maybe there will come some more...

See you at DOAG.

And for all who will miss the DOAG event.  I plan to publish an open source version of the application. So check at the end of the year. Maybe 24. of December will be a good date. :)

Oracle APEX Meetup in Stockholm 16.08.

Von Tobias Arnhold → 7.19.2016
In my summer holiday, this year in Stockholm (Sweden), I will make a stop and present two APEX topics in the "Stockholm Oracle Meetup group".

The topics will be:

Working with interactive SVG graphics in APEX 
Adding SVG graphics inside individual business applications is quite in common. Because those graphics can increase the usability and even more important it creates a completely new way to visualize data inside a browser app. In this presentation he will show us how one can integrate SVG charts and how to use the possibilities of SVG elements to make every static image interactive with only a few lines of code.

APEX Dashboard Competition 
At the beginning of the year the German community announced the "APEX Dashboard Competition". The goal was to create a nice looking dashboard application. This presentation will give you an impression about the best 10 applications and their individual solutions.

If you are interested to see what APEX is capable of then join the presentation on
Thanks to Mathias Magnusson for organizing this great event. Hope to meet as much APEX enthusiasts as possible. :)

Interactive Report with a Font Awesome edit icon

Von Tobias Arnhold → 7.01.2016
Most of you know the default APEX edit icons you can choose from inside your Interactive Report.
Basically you use them to link to a detail page.

The icon source looks like this.

A typical result page.

Two things I would like to change:
 1. The Icon should be a nice looking car symbol from the Font Awesome library.
 2. The column width should be as small as the icon and not relative to the page width.

We change the pencil.png towards the nice looking automobile icon from Font Awesome.
<span class="fa fa-automobile"></span> 

Then we add a little CSS snippet to the page inline CSS.
.minimize-first-table-col td:first-child{
  width: 1%;
  overflow: visible;
  padding: 8px;

And as a last step we add the class minimize-first-table-col inside the Interactive Report > Appearance > CSS Classes.

The result will looks like this.

Reset Interactive Report (IR)

Von Tobias Arnhold → 6.30.2016
Resetting an Interactive Report (IR) can be done in 4 different ways.
User Reset, URL Link, Page Process, Dynamic Action

First of all
It is always a good start to set up a specific static report id.

1.  User Reset
Not much to say.

1. URL Link


Cache definition:
- RIR: reset IR to primary report
- CIR: reset IR to primary report but with custom columns
- RP: reset IR pagination.

More details about the difference of RIR and CIR can be found here:
Apex Interactive Report: The difference between CIR and RIR

Basically all you need to know about the URL options in an IR can be found in the documentation:
Application Express Application Builder User's Guide

Also be aware that you can use several IR since APEX 5 on one page. Filters must now be applied in a specific syntax:
IR[region static ID]_

2. Page Process (Before Header)

  SELECT region_id INTO v_region_id
  WHERE application_id = :APP_ID
  AND page_id = 1
  AND static_id = 'IR_RO_REPORT_ID'; -- Static ID of your IR

   P_page_id => 1,
   P_region_id => v_region_id,
   P_report_id => NULL


3. Dynamic Action
Create a new Dynamic Action.
Add a TRUE action of type "Execute PL/SQL code"  and use the same code as above.
And finally add another TRUE action to refresh the IR.

If you still need more information then take a look here:
Reset an Interactive Report (IR)

Oracle Spatial (Teil 4) - Unterschiedliche Koordinaten Punkte zu einer Linie zusammenführen

Von Tobias Arnhold → 6.21.2016
Vor kurzem musste ich Daten aus einer Excel-Liste in das SDO_GEOMETRY Format bringen. Leider hatte die Excelliste einen Haken.

Die Anforderungen:
- Es musste eine Linie (Typ 2002) im GK3 Format (31467) aus VON und NACH Punkten generiert werden.
- Die Excel-Liste hatte die Punkte entweder als GK3 oder als WGS84 Format hinterlegt.

Nach Import der Daten sah meine Quelltabelle dann so aus:

Und hier das Select zur richtigen Transformation der Geo-Daten ins SDO_GEOMETRY Format:

     /* Linie generieren */
        2002, /* Linie */
        31467, /* GK3 */
     ) AS GEO_GK3,

     /* Entfernung berechnen */
           GEOM1 => SDOP.VON_GEO_GK3,
           GEOM2 => SDOP.NACH_GEO_GK3,
           TOL => 5,
           UNIT => 'unit=KM'
     ),3) ENTFERNUNG
      /* Berechnung der SDO Punkte */

        /* VON: Check ob GK3 oder WGS84 und Vereinheitlichung ins GK3 Format*/
            MDSYS.SDO_GEOMETRY (
                      2001, -- Zweidimensionaler Punkt
                      31467, -- Typ: GK3
                          X => VON_GK3_X, 
                          Y => VON_GK3_Y,
                          Z => NULL
              MDSYS.SDO_GEOMETRY (
                2001, -- Zweidimensionaler Punkt
                8307, -- Typ: WGS84
                    X => VON_WGS84_X,  -- Längengrad / Longitude / Ost
                    Y => VON_WGS84_Y,  -- Breitengrad / Latitude / Nord
                    Z => NULL
             31467 -- Umwandlung in GK3
        END AS VON_GEO_GK3,

        /* NACH: Check ob GK3 oder WGS84 und Vereinheitlichung ins GK3 Format*/
            MDSYS.SDO_GEOMETRY (
                      2001, -- Zweidimensionaler Punkt
                      31467, -- Typ: GK3
                          X => NACH_GK3_X, 
                          Y => NACH_GK3_Y,
                          Z => NULL
              MDSYS.SDO_GEOMETRY (
                2001, -- Zweidimensionaler Punkt
                8307, -- Typ: WGS84
                    X => NACH_WGS84_X,  -- Längengrad / Longitude / Ost
                    Y => NACH_WGS84_Y,  -- Breitengrad / Latitude / Nord
                    Z => NULL
             31467 -- Umwandlung in GK3

Mit dem Ergebnis:

APEX Master (Interactive Report) - Detail (Modal Dialog) Form: Conditional Column Link

Von Tobias Arnhold → 6.15.2016

Since APEX 5 it is much easier to create master-detail pages with modal dialogs. But there is still no declarative way to create a conditional row based column link.

This blog post will show you a way how to create a conditional row based master - detail page.

1. We need some sample data:
select 1 as ID, 'APEX Connect' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 2 as ID, 'KScope' as name, 0 as CONDITIONAL_COL from DUAL
union all
select 3 as ID, 'DOAG' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 4 as ID, 'APEX-FRA Meetup Group' as name, 1 as CONDITIONAL_COL from DUAL
union all
select 5 as ID, 'Oracle World' as name, 0 as CONDITIONAL_COL from DUAL
  case when nvl(CONDITIONAL_COL,99) = 1 then
  else 'none' end as CSS,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'Visited conference'
  else 'Not visited yet' end as DETAIL_COL
from MY_DATA
As you can see the column CONDITIONAL_COL defines the conditional appearance.
CONDITIONAL_COL = 1 means show a detail button.
CONDITIONAL_COL = 0 means no detail button.

2. Now we can create a APEX master detail page where the "Page Mode" of the detail page is set to:
"Modal Dialog".

The master page gets an Interactive Report with the above select statement.

3. Now we need to configure the column attributes inside the Interactive Report:
Columns ID and NAME with be displayed as of type: "Plain Text".
Column CSS will not be displayed: "Hidden Column"
Column DETAIL_COL will be displayed as of type: "Link"
 - Target: 
   - Page: 2
   - Set Items: P2_ID - #ID#
 - Link Text: <span class="fa fa-search-plus" style="font-size: 160%"></span>
 - Link Attribues: class="a-Button" style="display:#CSS#;"
 We created a custom link for our detail page.

And the functionality to display the detail button conditionally is set by the column "CSS".

The result looks like this:

You can even filter the button by some readable data:

Security issue:
On the detail page you need a validation to check if the user is allowed to edit the data of the transmitted ID. An alternative way is to update the select so that no ID value will be generated if the user has no rights.
  case when nvl(CONDITIONAL_COL,99) = 1 then
  else NULL end as ID,
  case when nvl(CONDITIONAL_COL,99) = 1 then
  else 'none' end as CSS,
  case when nvl(CONDITIONAL_COL,99) = 1 then
    'Visited conference'
  else 'Not visited yet' end as DETAIL_COL
from MY_DATA

Using dynamic tooltips in your Interactive Report

Von Tobias Arnhold → 5.31.2016

Inside an Interactive Report (IR) I had a comment column. The comments in this column could become really large and the users wanted the comments to be automatically trimmed if more then 60 characters were displayed. If the user moved the mouse above a trimmed comment then a tooltip should be display including all comment text.

My first idea was to check for existing plugins which could do this job for me. So I searched on and found the plugin called "APEX Tooltip" developed by Daniel Hochleitner.

The plugin looked great from what I could see in the example application. When I tried it in my application I found out that all comments must be applied manually in the dynamic action.
Not exactly what I needed. :)

Luckily it was really easy to extend the plugin in a way that I could use it in my IR. To achieve what I need I had to update the javascript file: apextooltip.js
// APEX Tooltip functions
// Author: Daniel Hochleitner
// Updated by Tobias Arnhold
// Version: 1.1

// global namespace
var apexTooltip = {
  // parse string to boolean
  parseBoolean: function(pString) {
    var pBoolean;
    if (pString.toLowerCase() == 'true') {
      pBoolean = true;
    if (pString.toLowerCase() == 'false') {
      pBoolean = false;
    if (!(pString.toLowerCase() == 'true') && !(pString.toLowerCase() == 'false')) {
      pBoolean = undefined;
    return pBoolean;
  // function that gets called from plugin
  showTooltip: function() {
    // plugin attributes
    var daThis = this;
    var vElementsArray = daThis.affectedElements;
    var vTheme = daThis.action.attribute01;
    var vContent = daThis.action.attribute02;
    var vContentAsHTML = apexTooltip.parseBoolean(daThis.action.attribute03);
    var vAnimation = daThis.action.attribute04;
    var vPosition = daThis.action.attribute05;
    var vDelay = parseInt(daThis.action.attribute06);
    var vTrigger = daThis.action.attribute07;
    var vMinWidth = parseInt(daThis.action.attribute08);
    var vMaxWidth = parseInt(daThis.action.attribute09);
    var vLogging = apexTooltip.parseBoolean(daThis.action.attribute10);
    // Logging
    if (vLogging) {
      console.log('showTooltip: affectedElements:', vElementsArray);
      console.log('showTooltip: Attribute Theme:', vTheme);
      console.log('showTooltip: Attribute Content:', vContent);
      console.log('showTooltip: Attribute Content as HTML:', vContentAsHTML);
      console.log('showTooltip: Attribute Animation:', vAnimation);
      console.log('showTooltip: Attribute Position:', vPosition);
      console.log('showTooltip: Attribute Delay:', vDelay);
      console.log('showTooltip: Attribute Trigger:', vTrigger);
      console.log('showTooltip: Attribute minWidth:', vMinWidth);
      console.log('showTooltip: Attribute maxWidth:', vMaxWidth);
      console.log('showTooltip: Attribute Logging:', vLogging);
    for (var i = 0; i < vElementsArray.length; i++) {
      var vaffectedElement = daThis.affectedElements.eq(i);
      // call tooltipster plugin
        theme: vTheme,
        content: $(vaffectedElement).find('.rep_complete_comment').html(),
        contentAsHTML: vContentAsHTML,
        animation: vAnimation,
        position: vPosition,
        delay: vDelay,
        touchDevices: false,
        trigger: vTrigger,
        minWidth: vMinWidth,
        maxWidth: vMaxWidth,
        debug: vLogging,
        functionBefore: function(origin, continueTooltip) {
        functionAfter: function(origin) {
Of course I had to update my IR as well.
First I trimmed the comment column and added a new hidden comment column:
-- ...
from my_table
Then I updated the column attributes:
COMMENT_COL as plain text
- Static ID: rep_comment
- HTML Expression:
#COMMENT_COL#<div class="rep_complete_comment">#COMPLETE_COMMENT_COL#</div>

COMPLETE_COMMENT_COL as hidden column

I also had to add a small css snippet in the page attributes > CSS > Inline to hide the complete comment:
.rep_complete_comment {
display: none;

And as a last step I had to implement the tooltip plugin after refreshing the IR:
I used an advanced jQuery selector to get only those comments affected which had more then 60 characters.

The result looked like this: