SWT Help (Chart Not Filling Layout)

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
aga03
Posts: 3
Joined: Mon Jul 18, 2016 8:17 pm
antibot: No, of course not.

SWT Help (Chart Not Filling Layout)

Post by aga03 » Tue Jul 19, 2016 4:19 pm

Hello, I am trying to incorporate the Dynamic Chart Demo (1) in conjunction with SWT. The issue I am having is regardless of the layout I use. When using a Fill Layout the chart is displayed in right half of the window. When I use a grid layout and setting all the grid data to Fill and setting grab excess space to true, the chart shrinks very small and goes to the bottom left of the window. See code below. I cannot host an image of the output at the moment.

Code:

Code: Select all

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.experimental.chart.swt.ChartComposite;

public class TestChartComposite extends Composite
{
	private TimeSeries series;
	
	public TestChartComposite(Composite parent, int style) 
	{
		super(parent, style);
		
        this.series = new TimeSeries("Random Data");
        final TimeSeriesCollection dataset = new TimeSeriesCollection(this.series);
        final JFreeChart chart = createChart(dataset);
		
		
		new ChartComposite(parent, style, chart);

	}
	
	 private JFreeChart createChart(final XYDataset dataset) {
	        final JFreeChart result = ChartFactory.createTimeSeriesChart(
	            "Dynamic Data Demo", 
	            "Time", 
	            "Value",
	            dataset, 
	            true, 
	            true, 
	            false
	        );
	        final XYPlot plot = result.getXYPlot();
	        ValueAxis axis = plot.getDomainAxis();
	        axis.setAutoRange(true);
	        axis.setFixedAutoRange(60000.0);
	        axis = plot.getRangeAxis();
	        axis.setRange(0.0, 200.0); 
	        return result;
	    }
	
	public static void main(String[] args)
	{
		Display display = new Display();
		
		Shell shell = new Shell(display);
		
		shell.setLayout(new FillLayout());
		
		new TestChartComposite(shell, SWT.NONE);
		
		shell.open();
		
		while(!shell.isDisposed())
		{
			display.readAndDispatch();
		}
	}
}

aga03
Posts: 3
Joined: Mon Jul 18, 2016 8:17 pm
antibot: No, of course not.

Re: SWT Help (Chart Not Filling Layout)

Post by aga03 » Thu Jul 21, 2016 2:42 pm

Has anyone heard of this happening before?

aga03
Posts: 3
Joined: Mon Jul 18, 2016 8:17 pm
antibot: No, of course not.

Re: SWT Help (Chart Not Filling Layout)

Post by aga03 » Wed Jul 27, 2016 2:46 pm

Any Ideas? Any others forums I should check?

Locked