com.java4less.rchart
Class Legend

java.lang.Object
  |
  +--com.java4less.rchart.ChartComponent
        |
        +--com.java4less.rchart.Legend

public class Legend
extends ChartComponent

The legend contains the description of the data displayed in the chart. A legend can be displayed on the right side of the chart (default), at the top or at the bottom. The property Layout of the Chart modifies the behaviour.

A legend is a list of pairs:

LineStyle + Text: a line will be displayed next to the next.
FillStle + Text: a small boy will be displayed nex to the text.
Image + Text: the image will be displayed next to the text.

Example:

Legend l=new Legend();
l.border=new LineStyle(0.2f,GraphicsProvider.getColor(ChartColor.BLACK),LineStyle.LINE_NORMAL);
l.addItem("Company A",GraphicsProvider.getColor(ChartColor.CYAN));
l.addItem("Company B",GraphicsProvider.getColor(ChartColor.GREEN));

the legend must be assigned to the chart:

chart.legend=l;


Field Summary
 FillStyle background
          background of the legend.
 LineStyle border
          border of the legend.
 ChartColor color
           
 ChartFont font
           
 java.lang.String legendLabel
          use the legendLabel property to define the legend using the label @ tags.
 int legendMargin
          margin of the legend.
 java.lang.String title
          title of the legend
 boolean verticalLayout
          if false the items will be displayed from left to right.
 
Fields inherited from class com.java4less.rchart.ChartComponent
height, width, x, y
 
Constructor Summary
Legend()
           
 
Method Summary
 void addItem(java.lang.String name, java.lang.Object icon)
          Adds an item.
 void draw(ChartGraphics g)
           
 void drawHorizontal(ChartGraphics g)
           
 void drawVertical(ChartGraphics g)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

background

public FillStyle background
background of the legend.


border

public LineStyle border
border of the legend.


legendMargin

public int legendMargin
margin of the legend.


title

public java.lang.String title
title of the legend


color

public ChartColor color

font

public ChartFont font

verticalLayout

public boolean verticalLayout
if false the items will be displayed from left to right.


legendLabel

public java.lang.String legendLabel
use the legendLabel property to define the legend using the label @ tags. This is a very flexible approach since you can define the format of the legend and its contents.

Constructor Detail

Legend

public Legend()
Method Detail

addItem

public void addItem(java.lang.String name,
                    java.lang.Object icon)
Adds an item. The item is a description and an icon. The icon can be an Image, a Linestyle or a FillStyle.


draw

public void draw(ChartGraphics g)

drawHorizontal

public void drawHorizontal(ChartGraphics g)

drawVertical

public void drawVertical(ChartGraphics g)