Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gantt chart bars are drawn incorrectly when orientation of plot is vertical #235

Open
danno-1 opened this issue Jul 20, 2021 · 5 comments
Open

Comments

@danno-1
Copy link

danno-1 commented Jul 20, 2021

Using this example (or any other for that matter)
https://www.boraji.com/jfreechart-gantt-chart-example

add this line after the JFreeChart chart = ChartFactory.createGanttChart call

chart.getPlot().setOrientation(PlotOrientation.VERTICAL)

You'll see that the first two bars (Requirement bars) are the same size and touching the axis, rather than the Actual bar being smaller than the Estimated bar, and the third bar (Design Actual) is very wrong, touching the axis and shorter than it should be. And others are wrong as well.

Horizontal:
Horizontal Gantt Chart

Vertical:
Vertical Gantt Chart

This is a problem in both 1.0 and 1.5 versions of JFree. Hoping someone can point me to a fix in the renderer I can do myself before the fix is in an offical JFree release.

Thanks!
Dan

@trashgod
Copy link
Contributor

I see the same effect with v1.5.3. For reference,

import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
…
CategoryPlot plot = (CategoryPlot)chart.getPlot();
plot.setOrientation(PlotOrientation.VERTICAL);

@jfree
Copy link
Owner

jfree commented Jul 20, 2021

Does this fix it for you?

Index: src/main/java/org/jfree/chart/renderer/category/GanttRenderer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8

diff --git a/src/main/java/org/jfree/chart/renderer/category/GanttRenderer.java b/src/main/java/org/jfree/chart/renderer/category/GanttRenderer.java
--- a/src/main/java/org/jfree/chart/renderer/category/GanttRenderer.java (date 1626807961092)
+++ b/src/main/java/org/jfree/chart/renderer/category/GanttRenderer.java (date 1626807961092)
@@ -446,7 +446,7 @@
barBase = RectangleEdge.LEFT;
}
else if (orientation == PlotOrientation.VERTICAL) {

  •        bar = new Rectangle2D.Double(rectStart, java2dValue1, rectBreadth,
    
  •        bar = new Rectangle2D.Double(rectStart, java2dValue0, rectBreadth,
                   rectLength);
           barBase = RectangleEdge.BOTTOM;
       }
    

Best regards,
David

@danno-1
Copy link
Author

danno-1 commented Jul 20, 2021

It does indeed! Thank you very much, David! Especially for your fast response!!

Updated Gantt Chart

@jfree
Copy link
Owner

jfree commented Jul 20, 2021

Thanks for the feedback, I committed that fix for the next release.

@trashgod
Copy link
Contributor

Confirmed using latest JFreeChart 1.5.4-SNAPSHOT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants