### RCHART, User Guide

Copyright 2005, J4L Components (http://www.java4less.com)
Go bak to contents

### RChart , The layout

- Chart's Layout
- The title
- The legend

#### Chart's layout

Charts are made of the following 6 areas (See example):

- Chart area: this is the area reserved for the plotter (orange area).
- Left margin: this is the area reserved for the Y Axis label and ticks.
- Right margin: this is the area reserved for the Y2 Axis label and ticks.
- Top margin: this is the area reserved for the title.
- Bottom margin: this is the area reserved for the Y Axis label and ticks.
- Legend margin: this is the area reserved for the legend. The legend can be located at the TOP, at the BOTTOM or to the RIGHT.

The previous example was created with the following parameters:

| Parameters | Description | Equivalent java class/property
| LEFT_MARGIN=0.18 RIGHT_MARGIN=0.1 TOP_MARGIN=0.1 BOTTOM_MARGIN=0.1 LEGEND_MARGIN=0.2 LEGEND_POSITION=BOTTOM LEGEND=FALSE | 18 % of the width (default is 12.5%) 10 % of the width (default is 12.5%) 10 % of the height (default is 12.5%) 10 % of the height (default is 12.5%) 20 % of the height (default) Legend is at the bottom (default is RIGHT) Do not display legend, leave space empty (default is TRUE) | Chart.leftMargin=0.18; Chart.rightMargin=0.1; Chart.topMargin=0.1; Chart.bottomMargin=0.1; Chart.legendMargin=0.2; Chart.layout =LAYOUT_LEGEND_BOTTOM; Chart.legend=null;

A margin of 0.18 means 18% of the width (or height) of the chart.

The space reserved for the axis is divided in 2 areas of equal size:

- Label area (see blue rectangle in screenshot).
- Scale (ticks) area (see green rectangle in screenshot).

if you are using a second Y2 axis, there is an additional parameter:

Parameters | Description | Equivalent java class/property
CHART_SECOND_AXIS_MARGIN=0.05 | 5 % of the width | Chart.secondYAxisMargin=0.05;

That is the blue rectangle in the screenshot. This parameter is normally set to 0 (default).

#### The title

As already stated, the title is painted in the area reserved by the top margin parameters. The following parameters control the title:

Parameters | Description | Equivalent java class/property
TITLECHART=Sales 1999 \n An overview TITLE_FONT=Dialog|BOLD|12 TITLE_COLOR=0x404040 | Text of the title, you can use "\n" to create a new line. Font of the title. Color of the text. | Chart.title= new Title("Sales 1999 \\n An overview"); Chart.title.font=Graphicsprovider.getFont( "Dialog", ChartFont.BOLD,12); Chart.title.color= GraphicsProvider.getColor(0x40, 0x40, 0x40);

The result of the above parameters is:

#### The Legend

The legend is the small box next to the chart that describes the content of the chart. The legend is placed in the space reserved by LEGEND_MARGIN and at the position specified by LEGEND_POSITION which can be TOP, BOTTOM or RIGHT.

Parameters | Description | Equivalent java class/property
LEGEND_FILL=WHITE LEGEND_COLOR=0xff LEGEND_FONT=Dialog|ITALIC|10 LEGEND_VERTICAL=FALSE LEGEND_BORDER=0.2|0xff|NORMAL LEGEND_POSITION=TOP LEGEND_MARGIN=0.12 | Background color of the legend Color of the font Font Layout of the legend (vertical or horizontal) Style of the line of the border Position Reserved area | Chart.legend.background=new FillStyle(Color.white); Chart.legend.color= GraphicsProvider.getColor( ChartColor.BLUE); Chart.legend.color= Graphicsprovider.getFont(Dialog", ChartFont.ITALIC,10); Chart.legend.verticalLayout=false; Chart.legend.border=new LineStyle(0.2, GraphicsProvider.getColor( ChartColor.BLUE) ,LineStyle.NORMAL); Chart.layout =LAYOUT_LEGEND_TOP; Chart.legendMargin=0.12;

The result of the above parameters is: