import jas.hist.*;
import javax.swing.*;
import java.awt.GridLayout;

public class Example4 extends JFrame
{
	Example4()
	{
		super("Example 4");
					 
		double[] data =	{ 0, 1,	3, 5, 7, 9,	11,	13,	5, 0 };
			  
		JPanel panel = new JPanel(new GridLayout(3,1));

		JASHist	plot1 =	new	JASHist();
		plot1.addData(new ArrayDataSource(data)).show(true);
		panel.add(plot1);
					 
		// A plot with a String	axis
					 
		JASHist	plot2 =	new	JASHist();
		plot2.addData(new StringDataSource(data)).show(true);
		panel.add(plot2);
					 
		// A plot with a Date axis
					 
		JASHist	plot3 =	new	JASHist();
		plot3.addData(new DateDataSource(data)).show(true);
		panel.add(plot3);
							 
		setContentPane(panel);
		setSize(500,500);
		show();
	}
	public static void main(String[] argv)
	{
		new	Example4();
	}
}
class StringDataSource extends ArrayDataSource
{
	StringDataSource(double[] data)
	{
		super(data);
		labels = new String[data.length];
		String alphabet	= "abcdefghijklmnopqrstuvwxyz";
		for	(int i=0; i<labels.length; i++)	
			labels[i] =	alphabet.substring(i,i+1);
	}
	public int getAxisType() { return STRING; }
	public String[]	getAxisLabels()	{ return labels; }	
	private	String[] labels;
}
class DateDataSource extends ArrayDataSource
{
	DateDataSource(double[]	data)
	{
		super(data);
		max	= System.currentTimeMillis()/1000; // now
		min	= max -	90*60; // 90 minutes ago
	}
	public int getAxisType() { return DATE;	}
	public double getMin() { return	min; }
	public double getMax() { return	max; }
	private	double min,	max;
}
