如何在 JChart2D 中标记特殊数据点?
在 JChart2D 中,一系列的点可以用小圆圈或穿过这些点的线来绘制。我需要引起用户对某些特定点的注意。
我如何用实心圆圈或其他类型的符号来标记偶尔出现的点。
提供的垂直条形图似乎将整个图更改为垂直条形图(在它发生的点以及“追溯”到较旧的点)。我不想那样。我只需要让一个点看起来很特别,例如 X=5 处的点。
Chart2D chart = new Chart2D();
ITrace2D myTrace = new Trace2DLtd(100);
myTrace.setColor(Color.RED);
myTrace.setTracePainter(new TracePainterDisc()); // circle; not filled
chart.addTrace(myTrace);
JFrame frame = new JFrame(Constants.graphTitle);
frame.getContentPane().add(chart);
frame.setSize(200, 200);
frame.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
frame.setVisible(true);
List<Point> list = Helper.makeList();
for (Point p: list)
{
if (p.x != 5)
myTrace.addPoint(p.x, p.y);
else
{
// MAKE THIS POINT LOOK DIFFERENT, BUT HOW?
myTrace.addPoint(p.x, p.y);
}
}
}
}
In JChart2D points from a series can be plotted with little circles or a line drawn through the points. I need to draw the user's attention to certain specific points.
How would I mark the occasional point with filled-in circles or some other kind of symbol.
The vertical bar painter provided, seems to change the entire plot to a vertical bar chart (at the point it occurs and also "retroactively" to the older points). I do not want that. I just need to make a single point look special, for example, the point at X=5.
Chart2D chart = new Chart2D();
ITrace2D myTrace = new Trace2DLtd(100);
myTrace.setColor(Color.RED);
myTrace.setTracePainter(new TracePainterDisc()); // circle; not filled
chart.addTrace(myTrace);
JFrame frame = new JFrame(Constants.graphTitle);
frame.getContentPane().add(chart);
frame.setSize(200, 200);
frame.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
frame.setVisible(true);
List<Point> list = Helper.makeList();
for (Point p: list)
{
if (p.x != 5)
myTrace.addPoint(p.x, p.y);
else
{
// MAKE THIS POINT LOOK DIFFERENT, BUT HOW?
myTrace.addPoint(p.x, p.y);
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将相关代码替换为:
Replace the relevant code with this: