business intelligence vendor

InetSoft Product Information: Adding Tooltips to a Table or Chart

To specify tooltips for individual table cells or chart data, use the following syntax:

 replet.addStatus("ElementID", item, "Tooltip"); 

The 'item' parameter specifies the particular table cell or chart data that should display the tooltip. The 'item' parameter is an EventPoint object, [column, row].

For example, consider the following element-level script for a chart with ID 'Chart1'. Note the index order in the 'item' parameter.

for(var i = 0;
 i < dataset.getRowCount(); i++) {
   replet.addStatus("Graph1", [1,i], dataset.getData(1,i));
 } 

The loop iterates through every value in the first chart dataset (index '1'), given by “getData(1,i),” and assigns each value to the tooltip of the corresponding chart graphical element. Use “getData(0,i)” to obtain the X-labels.

To perform a similar assignment of tooltips to individual cells in a table (ID 'Table1'), you can use the following script. Again, note the index order.

for(var i = 1; i < table.length; i++) {
   for(var j = 0; j < table.size; j++) {
      replet.addStatus("Table1",[j,i],table[i][j]);
   }
}

To add a single tooltip to an entire table or chart element, leave the 'item' parameter as 'undefined' or 'null':

 replet.addStatus("Table1",null,"Example table");
 replet.addStatus("Chart1",null,"Example chart");
View a five-minute Flash demo to get an overview of what InetSoft's business intelligence software, Style Intelligence, can do and how easy it is to use. KPI dashboard demo

 

 

 

 

 

Specifying a Data Format for Tooltip Text

To specify a data format for the tooltip text, format the 'message' parameter input using the 'formatNumber()' function. In the example below, the tooltips on 'Chart1' are given a particular numeric format:

for(var i = 0; i < dataset.getRowCount(); i++) {
  var fdata = formatNumber(dataset.getData(1,i),"#,###");
  replet.addStatus("Graph1", [1,i], fdata);
}

Text and TextBox

The Text and TextBox elements are the most commonly used elements in a report. They can display static text such as titles, headers, footers, and descriptions, or data retrieved from a query (for example, in a Section element).

You can modify the properties of a Text and TextBox from within script, including font, color, and text contents.

Text Property

You can access the contents of a Text or TextBox element through the 'text' property. To change the contents, simply assign a new value.

Text1.text = CALC.today(); // display current date/time 

A TextBox element has several properties in addition to those of the Text element. The 'alignment' property controls the alignment of the TextBox within the document flow. The 'textAlignment' property controls the alignment of the text within the TextBox boundaries.

// right align on the page
alignment = StyleReport.H_RIGHT;
 
// center align text inside textbox
textAlignment = StyleReport.H_CENTER; 

Useful Text/String Functions

Two common string operations are changing case and searching for substrings.

Changing a String to Upper/Lower Case

To change a string to uppercase or lowercase, use the 'toUpperCase()' and 'toLowerCase()' functions, respectively. For example:

 var s = 'John Lennon'; 
 Text1.text = s.toLowerCase(); 

For example, to change the header cells of a table to uppercase, add the following lines to the table script:

for(var col = 0; col < table.size; col++) {
  table[0][col] =
    table[0][col].toUpperCase();
}

Searching Within a String

To find one string within another string, use the 'indexOf()' function. The 'indexOf' function returns the starting index of the substring within the parent string. If the substring is not found, the function returns a value of -1. For example:

var state = 'New Jersey';

if(state.indexOf('New') > -1) {
  Text1.text = 'With New';
}
else {
  Text1.text = 'Without New';
}
Previous: Report Scripting - Common Element Properties Next: How to Find the Difference Between Dates

More Resources:

  >> Reporting Solutions
  >> Reporting Tools
  >> Salesforce Reporting
  >> Service Reporting Software
 
Copyright © 2012, InetSoft Technology Corp.
InetSoft Technology reporting vendor
Ad Hoc Reports | Business Dashboard | Business Intelligence Analytics | Business Intelligence Solution | Business Reporting Software | Dashboard Metrics | Financial Reporting Software | KPI Software | OLAP | Operational BI | Performance Management System | Real Time Reporting | Web Based Reporting Tools