Constructor problem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Edmond

Constructor problem

Post by Edmond » Tue Oct 29, 2002 4:45 pm

Hi,
I am trying to take the initialization of a all aspects of a dynamic BasicTimeSeries from the constructor to a seperate function. I need to do this in order to have the user decide which BasicTimerSeries to graph. When I take it out of the constructor and put it in a different function all I get is a gray panel with no data.
Any help would be greatly appreciated.
edmond


P.S. Code of my init function is included below

dataset.addSeries(totalMemory);
dataset.addSeries(freeMemory);
dataset.addSeries(used);
dataset.addSeries(threads);

BasicStroke gridStroke =
new BasicStroke(
0.50f,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL);
BasicStroke seriesStroke =
new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

HorizontalDateAxis domain = new HorizontalDateAxis("Time");
VerticalNumberAxis range = new VerticalNumberAxis("Memory");

XYPlot xyplot = new XYPlot(dataset, domain, range);
xyplot.setBackgroundPaint(Color.black);
xyplot.setSeriesPaint(
new Paint[] {
Color.red,
Color.green,
Color.blue,
Color.magenta,
Color.yellow });
xyplot.setSeriesStroke(0, seriesStroke);

domain.setAutoRange(true);
domain.setLowerMargin(0.0);
domain.setUpperMargin(0.0);
domain.setGridPaint(Color.green);
domain.setGridStroke(gridStroke);
domain.setTickLabelsVisible(true);
domain.setGridLinesVisible(false);
domain.setCrosshairVisible(false);

(NumberAxis.createIntegerTickUnits());
range.setGridPaint(Color.green);
range.setGridStroke(gridStroke);
range.setGridLinesVisible(true);
range.setCrosshairVisible(false);

JFreeChart chart =
new JFreeChart(
"Memory Usage",
JFreeChart.DEFAULT_TITLE_FONT,
xyplot,
true);
ChartPanel chartPanel = new ChartPanel(chart);
add(chartPanel);

Dave Gilbert

Re: Constructor problem

Post by Dave Gilbert » Wed Oct 30, 2002 9:06 am

Hi Edmond,

I can't see anything obvious that is wrong in your code.

Regards,

DG.

Locked