iReport折线图类别标签

发布于 2024-12-22 15:42:18 字数 135 浏览 3 评论 0原文

我正在使用折线图组件根据建筑物的消耗生成图表。 想象一个可能的图表,该图表基于一个月内建筑物的消耗量和一天的分辨率。 30天对应30点消费。 问题出在类别轴标签上。由于点数量相当多,标签变得难以辨认。我怎样才能标记一些点?

我最诚挚的问候

i'm using the Line Chart component to generate a chart based on the consumption of a building.
Imagine a possible chart based on the consumption of a building in a period of a month and a resolution of a day. It will have 30 points of consumption corresponding to 30 days.
The problem is with the category axis labels. With a considerable amount of points, the labels becomes unreadable. How can i just label some points?

My best regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一抹苦笑 2024-12-29 15:42:18

不要使用“折线”图表。相反,请使用“时间序列”图表。

它自动处理围绕绘制所有点但仅标记可读数量的点的问题。它还可以处理由不均匀分布的数据点产生的问题。

编辑:如果您传入的数据是字符串而不是日期,那么您就有额外的工作。时间序列图表需要时间(好吧,日期)。您需要将 DateString 转换为真正的 Date。但工作虽小,效益却很大。使用如下变量:new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse($F{MyDateString})

Don't use a "Line" chart. Instead use a "Time Series" chart.

It automatically handles the issues around charting all points but only labeling a readable number of them. It also handles problems created by data points that are not uniformly spaced.

EDIT: If your incoming data is a String instead of a Date, then you have extra work. Time Series charts expect Times (well, Dates). You'll need to cast your DateString into a real Date. But the work is small, and the benefits are large. Use a variable like this: new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse($F{MyDateString}).

心欲静而疯不止 2024-12-29 15:42:18

使用此代码在 JASPER 报告中的折线图上生成标签

else if(jasperChart.getChartType() == JRChart.CHART_TYPE_LINE) {
    LineAndShapeRenderer line = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();
    line.setBaseItemLabelsVisible(Boolean.TRUE);
    line.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());
}

Use this code to generate a label on the line chart in JASPER report

else if(jasperChart.getChartType() == JRChart.CHART_TYPE_LINE) {
    LineAndShapeRenderer line = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer();
    line.setBaseItemLabelsVisible(Boolean.TRUE);
    line.setBaseItemLabelGenerator((CategoryItemLabelGenerator) new StandardCategoryItemLabelGenerator());
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文