将静态网格线添加到JFreeChart时间序列图 [英] Adding a static gridline to a JFreeChart time series chart

查看:222
本文介绍了将静态网格线添加到JFreeChart时间序列图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在JFreeChart中实现具有特殊要求的时间序列图.我可以绘制图表,但是我不知道如何在图表的最后一个值处实现垂直红线.它应始终位于同一位置,并且应始终与最后一个值相交.

I am trying to implement a timeseries chart with a peculiar requirement in JFreeChart. I can draw the chart, but I don't know how to implement the vertical red line at the last value in the chart. It should always be in the same spot and should always intersect with the last value.

我绝对不知道该怎么做.我当时以为可以将它实现为静态网格线,但是我不知道如何指定它.

I am absolutely out of ideas on how this would be done. I was thinking that it might be possible to implement it as a static gridline, but I don't know how to specify one.

此外,图表的大小将是静态的,因此可以接受某种绕行方式,希望不引入任何第三方库.

Also, the size of the charts will be static, so some roundabout way of doing this is acceptable, hopefully without introducing any 3rd party libraries.

可以在此处找到图片.

谢谢.

推荐答案

好吧,我使用标记解决了它.这是执行此操作的代码:

Well, I solved it using a marker. Here's the code that does it:

JFreeChart chart = ChartFactory.createTimeSeriesChart(...);
XYPlot plot = chart.getXYPlot();
Long timestampToMark = new Date().getTime();
Marker m = new ValueMarker(timestampToMark);
m.setStroke(new BasicStroke(2));
m.setPaint(Color.RED);
plot.addDomainMarker(m);

也许其他人会发现这很有用.

Maybe someone else will find this useful.

这篇关于将静态网格线添加到JFreeChart时间序列图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