...
Anchor | ||||
---|---|---|---|---|
|
Table of Contents | ||
---|---|---|
|
Overview
If you want to have more control over the loading of content, call reports or dashboards on demand, or set display options dynamically (based on user input), you can call the API directly from your own script.
The Javascript API must be included before any API calls can be made:
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI" type="text/javascript"></script>
{code}
|
A
...
specific
...
version
...
of
...
the
...
API
...
may
...
be
...
requested
...
using
...
the
...
version
...
parameter:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI?version=2.1" type="text/javascript"></script>
{code}
|
If
...
the
...
browser
...
is
...
unable
...
to
...
load
...
the
...
API,
...
any
...
calls
...
to
...
load
...
reports
...
or
...
dashboards
...
will
...
fail.
...
If
...
you
...
wish
...
to
...
detect
...
whether
...
the
...
API
...
has
...
loaded
...
successfully,
...
you
...
should
...
check
...
the
...
variable
...
window.yellowfin
...
is
...
available:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script type="text/javascript">
if (!window.yellowfin) {
alert('Error loading API');
}
</script>
{code}
h2. Server Information
{styleclass: Class=topLink}[top|#top]{styleclass}
After loading the API, some server information is made available:
h3. {expand:title=Expand here...}
|| ||Description||
|{{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|
{expand}
h3. Example
{code:javascript} |
Server Information
After loading the API, some server information is made available:
Expand | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||
|
Example
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script type="text/javascript">
if (window.yellowfin) {
alert('Yellowfin API loaded. Version: ' + yellowfin.apiVersion);
}
</script>
{code}
h2. Loading a Report
{styleclass: Class=topLink}[top|#top]{styleclass}
A report is loaded by calling the {{yellowfin.loadReport}} function:
{code:javascript} |
Loading a Report
A report is loaded by calling the yellowfin.loadReport
function:
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadReport(options);
{code}
|
Options
...
are
...
passed
...
to
...
the
...
function
...
as
...
a
...
Javascript
...
object.
...
These
...
include
...
a
...
report
...
identifier
...
for
...
the
...
report
...
you
...
are
...
loading,
...
the
...
elementId
...
of
...
the
...
HTML
...
element
...
in
...
which
...
to
...
load
...
the
...
report
...
(or
...
the
...
element
...
itself),
...
and
...
other
...
options
...
that
...
alter
...
the
...
way
...
the
...
report
...
is
...
displayed.
...
The
...
available
...
options
...
are:
...
Expand | ||
---|---|---|
|
...
|
Examples
This example loads a report into an element specified by its universal id, setting some initial display options:
Code Block | ||||
---|---|---|---|---|
| ||||
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);
{code}
|
This
...
example
...
does
...
the
...
same
...
thing
...
with
...
an
...
anonymous
...
options
...
object:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadReport({
reportUUID: 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63',
elementId: 'myReport',
showFilters: 'false',
showSeries: 'false',
display: 'chart',
fitTableWidth: 'false'
});
{code}
|
This
...
example
...
passes
...
the
...
element
...
directly
...
rather
...
than
...
just
...
its
...
id:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadReport({
reportUUID: 'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63',
element: document.getElementById('myReport')
});
{code}
h2. Loading Report Filters
{styleclass: Class=topLink}[top|#top]{styleclass}
Filters used by a report can be loaded by calling the {{ |
Loading Report Filters
Filters used by a report can be loaded by calling the yellowfin.reports.loadReportFilters
...
function.
...
To
...
use
...
this
...
function,
...
load
...
the
...
reports
...
sub-API
...
into
...
your
...
page
...
along
...
with
...
the
...
main
...
API:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script src="http://localhost/JsAPI?api=reports" type="text/javascript"></script>
{code}
|
Then
...
call
...
the
...
loadReportFilters
...
function:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.reports.loadReportFilters(reportId, callback, arg);
{code}
|
The
...
first
...
argument
...
is
...
the
...
unique
...
identifier
...
for
...
the
...
report,
...
which
...
may
...
either
...
be
...
a
...
reportUUID
...
or
...
a
...
reportId
...
.
...
We
...
recommend
...
using
...
the reportUUID
where possible.
...
The
...
second
...
argument
...
is
...
a
...
callback
...
function
...
that
...
will
...
be
...
called
...
by
...
the
...
API
...
when
...
the
...
filters
...
for
...
the
...
report
...
have
...
been
...
loaded.
...
The
...
first
...
argument
...
to
...
the
...
callback
...
function
...
will
...
be
...
the
...
list
...
of
...
filters
...
in
...
the
...
report.
...
The
...
second
...
argument
...
to
...
the
...
callback
...
function
...
will
...
be
...
the
...
third
...
argument
...
supplied
...
to
...
the
...
loadReportFilters
...
function
...
(if
...
specified).
...
The
...
filters
...
object
...
returned
...
as
...
the
...
first
...
argument
...
to
...
the
...
callback
...
function
...
is
...
an
...
array
...
containing
...
any
...
filters
...
used
...
in
...
the
...
report.
...
Each
...
element
...
in
...
the
...
array
...
is
...
an
...
object
...
containing
...
information
...
about
...
that
...
filter.
...
These
...
filter
...
objects
...
contain
...
the
...
properties:
...
Expand | ||
---|---|---|
|
...
|
Examples
This example loads the report filters and displayed them to the user:
Code Block | ||||
---|---|---|---|---|
| ||||
function filterCallback(filters) {
for (var i = 0; i < filters.length; i++) {
alert('Filter ' + filters[i].description + ' (' +
filters[i].filterUUID + '), display style: ' +
filters[i].display);
}
}
yellowfin.reports.loadReportFilters(
'e5e5aaf3-c3b8-4f9b-8280-e21e4d848e63', filterCallback);
{code}
|
This
...
function
...
can
...
be
...
used
...
to
...
load
...
the
...
available
...
filters,
...
and
...
then
...
pass
...
them
...
back
...
to
...
the
...
loadReport
...
function
...
to
...
set
...
up
...
initial
...
filter
...
values
...
for
...
the
...
report
...
when
...
it
...
is
...
loaded
...
into
...
the
...
page.
...
For
...
example:
...
Code Block | ||||
---|---|---|---|---|
| ||||
function filterCallback(filters) {
var filterValues = {};
for (var i = 0; i < filters.length; i++) {
if (filters[i].description == 'Country') {
filterValues[filters[i].filterUUID] = 'Australia';
} else if (filters[i].description == 'Start Date') {
filterValues[filters[i].filterUUID] = '2011-01-01';
} else if (filters[i].description == '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);
{code}
|
Filter
...
values
...
passed
...
to
...
the
...
loadReport
...
function
...
should
...
be
...
specified
...
as
...
simple
...
values
...
as
...
above.
...
If
...
the
...
filter
...
is
...
a
...
list
...
style,
...
multiple
...
values
...
can
...
be
...
set
...
using
...
an
...
array:
...
Code Block | ||||
---|---|---|---|---|
| ||||
filterValues[filterUUID] = ['Australia', 'China', 'Italy'];
{code}
|
If
...
the
...
filter
...
is
...
a
...
between
...
style,
...
the
...
start
...
and
...
end
...
values
...
should
...
be
...
set
...
using
...
an
...
array:
...
Code Block | ||||
---|---|---|---|---|
| ||||
filterValues[filterUUID] = [500, 600];
{code}
The {{ |
The options.filters
...
element
...
passed
...
to
...
the
...
loadReport
...
function
...
should
...
contain
...
values
...
keyed
...
either
...
by
...
filterUUID
...
or
...
filterId
...
.
...
We
...
recommend
...
using
...
filterUUID
where possible.
Loading a Dashboard
A dashboard is loaded by calling the yellowfin.loadDash
function:
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadDash(options);
{code}
|
Options
...
are
...
passed
...
to
...
the
...
function
...
as
...
a
...
Javascript
...
object.
...
These
...
include
...
an
...
identifier
...
for
...
the
...
dashboard
...
you
...
are
...
loading,
...
the
...
elementId
...
of
...
the
...
HTML
...
element
...
in
...
which
...
to
...
load
...
the
...
dashboard
...
(or
...
the
...
element
...
itself),
...
and
...
other
...
options
...
that
...
alter
...
the
...
way
...
the
...
dashboard
...
is
...
displayed.
...
The
...
available
...
options
...
are:
...
Expand | ||
---|---|---|
|
...
|
Examples
This example loads a dashboard into an element specified by its id, setting some initial display options.
Code Block | ||||
---|---|---|---|---|
| ||||
var options = {};
options.dashUUID = '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9';
options.elementId = 'myDash';
options.showFilters = 'false';
options.showExport = 'false';
yellowfin.loadDash(options);
{code}
|
This
...
example
...
does
...
the
...
same
...
thing
...
with
...
an
...
anonymous
...
options
...
object:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadDash({
dashUUID: '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9',
elementId: 'myDash',
showFilters: 'false',
showExport: 'false'
});
{code}
|
This
...
example
...
passes
...
the
...
element
...
directly,
...
rather
...
than
...
just
...
its
...
id:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.loadDash({
dashUUID: '3b0b6c9a-9dfb-41f0-b85a-eb17bb8aeeb9',
element: document.getElementById('myDash')
});
{code}
h2. Loading Dashboard Filters
{styleclass: Class=topLink}[top|#top]{styleclass}
Filters used by a dashboard can be loaded by calling the {{ |
Loading Dashboard Filters
Filters used by a dashboard can be loaded by calling the yellowfin.dash.loadDashFilters
...
function.
...
To
...
use
...
this
...
function,
...
load
...
the
...
dashboard
...
sub-API
...
into
...
your
...
page
...
along
...
with
...
the
...
main
...
API:
...
Code Block | ||||
---|---|---|---|---|
| ||||
<script src="http://localhost/JsAPI" type="text/javascript"></script>
<script src="http://localhost/JsAPI?api=dash" type="text/javascript"></script>
{code}
|
Then
...
call
...
the
...
loadDashFilters
...
function:
...
Code Block | ||||
---|---|---|---|---|
| ||||
yellowfin.dash.loadDashFilters(dashUUID, callback, arg);
{code}
|
The
...
first
...
argument
...
is
...
the
...
unique
...
identifier
...
for
...
the
...
dashboard.
...
The
...
second
...
is
...
a
...
callback
...
function
...
that
...
will
...
be
...
called
...
by
...
the
...
API
...
when
...
the
...
filters
...
for
...
the
...
dashboard
...
have
...
been
...
loaded.
...
The
...
first
...
argument
...
to
...
the
...
callback
...
function
...
will
...
be
...
the
...
list
...
of
...
filters
...
in
...
the
...
dashboard.
...
The
...
second
...
argument
...
to
...
the
...
callback
...
function
...
will
...
be
...
the
...
third
...
argument
...
supplied
...
to
...
the
...
loadReportFilters
...
function
...
(if
...
specified).
...
The
...
filters
...
object
...
returned
...
as
...
the
...
first
...
argument
...
to
...
the
...
callback
...
function
...
is
...
an
...
array
...
containing
...
any
...
analytical
...
filters
...
used
...
in
...
the
...
dashboard,
...
as
...
well
...
as
...
filter
...
group
...
separators.
...
Each
...
element
...
in
...
the
...
array
...
is
...
an
...
object
...
containing
...
information
...
about
...
that
...
filter
...
or
...
filter
...
group.
...
These
...
objects
...
contain
...
the
...
properties:
...
Expand | ||
---|---|---|
|
...
|
Examples
This example loads the dashboard filters and displays them to the user:
Code Block | ||||
---|---|---|---|---|
| ||||
function filterCallback(filters) {
for (var i = 0; i < filters.length; i++) {
alert('Filter ' + filters[i].description + ' (' +
filters[i].key + '), display style: ' +
filters[i].display);
}
}
yellowfin.reports.loadReportFilters(1234, filterCallback);
{code}
|
This
...
function
...
can
...
be
...
used
...
to
...
load
...
the
...
available
...
filters,
...
and
...
then
...
pass
...
them
...
back
...
to
...
the
...
loadDash
...
function
...
to
...
set
...
up
...
initial
...
filter
...
values
...
for
...
the
...
dashboard
...
when
...
it
...
is
...
loaded
...
into
...
the
...
page:
...
Code Block | ||||
---|---|---|---|---|
| ||||
function filterCallback(filters) {
var filterValues = {};
for (var i = 0; i < filters.length; i++) {
if (filters[i].description == 'Country') {
filterValues[filters[i].key] = 'Australia';
} else if (filters[i].description == 'Start Date') {
filterValues[filters[i].key] = '2011-01-01';
} else if (filters[i].description == '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);
{code}
|
Filter
...
values
...
passed
...
to
...
the
...
loadDash
...
function
...
should
...
be
...
specified
...
as
...
simple
...
values
...
as
...
above.
...
If
...
the
...
filter
...
is
...
a
...
list
...
style,
...
multiple
...
values
...
can
...
be
...
set
...
using
...
an
...
array:
...
Code Block | ||||
---|---|---|---|---|
| ||||
filterValues[key] = ['Australia', 'China', 'Italy'];
{code}
|
If
...
the
...
filter
...
is
...
a
...
between
...
style,
...
the
...
start
...
and
...
end
...
values
...
should
...
be
...
set
...
using
...
an
...
array:
...
Code Block | ||||
---|---|---|---|---|
| ||||
filterValues[key] = [500, 600];
{code}
The {{ |
The options.filters
...
element
...
passed
...
to
...
the
...
loadDash
...
function
...
should
...
contain
...
values
...
keyed
...
by
...
the
...
keys
...
returned
...
from
...
the
...
loadDashFilters
...
function.
...