IReport displays too many labels on x axis

ireportjasper-reports

Good morning! I'm having a problem with Jaspersoft iReport 4.5.0, and I was hoping for some help. Basically, when I display an xy line chart, it's attempting to add a label on the x-axis for each data point. I have almost 200 data points, so this ends up looking like just a solid line, even if I tweak the rotation of the tick labels or whatever.

I'm aware that the general response to this question is to use a timeseries chart instead. This would ordinarily work, but in my instance I am using a multi-axis chart where the opposite axis is a bar chart. Since a bar chart has no timeseries variety, iReport will not allow me to mix a bar chart with a timeseries chart, forcing me to use the xy line chart.

Is there any way I can have my cake and eat it, too? Some way I can filter out some of the labels? Or perhaps limit the number of labels that can be displayed, spread out over the x-axis? I have yet to see a definitive answer anywhere on the internet!

Thanks in advance!
– Ian

EDIT: Here is the jrxml for one of the multi-axis charts I'd like to modify:

<multiAxisChart>
    <chart evaluationTime="Report" hyperlinkType="LocalAnchor">
        <reportElement x="42" y="441" width="440" height="292"/>
        <chartTitle position="Top">
            <titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
        </chartTitle>
        <chartSubtitle/>
        <chartLegend/>
        <anchorNameExpression><![CDATA["CICS Elapsed Small"]]></anchorNameExpression>
        <hyperlinkAnchorExpression><![CDATA["CICS Elapsed Big"]]></hyperlinkAnchorExpression>
        <hyperlinkTooltipExpression><![CDATA["Click to Enlarge"]]></hyperlinkTooltipExpression>
    </chart>
    <multiAxisPlot>
        <plot/>
        <axis position="leftOrTop">
            <lineChart>
                <chart>
                    <reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
                    <chartTitle position="Top" color="#000000">
                        <titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
                    </chartTitle>
                    <chartSubtitle color="#000000"/>
                    <chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
                </chart>
                <categoryDataset>
                    <dataset>
                        <datasetRun subDataset="wmprod_cics"/>
                    </dataset>
                    <categorySeries>
                        <seriesExpression><![CDATA["Cpu Time"]]></seriesExpression>
                        <categoryExpression><![CDATA[$F{TIMESTAMP}]]></categoryExpression>
                        <valueExpression><![CDATA[$F{ELAPSTIME}]]></valueExpression>
                    </categorySeries>
                </categoryDataset>
                <linePlot isShowShapes="false">
                    <plot/>
                    <categoryAxisLabelExpression><![CDATA["Date/Time"]]></categoryAxisLabelExpression>
                    <valueAxisLabelExpression><![CDATA["Avg Elapsed Time (ms)"]]></valueAxisLabelExpression>
                </linePlot>
            </lineChart>
        </axis>
        <axis position="rightOrBottom">
            <barChart>
                <chart>
                    <reportElement x="0" y="0" width="0" height="0" backcolor="#FFFFFF"/>
                    <chartTitle position="Top" color="#000000">
                        <titleExpression><![CDATA["CICS Elapsed"]]></titleExpression>
                    </chartTitle>
                    <chartSubtitle color="#000000"/>
                    <chartLegend textColor="#000000" backgroundColor="#FFFFFF"/>
                </chart>
                <categoryDataset>
                    <dataset>
                        <datasetRun subDataset="wmprod_cics"/>
                    </dataset>
                    <categorySeries>
                        <seriesExpression><![CDATA["Volume (transactions)"]]></seriesExpression>
                        <categoryExpression><![CDATA[$F{TIMESTAMP}]]></categoryExpression>
                        <valueExpression><![CDATA[$F{TRANSCOMPL}]]></valueExpression>
                    </categorySeries>
                </categoryDataset>
                <barPlot>
                    <plot/>
                    <itemLabel/>
                    <valueAxisLabelExpression><![CDATA["Volume (transactions)"]]></valueAxisLabelExpression>
                </barPlot>
            </barChart>
        </axis>
    </multiAxisPlot>
</multiAxisChart>

Best Answer

I had the same problem. I think the answer is this:

<chart>
  <reportElement x="0" y="0" width="802" height="215">
    <property name="net.sf.jasperreports.chart.domain.axis.tick.interval" value="1"/>
  </reportElement>

Set the tick interval as appropriate. Note: My chart was a scatter chart. Untested with line chart.

Related Topic