开发者

how do I mark special data points in JChart2D?

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 exampl开发者_JS百科e, 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);
        }
    }
  }
}


Replace the relevant code with this:

PointPainterDisc icon = new PointPainterDisc(); 
icon.setDiscSize(20); // make it bigger than the others
icon.setColorFill(Color.BLUE); // choose a color not used by the others
TracePoint2D point = new TracePoint2D(p.x, p.y);
point.addAdditionalPointPainter(icon);
myTrace.addPoint(point);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