0

I have an issue with JFreeChart in Redhat 6.5. My chart is flipped top-for-bottom.

Issue's image

This is my source code to add chart.

private Control createPartControl() {
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);

    ScrolledComposite sc = new ScrolledComposite(m_parent, SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setLayoutData(layoutData);
    sc.setMinSize(450, 250);

    m_mainComposite = new Composite(sc, SWT.EMBEDDED);
    m_mainComposite.setLayoutData(layoutData);
    m_mainComposite.setBackground(ColorConstants.white);

    Frame frame = SWT_AWT.new_Frame(m_mainComposite);
    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            m_panel.setMaximumDrawHeight(e.getComponent().getHeight());
            m_panel.setMaximumDrawWidth(e.getComponent().getWidth());
            m_panel.setMinimumDrawWidth(e.getComponent().getWidth());
            m_panel.setMinimumDrawHeight(e.getComponent().getHeight());
        }
    });
    m_panel = new ChartPanel(null);
    m_panel.setPopupMenu(null);
    frame.add(m_panel);
    frame.setBackground(Color.white);

    sc.setContent(m_mainComposite);
    return sc;
}

 public void updateContent(List<AggregatedSdcCollectionStat> stats) {
    if (!isChartExsited()) {
        m_chart = createChart(createDataset(stats));
        m_panel.setChart(m_chart);
        setChartExisted(true);
        //m_panel.setVisible(true);
    }
}

private JFreeChart createChart(CategoryDataset categorydataset) {
    String collectionTime = Messages.getString("SdcCollectionStatisticViewItem.chart.xAxis");//$NON-NLS-1$
    String nes = Messages.getString("SdcCollectionStatisticViewItem.chart.yAxis");//$NON-NLS-1$
    JFreeChart jfreechart = ChartFactory
            .createStackedBarChart(null, collectionTime, nes, categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setBaseItemLabelsVisible(true);
    stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    CategoryItemRenderer renderer = categoryplot.getRenderer();
    renderer.setSeriesPaint(0, SUCCESS_CLR);
    renderer.setSeriesPaint(1, ONGOING_CLR);
    renderer.setSeriesPaint(2, MISSING_CLR);
    renderer.setSeriesPaint(3, EXCLUDED_CLR);
    renderer.setBaseItemLabelsVisible(Boolean.FALSE);
    return jfreechart;
}

Executing the jar:

java -jar jfreechart-1.0.2-demo.jar

Console output:

Exception in thread "main"
java.lang.NoClassDefFoundError:org/jfree/ui/ApplicationFrame Caused by:
java.lang.ClassNotFoundException: org.jfree.ui.ApplicationFrame at
java.net.URLClassLoader$1.run(URLClassLoader.java:366) at
java.net.URLClassLoader$1.run(URLClassLoader.java:355) at
java.security.AccessController.doPrivileged(Native Method) at
java.net.URLClassLoader.findClass(URLClassLoader.java:354) at
java.lang.ClassLoader.loadClass(ClassLoader.java:423)

This only happens with Redhat; it works fine on Windows and Ubuntu. Did you see this issue? Can you give me a solution for this case?

Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
  • Nice image but where's your code you need help with? – Wh1T3h4Ck5 May 21 '15 at 13:27
  • Have you tried running jfreechart standard demo to see if that works fine `java -jar jfreechart-1.0.1-demo.jar` ? – bhantol May 21 '15 at 13:45
  • Looks like the `scale()` transform used [here](http://stackoverflow.com/a/9373195/230513). – trashgod May 21 '15 at 13:54
  • That's odd; try with the required libs, for [example](http://stackoverflow.com/a/2603723/230513); edit your question with new information. – trashgod May 21 '15 at 14:00
  • As trashgod was saying - please also add any LD_LIBRARY_PATH etc\ along with CLASSPATH. However that example should just work if you downloaded the full gz and expanded. – bhantol May 21 '15 at 14:31
  • I tried with jfreechart demo and I see that it works fine in Redhat. I dont know why my chart is mirrored in Redhat? Can you give me the reason? – Steven Van Hoof May 21 '15 at 15:38
  • @StevenVanHoof: Possibly an artifact of using the old version, a bug in the SWT bridge or an errant `scale()` somewhere in the paint chain. – trashgod May 24 '15 at 14:38

0 Answers0