This example illustrates how to load and save the dashboard template to the MRT file. First of all, you should add Stimulsoft modules to the project. To do this, just use one universal package, all other dependencies will be loaded automatically:
// Stimulsoft Dashboard module
var Stimulsoft = require('stimulsoft-dashboards-js');
console.log("Stimulsoft Dashboards loaded");
Now you should create a new
StiReport
object with dashboard page. You can use the special
createNewDashboard()
constructor:
// Creating new dashboard
var report = Stimulsoft.Report.StiReport.createNewDashboard();
console.log("New dashboard created");
To load a previously prepared dashboard template, you can use the
loadFile()
method. As an argument, specify the path to the MRT template file:
// Loading dashboard template
report.loadFile("Dashboard.mrt");
console.log("Dashboard template loaded");
To save an existing dashboard template, you can use the
saveFile()
method. As with loading, in the arguments of the function, specify the path to the MRT template file:
// Save dashboard to file
report.saveFile("Dashboard2.mrt");
console.log("Rendered dashboard saved");
In the screenshot below you can see the result of the sample code: