I've got some not working code here:
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, true, true, true);
ChartPanel chartpanel = new ChartPanel(chart);
chartpanel.setDomainZoomable(true);
jPanel4.setLayout(new BorderLayout());
jPanel4.add(chartpanel, BorderLayout.NORTH);
So the problem is that the jPanel4 with a chart is not visible. When I add my chartpanel to a frame and make it visible, it works.
Anyone knows what's my mistake?
do u have anything in
CENTER
Layout in jpanel else try adding chart in centerNORTH
is actually top of the container.This works perfectly fine for me:
Can you provide us with a bit more code? Do you put something else into
jPanel4
? There can not be more than one component in every spot (NORTH, SOUTH, WEST, EAST, CENTER
). Do you put your panel into a frame?