Chart Axis Fix-age [message #513752] |
Thu, 11 February 2010 01:19 |
Eclipse User |
|
|
|
package org.swtchart.examples;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.swtchart.Chart;
import org.swtchart.ILineSeries;
import org.swtchart.ISeries.SeriesType;
/**
* An example for line chart.
*/
public class LineChartExample {
private static final double[] ySeries = { 0.0, 0.38, 0.71, 0.92, 1.0, 0.92,
0.71, 0.38, 0.0, -0.38, -0.71, -0.92, -1.0, -0.92, -0.71, -0.38 };
/**
* The main method.
*
* @param args
* the arguments.
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Line Chart Example");
shell.setSize(500, 400);
shell.setLayout(new FillLayout());
// create a chart
Chart chart = new Chart(shell, SWT.NONE);
// set titles
chart.getTitle().setText("Line Chart Example");
chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
// create line series
ILineSeries lineSeries = (ILineSeries) chart.getSeriesSet()
.createSeries(SeriesType.LINE, "line series");
lineSeries.setYSeries(ySeries);
// adjust the axis range
chart.getAxisSet().adjustRange();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
Hi, I'm attempting to use the above sample to ask the question as I'm not suppose to reveal my client's source codes.
I'm trying to do out a graph as shown in the sample, however, the above graph have their range of X and Y axis based on the maximum values.
For example,
This is the original output. Notice the X axis have 15 data points
http://cid-ff31e0d0d4c5b9a9.skydrive.live.com/self.aspx/Imag es/1.png
This is what happened when I remove all the values except the first 3.
The X axis now have 2 data point instead.
http://cid-ff31e0d0d4c5b9a9.skydrive.live.com/self.aspx/Imag es/2.PNG
Is there a way for me to make the axis fixed, so I can make the X axis in the 2nd sample have 15 data points?
Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.02590 seconds