Pages

Thursday, August 23, 2012

Adding Bar Chart inside table cells in Webintelligence Report using HTML Components

Add Bar Chart inside table cells in Webi

Task:

For simplicity, assume a requirement as below:
  • A view having columns for Event, Current Score, and Score of Previous attempt.
  • Show a table in the report with columns Event and Comparison. In the Comparison column, we have to show a horizontal bar chart comparing current and previous score.

Procedure:

The idea is to use a HTML table with background color where the width of the area filled by the color is dynamically varied by the score values.
Suppose, the data in the table is like below:

 
To achieve the requirement, follow the steps below:

1. Drag the following objects in the query:
Event (dimension), Current Score (measure), Previous Score (measure)
2. In the report, define a Vertical Table with two columns: one for Event and another for the
comparison.
3. In the Event column, define the formula as =[Event] and in the Comparison column, define the
formula as below:

="<html><table><tr><td><div style='background-color:#b5d7e7; width:"+[Current
Score]+";'/></td><td>"+[Current Score]+"</td></tr><tr><td><div style='backgroundcolor:#
7bbace; width:"+[Previous Score]+";'/><td>"+[Previous
Score]+"</td></td></tr></table>"

4. In Display property for the cells of Comparison column, select HTML in Read cell content as field.
5. Adjust the cell height and width to fit the chart.
6. Save the report.
Define two variables as percentage values of ([Current Score]+[Previous Score]) and use them in place of
[Current Score] and [Previous Score] in the comparison formula so that the width of the column can be fixed.

In the HTML viewer, the report will look like below:

 
Then let us add one legend for the colors used.

1. Add one free-standing cell in the report.
2. In the Formula Editor of the cell, give the formula as below:

="<html><fieldset><legend>Legend</legend><table><tr><td><div style='backgroundcolor:#
b5d7e7;width:50'/></td><td>Current Score</td></tr><tr><td><div
style='background-color:#7bbace;width:50'/><td>Previous
Score</td></td></tr></table></fieldset></html>”

3. In Display property for the cell, select HTML in Read cell content as field.

In the HTML viewer, the report will look like below now:

No comments:

Post a Comment

How Many's!!!

  • ()