如何在JFreeChart图表上画线? [英] How to draw line over a JFreeChart chart?

查看:131
本文介绍了如何在JFreeChart图表上画线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可更新的OHLCChart。
我需要在图表上画一条线。

I have updatable OHLCChart. I need to draw a line over chart.

如何实现它?

推荐答案

如果要在轴上的给定位置绘制垂直或水平线,可以使用 ValueMarker

If you want to draw a vertical or horizontal line at a given position on an axis, you can use a ValueMarker :

ValueMarker marker = new ValueMarker(position);  // position is the value on the axis
marker.setPaint(Color.black);
//marker.setLabel("here"); // see JavaDoc for labels, colors, strokes

XYPlot plot = (XYPlot) chart.getPlot();
plot.addDomainMarker(marker);

如果你使用 plot.addRangeMarker()想画一条水平线。

Use plot.addRangeMarker() if you want to draw an horizontal line.

这篇关于如何在JFreeChart图表上画线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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