No tópico "Passando Datasources para sub relatórios" há a explicação apenas sobre como passar o dataSource para o relatório principal.
JasperPrint print = JasperFillManager.fillReport(jr, params, dataSource);
Mas quando o relatório principal possui vários objetos incoporados? Gráficos, Subrelatórios, Crosstab .... Como passar os dataSources de cada um deles?
<subDataset name="CharDataSet" uuid="ea5204b7-e4eb-4d09-8f67-109722fb08b9">
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="financas.xml"/>
<queryString language="SQL">
<![CDATA[SELECT
con.titular AS titular,
cat.nome AS categorias,
sum(mov.valor) AS soma
FROM contas con
INNER JOIN movimentacoes mov ON (mov.conta_id = con.id)
INNER JOIN categorias cat ON (mov.categoria_id = cat.id)
WHERE mov.tipomovimentacao like 'SAIDA'
GROUP BY con.titular, cat.nome]]>
</queryString>
<field name="titular" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="titular"/>
<property name="com.jaspersoft.studio.field.tree.path" value="contas"/>
</field>
<field name="categorias" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="categorias"/>
<property name="com.jaspersoft.studio.field.tree.path" value="categorias"/>
</field>
<field name="soma" class="java.math.BigDecimal">
<property name="com.jaspersoft.studio.field.label" value="soma"/>
</field>
</subDataset>
<queryString language="SQL">
<![CDATA[SELECT
cat.nome AS categoriaNome,
mov.id AS id,
mov.data AS data,
mov.descricao AS descricao,
mov.tipomovimentacao AS tipo,
mov.valor AS valor,
con.titular AS contaTitular
FROM categorias cat
INNER JOIN movimentacoes mov on (cat.id = mov.categoria_id)
INNER JOIN contas con on (con.id = mov.conta_id)
WHERE
mov.tipomovimentacao LIKE 'SAIDA'
ORDER BY con.titular ASC, mov.data ASC]]>
</queryString>
<field name="categorianome" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="categorianome"/>
<property name="com.jaspersoft.studio.field.tree.path" value="categorias"/>
</field>
<field name="id" class="java.lang.Long">
<property name="com.jaspersoft.studio.field.label" value="id"/>
<property name="com.jaspersoft.studio.field.tree.path" value="movimentacoes"/>
</field>
<field name="data" class="java.sql.Timestamp">
<property name="com.jaspersoft.studio.field.label" value="data"/>
<property name="com.jaspersoft.studio.field.tree.path" value="movimentacoes"/>
</field>
<field name="descricao" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="descricao"/>
<property name="com.jaspersoft.studio.field.tree.path" value="movimentacoes"/>
</field>
<field name="tipo" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="tipo"/>
<property name="com.jaspersoft.studio.field.tree.path" value="movimentacoes"/>
</field>
<field name="valor" class="java.lang.Double">
<property name="com.jaspersoft.studio.field.label" value="valor"/>
<property name="com.jaspersoft.studio.field.tree.path" value="movimentacoes"/>
</field>
<field name="contatitular" class="java.lang.String">
<property name="com.jaspersoft.studio.field.label" value="contatitular"/>
<property name="com.jaspersoft.studio.field.tree.path" value="contas"/>
</field>
<variable name="valor1" class="java.math.BigDecimal" resetType="Group" resetGroup="ContaTitular" calculation="Sum">
<variableExpression><![CDATA[$F{valor}]]></variableExpression>
</variable>
<variable name="valor2" class="java.math.BigDecimal" resetType="Group" resetGroup="Data_Mes" calculation="Sum">
<variableExpression><![CDATA[$F{valor}]]></variableExpression>
</variable>
<variable name="valor3" class="java.math.BigDecimal" calculation="Sum">
<variableExpression><![CDATA[$F{valor}]]></variableExpression>
</variable>
Nesse exemplo o relatório principal tem um gráfico incorporado, mas não consegue montar o gráfico.