J4L-CHART for Ruby
Copyright 2011, J4L
Components (http://www.java4less.com)
Go bak to contents
J4L-Chart , first steps.
Installation
The installation of
J4L-Chart
is very simple, just add the delivered ruby source code files to your Ruby
project.
Requirements
J4L-Chart will work with:
Where
to start
As starting point we recommend
you not to create a chart from scratch but to take one of the examples we provide
and start working by modifying it.
But first of all you must
be aware that there are 2 ways to create a chart:
- either you create it
using the API, creating the Chart Ruby objects and setting the
properties (see file chart_examples.rb)
- or you create the chart
by means of the ChartLoader. In this case you do not have to worry
about the API. You just have to create a list of parameters and use the
ChartLoader class to create the chart (see examples in directory data/examples).
We recommend you to use the
second approach (using the ChartLoader) for the following reasons:
- It is easier to learn.
- It is easier to develop
and debug.
- You can reuse the code since the same code can load different charts.
Nevertheless this guide
provides both the parameter names and the equivalent Ruby class and property.
Format
of the parameters
If you are going to create
you chart by mean of the chart loader (instead of using the Java API), there
are some parameters that have a special format:
- Colors: predefined
values are:
RED
WHITE
GREEN
BLUE
YELLOW
GRAY
DARKGRAY
BLACK
LIME
OLIVE
MAROON
NAVY
PURPLE
TELA
FUCHSIA
AQUA
ALICEBLUE
ANTIQUEWHITE
AQUAMARINE
|
AZURE
BEIGE
BLUEVIOLET
BROWN
BORLYWOOD
CORAL
CYAN
DARKGOLDENROD
DARKGREEN
DARKOLIVEGREEN
DARKORANGE
DARKORCHID
DARKSALMON
DARKTURQUOISE
DARKVIOLET
DEEPPINK
DEEPSKYBLUE
FORESTGREEN
GOLD |
GOLDENROD
GREENYELLOW
HOTPINK
INDIANRED
IVORY
LAVENDER
LAWNGREEN
LIGHTBLUE
LIGHTCORAL
LIGHTCYAN
LIGHTGRAY
LIGHTPINK
LIGHTSALMON
LIGHTSKYBLUE
LIGHTYELLO
LIMEGREEN
MAGENTA
MEDIUMBLUE
MEDIUMPURPLE
|
MIDNIGHTBLUE
ORANGE
ORANGERED
ORCHID
PALEGREEN
PALETURQUOISE
PALEVIOLETRED
PINK
PLUM
PURPLE
SALMON
SEAGREEN
SIENNA
SKYBLUE
SPRINGGREEN
TURQUOISE
VIOLET
YELLOWGREEN |
You can also use
the RGB numeric value of a color as parameter. For example "#FF0000"
is red (RGB format), "#00FF00" is green and so on.
- List of values.
List of values a separated by "|", only certain parameters like
FiIll styles use another separator.
- Fonts have the
format <font name>|<style>|<size>. Style can be PLAIN, ITALIC
or BOLD. Example: "Arial|BOLD|12"
- Line styles have
the format <width>|<color>|<style>. Style can be LINE, DASHED
or DOTS. Example: "1|RED|LINE".
You can define transparency in line styles using an additional parameter:
<width>|<color>|<style>|<transparency>. <transparency>
is a value between 0 (full transparent) and 1 (opaque). We recommend 0.5.
- Fill style: there
are several options:
- <color>: for
plain color filling.
- <color>|<transparentcy>:
for transparent color filling. <transparency> is a value between
0 (full transparent) and 1 (opaque). We recommend 0.5.