Reputation: 11
Example: add (0, y1) point and (0,0) then (20, 0) and (20, y2) and (20, 0), then (30,0) and (30, y3) and (30,0) etc. so always return to the x axis and step one.
Are there other/better way?
Upvotes: 0
Views: 346
Reputation: 11
change the default TracePainter of the chart to TracePainterVerticalBar.
try this sample code:
public class MinimalStaticChart {
MinimalStaticChart() {
super();
}
public static void main(String[]args){
// Create a chart:
Chart2D chart = new Chart2D();
// Create an ITrace:
ITrace2D trace = new Trace2DSimple();
// change to vertical bar diagram
trace.setTracePainter(new info.monitorenter.gui.chart.traces.painters.TracePainterVerticalBar(chart));
// Add the trace to the chart. This has to be done before adding points (deadlock prevention):
chart.addTrace(trace);
// Add all points, as it is static:
Random random = new Random();
for(int i=10;i>=0;i--){
trace.addPoint(i,random.nextDouble()*10.0+i);
}
// Make it visible:
// Create a frame.
JFrame frame = new JFrame("MinimalStaticChart");
// add the chart to the frame:
frame.getContentPane().add(chart);
frame.setSize(400,300);
// Enable the termination button [cross on the upper right edge]:
frame.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
frame.setVisible(true);
}
}
Upvotes: 1