labels of rangeAxis,domian and legen are NOT visible

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
muchtar
Posts: 4
Joined: Fri Aug 24, 2012 9:50 pm
antibot: No, of course not.

labels of rangeAxis,domian and legen are NOT visible

Post by muchtar » Fri Aug 24, 2012 11:05 pm

Hallo,

i am doing eclipse plugin and need to implement a linechart in a View. My problem as the subject states, i dont see the labels in the y and x axis neither the legend labels. Below is the working code as a java app then follows my code "almost the same" but the chart is to be shown in a View. I used org.jfree.experimental.chart.swt.ChartComposite to contain the line chart. thank you for any help!

working snippet using ApplicationFrame http://goo.gl/Klt9F

Code: Select all

public LineChartDemo1(final String title) {
        super(title);
        final CategoryDataset dataset = createDataset();
        final JFreeChart chart = createChart(dataset);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(500, 270));
        setContentPane(chartPanel);
    }
    private CategoryDataset createDataset() {
        
        // row keys...
        final String series1 = "First";
        final String series2 = "Second";
        //final String series3 = "Third";

        // column keys...
        final String type1 = "Type 1";
        final String type2 = "Type 2";
       
        // create the dataset...
        final DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        dataset.addValue(1.0, series1, type1);
        dataset.addValue(5.0, series2, type1);
       dataset.addValue(4.0, series3, type7);
       dataset.addValue(3.0, series3, type8);

        return dataset;
                
    }
    private JFreeChart createChart(final CategoryDataset dataset) {
        
        // create the chart...
        final JFreeChart chart = ChartFactory.createLineChart(
            "Line Chart Demo 1",       // chart title
            "Type",                    // domain axis label
            "Value",                   // range axis label
            dataset,                   // data
            PlotOrientation.VERTICAL,  // orientation
            true,                      // include legend
            true,                      // tooltips
            false                      // urls
        );

     
        chart.setBackgroundPaint(Color.white);

        final CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setRangeGridlinePaint(Color.white);

        // customise the range axis...
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setRange(0, 100);
        rangeAxis.setTickUnit(new NumberTickUnit(10));
          
        return chart;
    }
    
    public static void main(final String[] args) {

        final LineChartDemo1 demo = new LineChartDemo1("Line Chart Demo");
        demo.pack();
        RefineryUtilities.centerFrameOnScreen(demo);
        demo.setVisible(true);

    }

}
my Code:

Code: Select all

public class QualityView extends ViewPart {
	
	private DefaultCategoryDataset dataset;
	private JFreeChart chart;
	private ChartComposite chartComposite;
	SashForm sashForm;
	
	public QualityView() {
		// TODO Auto-generated constructor stub
	}

	private DefaultCategoryDataset createCategoryDataSet(String analysis){
		//row keys
		 final String series1 = "Precision";
		 final String series2 = "Recall";
		
	    final String type1 = "Type 1";
	    final String type2 = "Type 2";
	    final String type3 = "Type 3";
	    final String type4 = "Type 4";
	    final String type5 = "Type 5";
	    final String type6 = "Type 6";
	    final String type7 = "Type 7";
	    final String type8 = "Type 8";
	    
		final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		
		dataset.addValue(10.0, series1, type1);
        dataset.addValue(40.0, series1, type2);
        dataset.addValue(30.0, series1, type3);
        dataset.addValue(50.0, series1, type4);
        dataset.addValue(50.0, series1, type5);
        dataset.addValue(70.0, series1, type6);
        dataset.addValue(70.0, series1, type7);
        dataset.addValue(80.0, series1, type8);

        dataset.addValue(50.0, series2, type1);
        dataset.addValue(70.0, series2, type2);
        dataset.addValue(60.0, series2, type3);
        dataset.addValue(80.0, series2, type4);
        dataset.addValue(40.0, series2, type5);
        dataset.addValue(40.0, series2, type6);
        dataset.addValue(20.0, series2, type7);
        dataset.addValue(10.0, series2, type8);

		return dataset;
	}
	private JFreeChart createLineChart(final CategoryDataset dataset){
		final JFreeChart chart = ChartFactory.createLineChart("Analysis Quality", "Time", "Quality", 
					dataset, PlotOrientation.VERTICAL, true, true, false);
		
		    chart.setBackgroundPaint(Color.white);
	        final CategoryPlot plot = (CategoryPlot) chart.getPlot();
	        plot.setBackgroundPaint(Color.lightGray);
	        plot.setRangeGridlinePaint(Color.white);

	        // customise the range axis...
	        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
	        rangeAxis.setRange(0, 100);
	        rangeAxis.setTickUnit(new NumberTickUnit(10));
	        
	        
		return chart;
	}
	synchronized public void updateLineChart(final String analysisName){
		
        
		UIUtils.getDisplay().asyncExec(new Runnable() {
			
			@Override
			public void run() {
				CategoryDataset dataset = createCategoryDataSet(analysisName);
				
				JFreeChart chart = createLineChart(dataset);
				chartComposite.setChart(chart);
				chartComposite.chartChanged(new ChartChangeEvent(chart));
				
			}
		});
		
	}
	@Override
	public void createPartControl(Composite parent) {
		parent.setLayout(new GridLayout(4, false));
		
			@Override
			public void widgetSelected(SelectionEvent e) {
				
				updateLineChart("string");
				
			}
		});
		
		sashForm = new SashForm(parent, SWT.VERTICAL|SWT.BORDER|SWT.SMOOTH);
		GridData gd_sashForm = new GridData(SWT.FILL, SWT.FILL, true, true);
		gd_sashForm.horizontalSpan = 4;
		sashForm.setLayoutData(gd_sashForm);
		sashForm.SASH_WIDTH = 1;
		
		// TODO Auto-generated method stub
		chartComposite = new ChartComposite(sashForm, SWT.NONE,null,true);
		
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}
	
}

