LineChart3D - Problem with Item Labels

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mimmorossi
Posts: 35
Joined: Thu Nov 03, 2011 12:48 pm
antibot: No, of course not.

LineChart3D - Problem with Item Labels

Post by mimmorossi » Thu Nov 03, 2011 1:06 pm

Hi,
i use jfreechart-1.0.13 with relative jcommon and junit; i use the LineChart3D with item label visible, when the orientation is Vertical it's work fine, but when the orientation is Horizontal the item is drawed wrong in the graph.
Someone can help me?
Thanks in advance

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: LineChart3D - Problem with Item Labels

Post by matinh » Thu Nov 03, 2011 3:44 pm

Could you provide a small, self-contained demo illustrating the problem?
What does "is drawn wrong in the graph" mean exactly?

- martin

mimmorossi
Posts: 35
Joined: Thu Nov 03, 2011 12:48 pm
antibot: No, of course not.

Re: LineChart3D - Problem with Item Labels

Post by mimmorossi » Thu Nov 03, 2011 5:44 pm

Hi Martin,
sorry for my english; i write this code :
---------------------------------------------------
JFreeChart chart= ChartFactory.createLineChart3D("", // title
labelX, //X-Axis label
labelY,//Y-Axis label
aCategoryDataset, //DataSet
PlotOrientation.HORIZONTAL;, // Bar Orientation
true, // legend Visible
true, // toolTip Visible
false // url Visible
);
[...]
LineAndShapeRenderer linerenderer = (LineAndShapeRenderer)categoryplot.getRenderer();
// the same effect if i use this
//LineRenderer3D linerenderer= (LineRenderer3D)categoryplot.getRenderer();
linerenderer.setBaseItemLabelsVisible(true);
linerenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
---------------------------------------------------------------------------------
and the graph showed is correctly drawed, but the item label no as shown in this image:
Image

but if i use the Vertical orientation, the graph and the label are drawed ok, as shown in this image:
Image

Thanks

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: LineChart3D - Problem with Item Labels

Post by matinh » Thu Nov 03, 2011 8:09 pm

Hi!

According to your images and explanation, this looks very much like a bug. Could you please file a bug using JFreeChart's bug tracker. Please add a back-link to this forum thread. Someone will then have a look at it and hopefully fix it.

If you want to investigate further it would be even better if you could provide a patch that fixes the problem.

Thanks,
- martin

mimmorossi
Posts: 35
Joined: Thu Nov 03, 2011 12:48 pm
antibot: No, of course not.

Re: LineChart3D - Problem with Item Labels

Post by mimmorossi » Fri Nov 04, 2011 10:17 am

Hi Martin,
I did as you said, we hope well.
If my work will allow me, I also try to work.
Thanks

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: LineChart3D - Problem with Item Labels

Post by matinh » Fri Nov 04, 2011 10:56 am

For the records: here is the bug-tracker link: http://sourceforge.net/tracker/?func=de ... tid=115494

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: LineChart3D - Problem with Item Labels

Post by paradoxoff » Sat Nov 05, 2011 9:34 am

Just had a look at the source to confirm an evident cause:
The LineRenderer3D does not take the plot orientation into account, when drawItemLabel(java.awt.Graphics2D g2, PlotOrientation orientation, CategoryDataset dataset, int row, int column, double x, double y, boolean negative) is called.-
Cf. the relevant section of LineAndShapeRenderer:

Code: Select all

if (isItemLabelVisible(row, column)) {
    if (orientation == PlotOrientation.HORIZONTAL) {
        drawItemLabel(g2, orientation, dataset, row, column, y1,x1, (value < 0.0));
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawItemLabel(g2, orientation, dataset, row, column, x1,y1, (value < 0.0));
    }
}
with that of LIneRenderer3D

Code: Select all

if (isItemLabelVisible(row, column)) {
    drawItemLabel(g2, orientation, dataset, row, column, x1, y1,(value < 0.0));
}

mimmorossi
Posts: 35
Joined: Thu Nov 03, 2011 12:48 pm
antibot: No, of course not.

Re: LineChart3D - Problem with Item Labels

Post by mimmorossi » Mon Nov 07, 2011 11:00 am

Hi paradoxoff,
i modified the code in LineRender3D.java and now the graph is ok, but same labels are drawed under the line, as shown in this image:
Image

matinh
Posts: 483
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: LineChart3D - Problem with Item Labels

Post by matinh » Wed Nov 09, 2011 10:06 pm

Hi!

I've fixed the positioning problem with HORIZONTAL plot orientation in SVN.

I also had a look at the problem where labels are drawn below the lines and I think I know how to fix it. But as 1.0.14 is to be released soon, I don't want the fix to be committed without someone who already knows the code reviewing it first. I've created a patch in the patch-tracker, so you can apply the patch to your local copy of JFreeChart if you feel confident with it.

hth,
- martin

mimmorossi
Posts: 35
Joined: Thu Nov 03, 2011 12:48 pm
antibot: No, of course not.

Re: LineChart3D - Problem with Item Labels

Post by mimmorossi » Thu Nov 10, 2011 10:17 am

Hi Martin,
i applied the patch in my local copy and now the labels are ok.
Thanks a lot

Locked