30日間の無料評価版をお試しいただけます。

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

概要

コンテンツのロードを詳細にコントロールしたり、レポートまたはダッシュボードを適宜呼び出したり、(ユーザー入力に基づいて)表示オプションをダイナミックに設定したりする場合は、独自のスクリプトでAPIを直接呼び出すことができます。

API呼び出しを実行する前に、Javascript APIを含める必要があります:

<script src="http://localhost/JsAPI" type="text/javascript"></script>

version パラメーターを使用して、特定バージョンのAPIをリクエストすることができます:

<script src="http://localhost/JsAPI?version=2.1" type="text/javascript"></script>

ブラウザーがAPIをロードできない場合、レポートまたはダッシュボードをロードするすべての呼び出しが失敗します。APIが正常にロードされたかどうかを検出するには、変数 window.yellowfin が使用可能かどうかを確認します:

<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script type="text/javascript">
if (!window.yellowfin) {
   alert('Error loading API');
}
</script>

Server Information

After loading the API, some server information is made available:

 

説明

yellowfin.apiVersion

The version of the API being used by the server.

yellowfin.baseURL

The base URL used to connect to the API on the server

yellowfin.serverInfo.releaseVersion

The release version of Yellowfin running on the server (eg. "6.1")

yellowfin.serverInfo.buildVersion

The build version of Yellowfin running on the server (eg. "20120601")

yellowfin.serverInfo.javaVersion

The java version installed on the server

yellowfin.serverInfo.operatingSystem

The Operating System running on the server

yellowfin.serverInfo.operatingSystemArch

The Operating System architecture on the server

yellowfin.serverInfo.operatingSystemVersion

The Operating System version on the server

yellowfin.serverInfo.schemaVersion

The schema version of the Yellowfin configuration database

<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script type="text/javascript">
if (window.yellowfin) {
   alert('Yellowfin API loaded. Version: ' + yellowfin.apiVersion);
}
</script>

レポートのロード

レポートは、 yellowfin.loadReport 関数を呼び出してロードします:

yellowfin.loadReport(options);

オプションは、Javascriptオブジェクトとして関数に渡されます。ロードしているレポートのレポート識別子、レポートをロードするHTML要素のelementId(またはelementそのもの)、およびレポートの表示方法を変更するその他のオプションなどがあります。使用可能なオプションは以下のとおりです:

オプション

説明

reportUUID

Either reportUUID, reportId or wsName must be present.The unique ID identifying the dashboard to load.

reportId

Either reportUUID, reportId or wsName must be present.The numeric reportId identifying the report to load. It is recommended to use the reportUUID parameter instead.

wsName

Either reportUUID, reportId or wsName must be present.The Web Service name identifying the report to load. It is recommended to use the reportUUID parameter instead.

elementId

Either elementId or element must be present.The id of the html element in which to load the report.

element

Either elementId or element must be present.The html element in which to load the report.

showTitle

Default: trueSet to false to omit the title bar at the top of the report. All interactive buttons included in the title bar will also be omitted.

showInfo

Default: trueSet to false to omit the Info button in the title bar.

showFilters

Default: trueSet to false to omit the Filters button in the title bar. Any user-prompt filters will not be displayed.

showSections

Default: trueSet to false to omit the Sections button in the title bar (for reports with tabbed or multi-page sections).

showSeries

Default: trueSet to false to omit the Series button in the title bar (for reports with the series selection option).

showPageLinks

Default: trueSet to false to omit the previous page/next page button in the title bar (for reports with multiple pages).

showExport

Default: trueSet to false to omit the Export button in the title bar.

height

Default: automatically detected from the dimensions of the enclosing elementSet this to a numeric value to override the report height.

width

Default: automatically detected from the dimensions of the enclosing elementSet this to a numeric value to override the report width.

display

Default: chartSet to table to display the report initially as a table.Set to chart to display the report initially as a chart.This is ignored for reports that do not have both table and chart available.

fitTableWidth

Default: trueSet to true to attempt to scale the report to the width of the enclosing element.

canChangeDisplay

Default: trueSet to false to omit the buttons that allow the user to switch between chart and table display.

filters

Set to an object containing filter values to pass to the report.

username

Set this along with the password parameter to authenticate as a particular user when loading the report. This avoids the need for users to enter their login details before viewing restricted reports.

password

Set this along with the username parameter to authenticate as a particular user when loading the report.

ユニバーサルIDで指定された要素にレポートをロードし、初期の表示オプションをいくつか設定する例を示します:

var options = {};
options.reportUUID = 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63';
options.elementId = 'myReport';
options.showFilters = 'false';
options.showSeries = 'false';
options.display = 'chart';
options.fitTableWidth = 'false';
yellowfin.loadReport(options);

匿名オプションオブジェクトを使用して同様の処理を行う例を示します:

yellowfin.loadReport({
   reportUUID: 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63',
   elementId: 'myReport',
   showFilters: 'false',
   showSeries: 'false',
   display: 'chart',
   fitTableWidth: 'false'
});