Thanks!

muchtar
Posts: 4
Joined: Fri Aug 24, 2012 9:50 pm
antibot: No, of course not.

Re: labels of rangeAxis,domian and legen are NOT visible

Post by muchtar » Sat Aug 25, 2012 12:21 pm

i have solved it as soon as i replaced

Code: Select all

org.jfree.experimental.chart.swt.ChartComposite
with

Code: Select all

CategoryDataset dataset = createCategoryDataSet(analysisName);
				
				JFreeChart chart = createLineChart(dataset);
				
				embeddedComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
				Frame fr = SWT_AWT.new_Frame(embeddedComp);
				ChartPanel panel = new ChartPanel(chart);
				fr.add(panel);
meaning that the chartcomposite contains the chart and the curves are ok but no labels at all.
If anyone has an idea please shoot it!
Muchtar

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: labels of rangeAxis,domian and legen are NOT visible

Post by david.gilbert » Mon Aug 27, 2012 8:22 pm

I'm pretty sure there are some SWT bug reports and patches in the the trackers at SourceForge that address this issue. I'll see if I can dig them out and supply links (also I'd like to get these patches committed of course).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: labels of rangeAxis,domian and legen are NOT visible

Post by david.gilbert » Mon Aug 27, 2012 11:06 pm

This is the one I was referring to:

http://sourceforge.net/tracker/?func=de ... tid=315494
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

muchtar
Posts: 4
Joined: Fri Aug 24, 2012 9:50 pm
antibot: No, of course not.

Re: labels of rangeAxis,domian and legen are NOT visible

Post by muchtar » Thu Aug 30, 2012 1:11 am

ok thank you! i hope you can fix it.

uli
Posts: 24
Joined: Sat Mar 14, 2009 3:22 pm
Location: Berlin

Re: labels of rangeAxis,domian and legen are NOT visible

Post by uli » Mon Oct 01, 2012 1:33 pm

Hi,

Is there any news about this topic? So far I used SWT_AWT to include JFreeCharts into Eclipse. But since the experimental swt.ChartComposite is supposed to be faster, I wanted to try this. I found two examples in the internet:
1)http://www.devdaily.com/java/jwarehouse ... java.shtml
2)http://www.ayukucode.org/pie-chart-with ... rt-on-swt/

When I copy the source into my Eclipse-workspace and let it run, in both cases, the chart comes without any labels, neither in the legend, nor at the axes, nor in the graph itself. Only the tooltips come correctly.

I have just updated JFreeChart to the latest version (1.0.14) and for SWT I use org.eclipse.swt.win32.win32.x86_3.7.2.v3740f.jar

I am thankful for any ideas!

Julia

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: labels of rangeAxis,domian and legen are NOT visible

Post by david.gilbert » Mon Oct 01, 2012 8:12 pm

The fix will be included with the 1.0.15 release. You can find the fix in SVN if you need it right away.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

muchtar
Posts: 4
Joined: Fri Aug 24, 2012 9:50 pm
antibot: No, of course not.

Re: labels of rangeAxis,domian and legen are NOT visible

Post by muchtar » Tue Oct 02, 2012 12:45 pm

hi,
the way i solved it currently is by updating the Jfreechart BACKWARD to an older version, then i used the expermintalChartComposite then it worked.
PS:
i dont have the software now to tell you what was the version.
As in eclipse "View", i had to plot the chart even if dataset is empty, becuase otherwise the chartcomposite shows some craps from the backgroung GUIs. Maybe this is because of the expandBar widget i used

cheers
muchtar

uli
Posts: 24
Joined: Sat Mar 14, 2009 3:22 pm
Location: Berlin

Re: labels of rangeAxis,domian and legen are NOT visible

Post by uli » Sat Oct 06, 2012 4:58 pm

OK, thanks David! I'll patiently wait for the 1.0.15 release then ;-)

Locked