VerticalXYBarRenderer class

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

VerticalXYBarRenderer class

Post by Hostos Monegro » Mon Oct 21, 2002 2:39 pm

Hi,

Can someone please explain how to use the drawItem method in the VerticalXYBarRenderer class:

drawItem (java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset data, int series, int item, CrosshairInfo crosshairInfo)


I'm not really sure how to make a graphics2D object with out using the paint method. It would be a big help if you could elaborate on each of the parameters of the method.

Daniel van Enckevort

Re: VerticalXYBarRenderer class

Post by Daniel van Enckevort » Mon Oct 21, 2002 2:52 pm

drawItem will render the item onto the given Graphics2D object. The size, co-ordinates, appearance, etc are determined by the other parameters.

Normally, you just let JFreechart do the drawing, why exactly do you need to call this method yourself?

Dan

Dave Gilbert

Re: VerticalXYBarRenderer class

Post by Dave Gilbert » Tue Oct 22, 2002 8:58 am

Hi,

As Daniel correctly pointed out, this method is called by JFreeChart (the call is made inside the XYPlot class) each time it draws an item in the plot. You normally won't call it yourself.

Regards,

DG.

Hostos Monegro

Re: VerticalXYBarRenderer class

Post by Hostos Monegro » Tue Oct 22, 2002 2:35 pm

What I'm trying to do is draw a red vertical bar on different charts (a bar chart and a line chart), using the drawitem method in the StandardXYItemRenderer class. What I did was make an object like the following:
XYItemRenderer renderer1 = new StandardXYItemRenderer();

then using the drawItem method (renderer1.drawItem(g2, etc...) from the StandardXYItemRenderer class is how I'm trying to achieve this. Also, this is being done from my createCombinedChart() method.

I guess what I'm really having trouble with is, what exactly is that I'm suppose to send the drawItem method as arguments and where and how to envoke it.

public void drawItem(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
ChartRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset data,
int series,
int item,
CrosshairInfo crosshairInfo)


thanks,
Hostos

Dave Gilbert

Re: VerticalXYBarRenderer class

Post by Dave Gilbert » Tue Oct 22, 2002 4:49 pm

I think you are going about it the wrong way. The drawItem(...) method is designed to be called once-per-item for all the data items in an XYPlot. The XYPlot takes care of passing in the correct arguments, the renderer just draws the item onto the supplied Graphics2D device.

What is the vertical bar you want to draw? Is it part of your data, or are you just trying to represent some threshold on your chart? If you just want to mark some value, you can use the addDomainMarker(...) and addRangeMarker(...) methods in the XYPlot class.

Regards,

DG.

Hostos Monegro

Re: VerticalXYBarRenderer class

Post by Hostos Monegro » Tue Oct 22, 2002 5:27 pm

Thats exactly what I want to do, my red vertical bar will represent a particular day on the x-axis (so, it will be a threshold representing a certain value). Could you please elaborate on your suggestion and on the argument of the addDomainMarker(Marker marker) method. thanks again...



thanks,
HM

Locked