我有几个子数据集,我使用图表的大部分结果和这个(工作)部分:
<pieDataset>
<dataset incrementType="Group" incrementGroup="group_2113924770">
<datasetRun subDataset="data_2113924770" uuid="724d6473-dd5d-41c4-af6e-4c5b1d995416">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
</datasetRun>
</dataset>
</pieDataset>
SubDataset 定义如下所示:
<subDataset name="data_2113924770" uuid="4a29c5a4-cd0a-4078-8b88-6699c60cbe5e">
<queryString language="MongoDbQuery">
<![CDATA[{ collectionName: 'xxx',
findQuery : { xxx: 1234 },
sort: { geo.c: -1 }
}]]>
</queryString>
<field name="xxx" class="java.lang.Integer"/>
<field name="geo.c" class="java.lang.String"/>
<variable name="var_2113924770" class="java.lang.Integer" resetType="Group" resetGroup="group_2113924770" calculation="Count">
<variableExpression><![CDATA[$F{geo.c}]]></variableExpression>
</variable>
<filterExpression><![CDATA[$F{geo.c} != null]]></filterExpression>
<group name="group_2113924770">
<groupExpression><![CDATA[$F{geo.c}]]></groupExpression>
</group>
</subDataset>
这适用于图表(结果实际上是分组的)。现在我想在表格而不是图表中显示分组的 geo.c 数据,但输出如下所示:
这是使用相同数据集时我的图表的外观:
我无法放入 <dataset incrementType="Group" incrementGroup="group_2113924770">
表格,并且行没有按国家/地区分组。我尝试了“printRepeatedValues”选项但没有成功。我认为这是主要问题。
表中数据集的定义如下所示:
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="data_2113924770" uuid="8c9a7682-73d6-4c85-b37d-5333eb7806cb">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
在尝试放入dataset
时,出现以下错误:
加载报告模板时出错:发现以“dataset”开头的无效内容,预期为“datasetRun”。
问题:如何避免重复键值,每个国家只有一次?
表定义:
<group name="presentation_2113924770" isStartNewPage="true">
<groupExpression><![CDATA[null]]></groupExpression>
<groupHeader>
<band height="225">
<componentElement>
<reportElement uuid="59259048-375f-4d6e-8c64-803ed1d626e2" key="table 3" style="table 3" isPrintRepeatedValues="false" x="25" y="24" width="360" height="140" isRemoveLineWhenBlank="true"/>
<jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<datasetRun subDataset="data_2113924770" uuid="3accd345-1640-4493-a8ae-d000f84ccfcd">
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
</datasetRun>
<jr:column width="90" uuid="de9563e1-11a3-4c60-80bd-5678a9232475">
<jr:tableHeader style="table 3_TH" height="30"/>
<jr:tableFooter style="table 3_TH" height="30"/>
<jr:columnHeader style="table 3_CH" height="30">
<staticText>
<reportElement uuid="91f39641-8c93-4cc0-92a9-01649f83991c" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Country]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 3_CH" height="30"/>
<jr:detailCell style="table 3_TD" height="20">
<textField>
<reportElement uuid="f7e51c9f-7837-45de-b90a-daaa3c330c06" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$F{geo.c}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
<jr:column width="90" uuid="9374f6e6-0dde-4699-bd4e-3479526babb4">
<jr:tableHeader style="table 3_TH" height="30"/>
<jr:tableFooter style="table 3_TH" height="30"/>
<jr:columnHeader style="table 3_CH" height="30">
<staticText>
<reportElement uuid="9e67b831-f794-4ead-ad33-fea93cc5ca63" x="0" y="0" width="90" height="30"/>
<textElement/>
<text><![CDATA[Hits]]></text>
</staticText>
</jr:columnHeader>
<jr:columnFooter style="table 3_CH" height="30"/>
<jr:detailCell style="table 3_TD" height="20">
<textField>
<reportElement uuid="e823f0ac-8c65-4bd9-b243-0a8335aacc4a" x="0" y="0" width="90" height="20"/>
<textElement/>
<textFieldExpression><![CDATA[$V{var_2113924770}]]></textFieldExpression>
</textField>
</jr:detailCell>
</jr:column>
</jr:table>
</componentElement>
</band>
</groupHeader>
</group>