Pages

Tuesday, April 13, 2010

OBIEE Showing Data on a Calendar

Sometimes there's need for the business data related to promotional events, holidays etc. to be presented on a calendar to improve readability. In this post I will explain how to achieve this in OBIEE using mooTools and javscript calendar (http://dansnetwork.com/mootools/events-calendar).

Here's Sales report of an ogranization by day. Wouldn't it be great if we can plot this on a calendar and higlight the day when it's holiday.



Prerequisites:
To render the calendar we will need mooTools Core, mooTools More and mooTools events calendar. Here are URLs for download: (I used No Compression for all downloads)

MooTools Core: http://mootools.net/download
MooTools More: http://mootools.net/more
Select Date, Scroller, Tips while downloading mooTools More.
Events Calendar: http://dansnetwork.com/mootools/events-calendar/download/

Here's the list of all files you should have after download:
  • mooECal.css
  • mooECal.js
  • mooECalLarge.css
  • mooECalSmall.css
  • mootools-1.2.4-core-nc.js
  • mootools-1.2.4.4-more.js
Create a folder name mooTools on OBIEE server under Drive:\OracleBI\oc4j_bi\j2ee\home\applications\analytics\analytics\res\ folder and copy all the files to it.

Narrative View to render Calendar
I added Narrative View to the report I showed earlier.




Added following information to each textbox and selected "Contains HTML Markup" checkbox.

Prefix:

<link rel="stylesheet" type"text/css" href="./res/mooTools/mooECal.css">
<script language="javascript" src="./res/mooTools/mootools-1.2.4-core-nc.js"></script>
<script language="javascript" src="./res/mooTools/mootools-1.2.4.4-more.js"></script>
<script language="javascript" src="./res/mooTools/mooECal.js"></script>
<div id="calBody"></div>
<script language="javascript">

function getDiv(holFlag)
{
if(holFlag=='Y')
{
return '<div style="background-color:#990000;color:#ffffff;">';
}
else
{
return '<div>';
}
}

new Calendar({calContainer:'calBody', newDate:'1/21/2010',
cEvents:new Array(

Narrative:
{
title: getDiv('@3') + '@4</div>',
start: '@2',
end: '@2',
location: ''
}

Row Separator:
,

Postfix:
)
}); </script>

Please note:
  • The path to .js and .css files is ./res/mooTools.
  • getDiv function returns div tag with red background when it's holiday. You can do other event specific handling if required.
  • Calendar instance is passed an array of events. In our case this is sales information.
    Sales value is passed in the title. Start and End date are sale date.
  • The comma (,) in Row separator will separate event array element.
  • You can change mooECal.css in prefix section to mooECalSmall.css or mooECalLarge.css if you want smaller or bigger calendar.

Here's data rendered on calendar. Note, background color for holidays.



Please read licensing terms of mooTools and event calendar before making commercial use.

10 comments:

  1. Nice article thanks for sharing with us.

    ReplyDelete
  2. Nice! Very Nice!

    John
    http://obiee101.blogspot.com/

    ReplyDelete
    Replies
    1. Hey John,

      Did you try this in 11g? Can you tell me to which folder should i copy in 11g?

      Delete
  3. Hitesh,
    I was searching for the same since long time. It is really very use full for me.
    Thank you very much…
    Venkat

    ReplyDelete
  4. Wonderful...Thanks a lot Hitesh

    Sheeba.T

    ReplyDelete
  5. Great Job Hitesh

    Raja V (Anjali)

    ReplyDelete
  6. can't make this work in 11g Calendar is undefined error

    ReplyDelete
  7. This is really good article, thanks for sharing

    ReplyDelete
  8. Good one. I will definitely try this.

    ReplyDelete
  9. What is holFlag ? DashBoard is not showing anything. Please any one explain how work flow of given function
    function getDiv(holFlag)

    and from where it takes value for holFlag ?

    ReplyDelete