Embed Metric Sets
This applies to: Managed Dashboards, Managed Reports
When Symphony is embedded directly onto your page, dundas.context
is a dundas.views.embedded.Bootstrap
.
Call its embedView
method to embed an existing dashboard, report, or other view type by its ID, which you can find from its URL or properties dialog. It is rendered inside the DOM element you specify, which should have some set size independent of its contents (i.e., not auto). The following embeds a dashboard:
let element = document.getElementById("viewContainer"); dundas.context.embedView(element, "bdba4200-8d2d-0f90-0049-cfbe81e00004", { sessionId: sessionId });
The third argument is an object specifying additional optional values. Important options include passing sessionId
as an alternative to first calling and waiting for setSessionId
, and viewType
when embedding a type of view other than a dashboard like in the next example. A jQuery.Promise
is returned that you can use to wait for the embedding to complete.
Content is always embedded on its own without other interface elements like the application's toolbar or main menu, but with most functionality accessible by default as usual from the context menu via right-click or long-tap.
If you are embedding multiple items on your page, a separate EmbeddedViewService
is used for displaying each one. Specify an embeddedViewServiceName
of your choice starting at least with the second embedding call (omitting this will cause an error such as "Service EmbeddedViewService is already registered"). Either to wait for the first embedding method to finish, or to call and wait for setSessionId
first before embedding any content as follows:
let element1 = document.getElementById("container1"); let element2 = document.getElementById("container2"); dundas.context.setSessionId(result.sessionId).done(() => { dundas.context.embedView(element1, "8166d221-af1a-1881-40c6-f09ed09fe735"); dundas.context.embedView(element2, "06294698-2d5a-9b4a-7b46-195db1d30397", { embeddedViewServiceName: "EmbeddedReportService", viewType: dundas.entities.ViewType.REPORT }); });
You can use the name you specified for an embedded view service or else its class name
EmbeddedViewService
when calling getService
to get its instance. For example, you can call its dispose method if you want to remove the content from your page.
Parameter Values
When calling embedView
, you can use the viewOverrides
option to pass in as well as create view parameter values. The same parameter value types are used as in the article Modify a filter / view parameter using scripting.
The following example sets an existing numeric parameter with the script name viewParameter1
when embedding the dashboard:
var numberValue = new dundas.data.RangeNumberValue({ lowerBoundaryValue: 1200, upperBoundaryValue: 1800 }); var overrides = new dundas.view.controls.ViewOverrides(); overrides.defaultViewParameterValues.push({ viewParameterName: "viewParameter1", parameterValue: numberValue }); dundas.context.embedView(document.getElementById("viewContainer"), "<insert ID>", { sessionId: sessionId, viewOverrides: overrides });
Similarly, you can create a view parameter that did not already exist, like the following that sets some specific hierarchy members by their unique names:
var newViewParameter = new dundas.view.ViewParameter(); newViewParameter.addElementParameterLink(new dundas.view.ElementParameterLink({ adapterId: "9ae85f75-0213-f2b6-98e8-e2000042b2cf", elementUsageUniqueName: "Customer Count", metricSetBindingId: "ba37ecdc-a049-9fca-00b1-1ef9f911147f", parameterId: "58e027c3-003d-4cc8-a5b9-1cf83a36deaf" })); newViewParameter.parameterValue = new dundas.data.CollectionMemberValue({ values: [ new dundas.data.MemberValue({ "hierarchyUniqueName": "Product", "uniqueName": "Accessories.C.Product", "levelUniqueName": "C.Product", }), new dundas.data.MemberValue({ "hierarchyUniqueName": "Product", "uniqueName": "Clothing.C.Product", "levelUniqueName": "C.Product", }) ] }); var overrides = new dundas.view.controls.ViewOverrides(); overrides.viewParameters.push(newViewParameter); dundas.context.embedView(document.getElementById("viewContainer"), "<insert ID>", { embeddedViewServiceName: "DashboardEmbeddedViewService", viewOverrides: overrides });
Find a visualization's
adapterId
in the Properties window, and the metricSetBindingId
in the metric set settings dialog accessible from the Data Analysis Panel. The parameter ID is defined on each AnalysisElementUsage
in a metric set's measures or hierarchies as analysisElementUsage.parameter.id
.
Embed Metric Sets
Calling embedMetricSet is similar to calling embedView but for an existing metric set and its default visualization. The same additional arguments are needed when embedding multiple Symphony items on the same page.
The following embeds a single metric set:
let container = document.getElementById("visualizationContainer"); dundas.context.embedMetricSet(container, "7b8000df-36fd-4994-b6f6-2f6d96999fab", { sessionId: sessionId });
To access embedded metric sets directly rather than through an embedded view such as an existing dashboard, a user must have a power user seat license or higher.