Data can be registered for the dashboard just before it renders, through the onBeforeRender event handled in client JavaScript.

Assign the event, load the dashboard.
$report = new StiReport();
$report->onBeforeRender = 'onBeforeRender';

$viewer->process();
$report->loadFile('../reports/ProductStats.mrt');
$viewer->report = $report;
Build and register data in the event.
function onBeforeRender(args) {
    let dataSet = new Stimulsoft.System.Data.DataSet("Demo");
    dataSet.readXmlSchemaFile("../data/Demo.xsd");
    dataSet.readXmlFile("../data/Demo.xml");
    args.report.regData("Demo", "Demo", dataSet);
}

How it works. The dashboard receives its data right before rendering, so the template need not carry its own connections.
In the screenshot below you can see the result of the sample code:

Registering a Data from Code

Hi. Need any help?