com.java4less.rchart
Class LinePlotter

java.lang.Object
  |
  +--com.java4less.rchart.ChartComponent
        |
        +--com.java4less.rchart.Plotter
              |
              +--com.java4less.rchart.LinePlotter
Direct Known Subclasses:
CurvePlotter

public class LinePlotter
extends Plotter

 This is the plotter used to draw a line chart. It only accepts DataSeries of type LineDataSerie.

Example of Line chart:

// data
double[] d1={2,1 ,2 ,3 ,4 ,5 ,4 ,3};
double[] dmax1={0.5,0 ,0.2 ,0.1 ,0.5 ,0,1 ,0};
MaxMinDataSerie data1= new MaxMinDataSerie(d1,null);
data1.bubbleChart=true;
data1.fillBubble=true;
data1.drawPoint=true;
data1.pointColor=GraphicsProvider.getColor(ChartColor.GREEN);
data1.setMaxMinValues(dmax1,null);

double[] d2={2,1 ,2 ,3 ,4 ,5 ,4 ,3};
LineDataSerie data2= new LineDataSerie(d2,new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS));
data2.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);
data2.valueColor=GraphicsProvider.getColor(ChartColor.YELLOW);
data2.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);

double[] d3={1,2 ,3 ,2 ,3 ,4 ,1 ,2};
double[] dmax3={0,0.2 ,0.2 ,0 ,0.2 ,0,0.3 ,0};
MaxMinDataSerie data3= new MaxMinDataSerie(d3,null);
data3.bubbleChart=true;
data3.fillBubble=false;
data3.drawPoint=true;
data3.pointColor=GraphicsProvider.getColor(ChartColor.WHITE);
data3.setMaxMinValues(dmax3,null);

double[] d4={1,2 ,3 ,2 ,3 ,4 ,1 ,2};
LineDataSerie data4= new LineDataSerie(d4,new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_DOTS));
data4.valueFont=GraphicsProvider.getFont("Arial",ChartFont.PLAIN,10);
data4.valueColor=GraphicsProvider.getColor(ChartColor.YELLOW);
data4.valueFont=GraphicsProvider.getFont("Arial",ChartFont.BOLD,10);

// create title
Title title=new Title("Price");
title.color=GraphicsProvider.getColor(ChartColor.WHITE);

// create axis
Axis  XAxis=new Axis(Axis.HORIZONTAL,new Scale());
Axis  YAxis=new Axis(Axis.VERTICAL,new Scale());
XAxis.tickAtBase=true; // draw also first tick
XAxis.scale.min=-1;
XAxis.ceroAxis=Axis.CEROAXIS_NO;
YAxis.ceroAxis=Axis.CEROAXIS_NO;
YAxis.scale.min=0;
YAxis.scale.max=6;
YAxis.DescColor=GraphicsProvider.getColor(ChartColor.WHITE);
YAxis.scaleTickInterval=1;
XAxis.scaleTickInterval=1;
XAxis.bigTickInterval=1;
XAxis.DescColor=GraphicsProvider.getColor(ChartColor.WHITE);
String[] lbls={"","8 Jan.","9 Jan.","10 Jan.","11 Jan.","12 Jan.","13 Jan.","14 Jan.","15 Jan."};
XAxis.tickLabels=lbls;
XAxis.style =new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_NORMAL);
YAxis.style =new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.WHITE),LineStyle.LINE_NORMAL);

HAxisLabel XLabel= new HAxisLabel("Week",GraphicsProvider.getColor(ChartColor.WHITE),GraphicsProvider.getFont("Arial",ChartFont.ITALIC,12));
VAxisLabel YLabel= new VAxisLabel("Value",GraphicsProvider.getColor(ChartColor.WHITE),GraphicsProvider.getFont("Arial",ChartFont.ITALIC,12));

// plotter
LinePlotter plot=new LinePlotter();

// create chart
Chart chart=new Chart(title,plot,XAxis,YAxis);
chart.XLabel=XLabel;
chart.YLabel=YLabel;
chart.addSerie(data1);
chart.addSerie(data2);
chart.addSerie(data4);
chart.addSerie(data3);
chart.back=new FillStyle(GraphicsProvider.getColor(ChartColor.BLACK));


Field Summary
 boolean fixedLimits
          clip lines using maximum and minimum values if the scale?
 boolean hideCeros
          if true, 0 values will not have a label
 int MaxMinType
          Type of the chart (ONLY MAXMIN CHARTS).
static int MM_CANDLESTICK
          Candlestick chart
static int MM_NORMAL
          normal line chart
static int MM_OHLC
          OHLC chart
 int pointSize
          size of squares that represent points.
static int TYPE_B_SPLINES
          b-spline curve.
static int TYPE_CUBIC_NATURAL
          curve.
static int TYPE_LEAST_SQUARES_LINE
          create a line using the least squares method.
static int TYPE_LINE
          normal lines
 
Fields inherited from class com.java4less.rchart.Plotter
back, backImage, depth, visibleHeight, visibleWidth, XScale, Y2Scale, YScale
 
Fields inherited from class com.java4less.rchart.ChartComponent
height, width, x, y
 
Constructor Summary
LinePlotter()
           
 
Methods inherited from class com.java4less.rchart.Plotter
addSerie, getCombinable, getNeedsAxis, getSerie, getSeriesCount, plot, plotBackground, replaceSerie, setSerie
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hideCeros

public boolean hideCeros
if true, 0 values will not have a label


TYPE_LINE

public static final int TYPE_LINE
normal lines

See Also:
Constant Field Values

TYPE_CUBIC_NATURAL

public static final int TYPE_CUBIC_NATURAL
curve. You must use the class CurvePlotter.

See Also:
Constant Field Values

TYPE_B_SPLINES

public static final int TYPE_B_SPLINES
b-spline curve. You must use the class CurvePlotter.

See Also:
Constant Field Values

TYPE_LEAST_SQUARES_LINE

public static final int TYPE_LEAST_SQUARES_LINE
create a line using the least squares method.

See Also:
Constant Field Values

MM_NORMAL

public static final int MM_NORMAL
normal line chart

See Also:
Constant Field Values

MM_OHLC

public static final int MM_OHLC
OHLC chart

See Also:
Constant Field Values

MM_CANDLESTICK

public static final int MM_CANDLESTICK
Candlestick chart

See Also:
Constant Field Values

fixedLimits

public boolean fixedLimits
clip lines using maximum and minimum values if the scale?


MaxMinType

public int MaxMinType
Type of the chart (ONLY MAXMIN CHARTS). The value can be (NORMAL, OHLC o CANDLESTICK. The first one needs maximum and minimum values, the other two also close values.


pointSize

public int pointSize
size of squares that represent points.

Constructor Detail

LinePlotter

public LinePlotter()