IDではなく要素を直接渡す例を示します:

yellowfin.loadReport({
   reportUUID: 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63',
   element: document.getElementById('myReport')
});

レポートフィルターのロード

レポートで使用されるフィルターは、 yellowfin.reports.loadReportFilters 関数を使用してロードすることができます。この関数を使用するには、メインAPIと共にレポートサブAPIをページにロードします:

<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script src="http://localhost/JsAPI?api=reports" type="text/javascript"></script>

その後 loadReportFilters 関数を呼び出します:

yellowfin.reports.loadReportFilters(reportId, callback, arg);

1番目の引数はレポートの固有識別子で、 reportUUIDreportId のいずれかです。可能な限り reportUUID を使用することをお勧めします。2番目の引数はコールバック関数で、レポートのフィルターがロードされたときにAPIによって呼び出されます。コールバック関数の1番目の引数は、レポートのフィルターリストです。コールバック関数の2番目の引数は loadReportFilters 関数に渡される3番目の引数になります(指定した場合)。

コールバック関数の1番目の引数として返されるフィルターオブジェクトは、レポートで使用されるあらゆるフィルターが格納された配列です。配列の各要素は、そのフィルターに関する情報が格納されたオブジェクトです。これらのフィルターオブジェクトには以下のプロパティがあります:

プロパティ

説明

filterUUID

A unique identifier for the filter.

filterId

A numeric identifier for the filter.

nativeType

The native data type of the filter.

説明

The 説明 of the filter.

operator

The operator used with the filter.

display

The display style used by the filter.

dependencies

Set to true if other filters in the report are dependent on this one.

list

Set to true if the filter is a list style (allows multiple values).

between

Set to true if the filter is a between style (requires a start and end value).

listValues

If the filter is displayed as a drop-down list, this property contains a list of available options.

レポートフィルターをロードしてユーザーに表示する例を示します:

function filterCallback(filters) {

   for (var i = 0; i < filters.length; i++) {
      alert('Filter ' + filters[i].説明 + ' (' +
         filters[i].filterUUID + '), display style: ' +
         filters[i].display);
   }

}

yellowfin.reports.loadReportFilters(
   'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63', filterCallback);

この関数は、使用可能なフィルターをロードしてloadReport関数に戻し、レポートがページにロードされるときのレポートのフィルター初期値を設定するために使用できます。例:

function filterCallback(filters) {

   var filterValues = {};

   for (var i = 0; i < filters.length; i++) {

      if (filters[i].説明 == 'Country') {

         filterValues[filters[i].filterUUID] = 'Australia';

      } else if (filters[i].説明 == 'Start Date') {

         filterValues[filters[i].filterUUID] = '2011-01-01';

      } else if (filters[i].説明 == 'Invoiced Amount') {

         filterValues[filters[i].filterUUID] = 6400;

      }

   }

   // set up other options to load the report
   var options = {};
   options.reportUUID = 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63';
   options.elementId = 'myReport';
   // add the filter values
   options.filters = filterValues;

   // load the report
   yellowfin.loadReport(options);

}

yellowfin.reports.loadReportFilters(
   'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63', filterCallback);

loadReport 関数に渡されるフィルター値は、上記のように単純な値として指定する必要があります。フィルターがリストスタイルの場合は、配列を使用して複数の値を設定できます:

filterValues[filterUUID] = ['Australia', 'China', 'Italy'];

フィルターが範囲スタイルの場合は、配列を使用して開始値および終了値を設定する必要があります:

filterValues[filterUUID] = [500, 600];

options.filters  loadReport 関数に渡される おp 要素は、 filterUUID または filterId でキー設定された値を含む必要があります。可能な限り filterUUID を使用することをお勧めします。

ダッシュボードのロード

ダッシュボードは、 yellowfin.loadDash 関数を呼び出してロードします:

yellowfin.loadDash(options);

オプションは、Javascriptオブジェクトとして関数に渡されます。ロードしているダッシュボードの識別子、ダッシュボードをロードするHTML要素のelementId(またはelementそのもの)、およびダッシュボードの表示方法を変更するその他のオプションなどがあります。使用可能なオプションは以下のとおりです:

オプション

説明

dashUUID

Must be present.The unique identifier for the dashboard to load.

elementId

Either elementId or element must be present.The id of the html element in which to load the dashboard.

element

Either elementId or element must be present.The html element in which to load the dashboard.

showTitle

Default: trueSet to false to omit the title bar at the top of the dashboard. All interactive buttons included in the title bar will also be omitted.

showInfo

Default: trueSet to false to omit the Info button in the title bar.

showFilters

Default: trueSet to false to omit the Filters button in the title bar. Any analytical filters will not be displayed.

showExport

Default: trueSet to false to omit the Export button in the title bar.

height

