Ahhhhh
Set the renderer on the plot to be a bar renderer
ie
ie
Code: Select all
xyPlot.setRenderer(int index, XYItemRenderer renderer);
// or
xyPlot.setRenderer(XYItemRenderer renderer);
This works
This doesn't =(
I want my BAR, but i just get a big X on the image
Code: Select all
JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, "Dollars", dataset, true, true, false);
chart.setBackgroundPaint(Color.WHITE);
XYPlot xyplot = chart.getXYPlot();
XYAreaRenderer renderer = new XYAreaRenderer();
xyplot.setRenderer(0, renderer);
Code: Select all
JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, "Dollars", dataset, true, true, false);
chart.setBackgroundPaint(Color.WHITE);
XYPlot xyplot = chart.getXYPlot();
XYBarRenderer renderer = new XYBarRenderer();
xyplot.setRenderer(0, renderer);
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
The XYBarRenderer class needs an IntervalXYDataset (the x-interval defines the width of the bars). Unfortunately, the JDBCXYDataset interface doesn't implement the IntervalXYDataset interface (only XYDataset, this could probably be fixed). One way to get around this is to create an XYBarDataset to wrap around your JDBCXYDataset instance and use that as your dataset. The bar width in the constructor will need to be specified in milliseconds (along the axis) for time series data.Anonymous wrote:very very frustrated =(
why does area work but not bar?!?!?!
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


do you know why all my bars are a thin line? How do I change the width bar to larger?
Code: Select all
JDBCXYDataset dataset = null;
//fill dataset
XYBarDataset xybar = new XYBarDataset(dataset, 0);
JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, "Dollars", xybar, false, true, false);
chart.setBackgroundPaint(Color.WHITE);
XYPlot xyplot = chart.getXYPlot();
XYBarRenderer renderer = new XYBarRenderer(0);
xyplot.setRenderer(0, renderer);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, 448, 252);
Because your interval width is set to 0.
Read Davids reply, the width is milliseconds along the axis. I'm using 600000.0 which is 10 minutes, as I have datapoints every 10 minutes.
I first tried 300000.0 because I have 2 datapoints, but it splits the bars into the alloted interval.
It works well.
Read Davids reply, the width is milliseconds along the axis. I'm using 600000.0 which is 10 minutes, as I have datapoints every 10 minutes.
I first tried 300000.0 because I have 2 datapoints, but it splits the bars into the alloted interval.
It works well.
Charles Anderson
I use constant MILLISECONDS_IN_HOUR = 60L * 1000L * 60L for charts with datapoints evety hour.caa wrote:I'm using 600000.0 which is 10 minutes, as I have datapoints every 10 minutes....blabla...It works well
But what should I do with month charts? Every month have different size in milliseconds and that's why i've got february that is much wider than other ones...
Any suggestion?...
Thx a lot!