Default: automatically set from the dimensions of the reports in the dashboard.Set this to a numeric value to override the dashboard height. If the reports in the dashboard require more space, a vertical scrollbar will be added.

width

Default: automatically set from the logged-in user's preferences or the system configuration settingSet this to a numeric value to override the dashboard width.Set this to auto to use the full width of the enclosing element.

filters

Set to an object containing filter values to pass to the dashboard.

username

Set this along with the password parameter to authenticate as a particular user when loading the dashboard. This avoids the need for users to enter their login details before viewing restricted dashboards.

password

Set this along with the username parameter to authenticate as a particular user when loading the dashboard.

IDで指定された要素にダッシュボードをロードし、初期の表示オプションをいくつか設定する例を示します。

var options = {};
options.dashUUID = '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9';
options.elementId = 'myDash';
options.showFilters = 'false';
options.showExport = 'false';
yellowfin.loadDash(options);

匿名オプションオブジェクトを使用して同様の処理を行う例を示します:

yellowfin.loadDash({
   dashUUID: '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9',
   elementId: 'myDash',
   showFilters: 'false',
   showExport: 'false'
});

IDではなく要素を直接渡す例を示します:

yellowfin.loadDash({
   dashUUID: '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9',
   element: document.getElementById('myDash')
});

ダッシュボードフィルターのロード

ダッシュボードで使用されるフィルターは、 yellowfin.dash.loadDashFilters 関数を使用してロードすることができます。この関数を使用するには、メインAPIと共にダッシュボードサブAPIをページにロードします:

<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script src="http://localhost/JsAPI?api=dash" type="text/javascript"></script>

その後 loadDashFilters 関数を呼び出します:

yellowfin.dash.loadDashFilters(dashUUID, callback, arg);

1番目の引数は、ダッシュボードの固有識別子です。2番目はコールバック関数で、ダッシュボードのフィルターがロードされたときにAPIによって呼び出されます。コールバック関数の1番目の引数は、ダッシュボードのフィルターリストです。コールバック関数の2番目の引数は loadReportFilters 関数に渡される3番目の引数になります(指定した場合)。

コールバック関数の1番目の引数として返されるフィルターオブジェクトは、ダッシュボードで使用されるあらゆる分析フィルターと、フィルターグループ区切り文字が格納された配列です。配列の各要素は、そのフィルターまたはフィルターグループに関する情報が格納されたオブジェクトです。これらのオブジェクトには以下のプロパティがあります:

プロパティ

説明

key

A unique key for this filter or filter group.

type

Set to FILTERGROUP if this object represents a filter group. Other values indicate a type of analytic filter.

説明

The 説明 of the filter or filter group.

groupId

For filter groups: a numeric identifier for the group.

state

For filter groups: set to OPEN if the group is currently opened.

display

For filters: the display style used by the filter.

dependencies

For filters: set to true if other filters in the dashboard are dependent on this one.

list

For filters: set to true if the filter is a list style (allows multiple values).

between

For filters: set to true if the filter is a between style (requires a start and end value).

listValues

For filters: if the filter is displayed as a drop-down list, this property contains a list of available options.

ダッシュボードフィルターをロードしてユーザーに表示する例を示します:

function filterCallback(filters) {

   for (var i = 0; i < filters.length; i++) {
      alert('Filter ' + filters[i].説明 + ' (' +
         filters[i].key + '), display style: ' +
         filters[i].display);
   }

}

yellowfin.reports.loadReportFilters(1234, filterCallback);

この関数は、使用可能なフィルターをロードして loadDash 関数に戻し、ダッシュボードがページにロードされるときのダッシュボードのフィルター初期値を設定するために使用できます:

function filterCallback(filters) {

   var filterValues = {};

   for (var i = 0; i < filters.length; i++) {

      if (filters[i].説明 == 'Country') {

         filterValues[filters[i].key] = 'Australia';

      } else if (filters[i].説明 == 'Start Date') {

         filterValues[filters[i].key] = '2011-01-01';

      } else if (filters[i].説明 == 'Invoiced Amount') {

         filterValues[filters[i].key] = 6400;

      }

   }

   // set up other options to load the dashboard
   var options = {};
   options.dashUUID = '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9';
   options.elementId = 'myDash';
   // add the filter values
   options.filters = filterValues;

   // load the dashboard
   yellowfin.loadDash(options);

}

yellowfin.dash.loadDashFilters('3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9', filterCallback);

loadDash 関数に渡されるフィルター値は、上記のように単純な値として指定する必要があります。フィルターがリストスタイルの場合は、配列を使用して複数の値を設定できます:

filterValues[key] = ['Australia', 'China', 'Italy'];

フィルターが範囲スタイルの場合は、配列を使用して開始値および終了値を設定する必要があります:

filterValues[key] = [500, 600];

options.filters  loadDash 関数に渡される OP 要素は、 ldfl 関数から返される keys でキー設定された値を含む必要があります。 loadDashFilters



  • No labels