|
|
|
- I
can only plot a maximum of 7 points and 3 data series.
- How
to create a gif file with jdk 1.1
- The
axis is displayed as a thick line and it is very slow.
- Axis
Labels are not properly displayed during scroll
- How
do I create a chart reading from a file?
- Can
I use RChart with Swing?
- How
to embed the servlet in a HTML page.
- How
do I use the Applet with ASP
- How
do I use the Applet with Php
- How
do I use the Applet with JSP
- How
do I use the Servlet with JSP
- How
do I use the Bean with JSP
- Servlet
running on Linux does not show text
|
1. I can only plot a maximum of 7 points and 3 data series. |
This is a restriction
in the evaluation version of RChart. The registered version can plot up
to 5000 point and a unlimited number of series.
|
2. How to create a gif file with jdk 1.1 |
This is an example:
public boolean
saveToGIF(Chart c,String psFile) {
try {
//create
image java.awt.Image
image=c.createImage(c.getSize().width,c.getSize().height);
c.paint(image.getGraphics
);
// open file
java.io.File
f=new java.io.File(psFile);
f.delete();
java.io.FileOutputStream
of=new java.io.FileOutputStream(f);
// encode
buffered image to a gif
GifEncoder
encoder = new GifEncoder(image,of);
encoder.encode();
of.close();
}
catch (Exception
e) { System.out.println(e.getMessage()); return false;}
return true;
}
|
3. The axis is displayed as a thick line and it is very slow. |
The problem could
be the TICK_INTERVALX parameter. The default is 1. This means that will
try to draw 1 tick per unit. If your xscale_max is 10000 then it will
try to draw 10000 ticks and will result in a ugly line which is very slow
to be displayed. In this case you could set the TICK_INTERVALX to 1000.
|
4. Axis Labels are not properly displayed during scroll |
RChart needs to
have a background color or image. For example: chart.back=new FillStyle(java.awt.Color.white);
|
5. How do I create a chart reading from a file?. |
This is an example
of reading a chart from a file:
<APPLET CODEBASE
= "./"
CODE = "com.java4less.rchart.ChartApplet.class"
NAME = "TestApplet"
WIDTH = 500 HEIGHT = 500 HSPACE = 0 VSPACE = 0 ALIGN = middle>
<PARAM
NAME = "DATAFILE" VALUE = "data.html">
</APPLET>
the file data.html
should contain:
TITLECHART=Sales
1999
LEGEND=TRUE
XLABEL=Month
YLABEL=Million $
XAXIS_LABELS=June|July|Aug.|Sept.|Oct.|Nov.|Dec.
SERIE_1=Products
SERIE_2=Services
SERIE_STYLE_1=0.2|RED|LINE
SERIE_FONT_1=Arial|PLAIN|8
SERIE_FONT_2=Arial|PLAIN|8
SERIE_COLOR_1=RED
SERIE_COLOR_2=BLUE
SERIE_POINT_COLOR_1=RED
SERIE_POINT_COLOR_2=BLUE
SERIE_POINT_1=true
SERIE_POINT_2=true
SERIE_STYLE_2=0.2|BLUE|LINE
SERIE_DATA_1=12|43|50|45|30|32|42
SERIE_DATA_2=20|41|48|39|36|34|50
SERIE_TYPE_1=LINE
SERIE_TYPE_2=LINE
CHART_BORDER=0.2|BLACK|LINE
CHART_FILL=LIGHTGRAY
BIG_TICK_INTERVALX=1
BIG_TICK_INTERVALY=10
YSCALE_MIN=0
LEGEND_BORDER=0.2|BLACK|LINE
LEGEND_FILL=WHITE
XAXIS_GRID=0.2|WHITE|DASHED
YAXIS_GRID=0.2|WHITE|DASHED
XAXIS_TICKATBASE=true
BACK_IMAGE=back16.gif
NOTE: you can put
only variable paramters in the file (e.g. SERIE_DATA_1 and SERIE_DATA2).
The rest of the parameters can be put in the applet parameters.
|
6. Can I use RChart with Swing? |
Yes, RChart is 100%
java.awt so you can use it with swing also. RChart is a subclass of java.awt.canvas.
It is however possible
that you experience problems if you mix Light weight and heavy weight
Java components (java.awt and swing). In that case you can modify the
Chart.java source code to inherit from JPanel instead of java.awt.Canvas.
|
7. How to embed the
servlet in a HTML page. |
The result of the
Servlet is an Image so you must use the <img> tag.This is how to
embed the result of the charting servlet into an HTML page:
<img src="http://localhost:8080/examples/servlet/RChartServlet?DATAFILE=http://localhost:8080/examples/ChartData1.htm">.
|
8. How do I use the Applet with ASP |
The following example
will create an area chart (it is very similar to the example Chart2.htm).
It will retrieve
the data from an MSAccess database that contains a table called
"salesMonth". This table has three fields: "Products"
(integer), "Services" (integer) and "salesMonth" (date),
which contains the sales for several months.
The example will
display the sales of the last 6 months. It will create a HTML page that
contains the applet. Most of the parameters of the applet are constant,
however the date labels and the sales data is retrieved from the DB.
<%@ LANGUAGE="VBSCRIPT"
%>
<%'
variables used to store the data used as parameter for the applet
dim labels, values1,values2
%>
<HTML>
<HEAD> </HEAD>
<BODY>
<APPLET
CODEBASE = "."
CODE = "com.java4less.rchart.ChartApplet.class"
NAME = "TestApplet"
WIDTH = 500 HEIGHT = 500
>
<!--
**** VARIABLE DATA, use VBScript to retrieve series data values
from database **** -->
<%
' get data from last 6 months
set Connect=Server.CreateObject("ADODB.Connection")
' open
db using a System ODBC data source called "Data"
Connect.ConnectionString="DSN=data;"
Connect.Open
' get
sales data, execute SQL
set rs=Connect.Execute("Select * from SalesMonth Order by salesMonth
DESC")
i=1
values1=""
values2=""
labels=""
' loop,
plot only last 6 months
while (not rs.eof) and (i<=6)
if (i>1) then
' add separators to create list of values
values1= "|" & values1
values2= "|" & values2
labels= "|" & labels
end if
' get month name
labels= "" & MonthName(DatePart("m",rs("salesMonth")),1)
& labels
' get sales of products
values1= "" & rs("Product") & values1
' get sales of services
values2= "" & rs("Services") & values2
i=i+1
rs.movenext
wend
rs.close
Connect.close
set Connect=nothing
%>
<!--
**** output of calculated variables**** -->
<PARAM NAME = "XAXIS_LABELS" VALUE = "<%=labels%>">
<PARAM NAME = "SERIE_DATA_2" VALUE = "<%=values1%>">
<PARAM NAME = "SERIE_DATA_1" VALUE = "<%=values2%>">
<!-- **** CONSTANT DATA **** -->
<PARAM
NAME = "TITLECHART" VALUE = "Sales 1999">
<PARAM NAME = "LEGEND" VALUE = "TRUE">
<PARAM NAME = "XLABEL" VALUE = "Month">
<PARAM NAME = "YLABEL" VALUE = "Million $">
<PARAM NAME = "SERIE_1" VALUE = "Products">
<PARAM NAME = "SERIE_2" VALUE = "Services">
<PARAM NAME = "SERIE_STYLE_1" VALUE = "0.2|0x663300|LINE">
<PARAM NAME = "SERIE_STYLE_2" VALUE = "0.2|0x99|LINE">
<PARAM NAME = "SERIE_FILL_1" VALUE = "RED">
<PARAM NAME = "SERIE_FILL_2" VALUE = "0x99cc">
<PARAM NAME = "SERIE_FONT_1" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_FONT_2" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_POINT_1" VALUE = "true">
<PARAM NAME = "SERIE_POINT_2" VALUE = "true">
<PARAM NAME = "SERIE_TYPE_1" VALUE = "LINE">
<PARAM NAME = "SERIE_TYPE_2" VALUE = "LINE">
<PARAM NAME = "CHART_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "CHART_FILL" VALUE = "LIGHTGRAY">
<PARAM NAME = "BIG_TICK_INTERVALX" VALUE = "1">
<PARAM NAME = "BIG_TICK_INTERVALY" VALUE = "1">
<PARAM NAME = "YSCALE_MIN" VALUE = "0">
<PARAM NAME = "TICK_INTERVALY" VALUE = "100">
<PARAM NAME = "LEGEND_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "LEGEND_FILL" VALUE = "WHITE">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "BACK_IMAGE" VALUE = "back13.gif">
</APPLET>
</BODY>
</HTML>
|
9. How do I use the Applet with Php |
The following example
will create an area chart (it is very similar to the example Chart2.htm).
It will retrieve
the data from an MSAccess database that contains a table called
"salesMonth". This table has three fields: "Products"
(integer), "Services" (integer) and "salesMonth" (date),
which contains the sales for several months.
The example will
display the sales of the last 6 months. It will create a HTML page that
contains the applet. Most of the parameters of the applet are constant,
however the date labels and the sales data is retrieved from the DB.
<HTML>
<HEAD></HEAD>
<BODY>
<APPLET
CODEBASE = "."
CODE = "com.java4less.rchart.ChartApplet.class"
NAME = "TestApplet"
WIDTH = 500 HEIGHT = 500 ALIGN = middle
>
<!--
**** VARIABLE DATA, use Php to retrieve series data values from
database ****
-->
<?
$labels="";
$values2="";
$values1="";
$i=1;
/*
connect to database
open db using a System ODBC data source called "Data"
*/
$odbcid = odbc_connect ("data", "", "",
"");
/*
get
sales data, execute SQL*/
$resultid = odbc_exec ($odbcid, "Select * from SalesMonth Order
by salesMonth DESC") ;
/* iterate on sales data, up to 6 rows */
while (($i <= 6) and (odbc_fetch_row($resultid))) {
/* concatenate | separator */
if ($i>1) {
$values1= "|" . $values1;
$values2= "|" . $values2;
$labels= "|" . $labels;
}
/* concatenate value */
$values1= odbc_result ($resultid, "Services") . $values1;
$values2= odbc_result ($resultid, "Product") . $values2;
$labels= odbc_result ($resultid, "salesMonth") . $labels;
$i=$i+1;
/* next record */
odbc_fetch_row($resultid);
}
/* echo values for serie 1 */
echo "<PARAM NAME = \"SERIE_DATA_1\" VALUE = \"";
echo $values1;
echo "\">";
/*
echo values for serie 2 */
echo "<PARAM NAME = \"SERIE_DATA_2\" VALUE = \"";
echo $values2;
echo "\">";
/*
echo values for labels */
echo "<PARAM NAME = \"XAXIS_LABELS\" VALUE = \"";
echo $labels;
echo "\">";
/*
close result */
odbc_free_result($resultid);
/* close connection */
odbc_close($odbcid);
?>
<!-- **** CONSTANT DATA **** -->
<PARAM
NAME = "TITLECHART" VALUE = "Sales 1999">
<PARAM NAME = "LEGEND" VALUE = "TRUE">
<PARAM NAME = "XLABEL" VALUE = "Month">
<PARAM NAME = "YLABEL" VALUE = "Million $">
<PARAM NAME = "SERIE_1" VALUE = "Services">
<PARAM NAME = "SERIE_2" VALUE = "Products">
<PARAM NAME = "SERIE_STYLE_1" VALUE = "0.2|0x663300|LINE">
<PARAM NAME = "SERIE_STYLE_2" VALUE = "0.2|0x99|LINE">
<PARAM NAME = "SERIE_FILL_1" VALUE = "RED">
<PARAM NAME = "SERIE_FILL_2" VALUE = "0x99cc">
<PARAM NAME = "SERIE_FONT_1" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_FONT_2" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_POINT_1" VALUE = "true">
<PARAM NAME = "SERIE_POINT_2" VALUE = "true">
<PARAM NAME = "SERIE_TYPE_1" VALUE = "LINE">
<PARAM NAME = "SERIE_TYPE_2" VALUE = "LINE">
<PARAM NAME = "CHART_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "CHART_FILL" VALUE = "LIGHTGRAY">
<PARAM NAME = "BIG_TICK_INTERVALX" VALUE = "1">
<PARAM NAME = "BIG_TICK_INTERVALY" VALUE = "1">
<PARAM NAME = "YSCALE_MIN" VALUE = "0">
<PARAM NAME = "TICK_INTERVALY" VALUE = "100">
<PARAM NAME = "LEGEND_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "LEGEND_FILL" VALUE = "WHITE">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "BACK_IMAGE" VALUE = "back13.gif">
</APPLET>
</BODY>
</HTML>
|
10. How do I use the Applet with JSP |
The following example
will create an area chart (it is very similar to the example Chart2.htm).
It will retrieve
the data from an MSAccess database that contains a table called
"salesMonth". This table has three fields: "Products"
(integer), "Services" (integer) and "salesMonth" (date),
which contains the sales for several months.
The example will
display the sales of the last 6 months. It will create a HTML page that
contains the applet. Most of the parameters of the applet are constant,
however the date labels and the sales data is retrieved from the DB.
<HTML>
<HEAD></HEAD>
<BODY>
<APPLET
CODEBASE = "."
CODE = "com.java4less.rchart.ChartApplet.class"
NAME = "TestApplet"
ARCHIVE = "rchartClasses.zip"
WIDTH = 500 HEIGHT = 500>
<!--
**** VARIABLE DATA, use Java to retrieve series data values from
database **** -->
<%
java.sql.Statement st;
java.sql.ResultSet rs;
java.sql.Connection db=null;
int i=1;
String labels="";
String values1="";
String values2="";
// connect
to database
// open db using a System ODBC data source called "Data"
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
db = java.sql.DriverManager.getConnection("jdbc:odbc:data",
"", "");
}
catch(Exception e) {
System.err.println("Error eonnecting to DB:" + e.getMessage());
}
try {
st
= db.createStatement();
/*get sales data, execute SQL*/
rs = st.executeQuery("Select * from SalesMonth Order by salesMonth
DESC");
/* iterate on sales data, up to 6 rows */
while ((i <= 6) && (rs.next())) {
/* concatenate | separator */
if (i>1) {
values1= "|" + values1;
values2= "|" + values2;
labels= "|" + labels;
}
/* concatenate
value */
values1= "" + rs.getString("Services") + values1;
values2= "" + rs.getString( "Product") + values2;
java.text.SimpleDateFormat df= new java.text.SimpleDateFormat("MMM");
labels= "" + df.format(rs.getDate("salesMonth"))
+ labels;
i++;
}
rs.close();
db.close();
}
catch(Exception
e) {
System.err.println("Error:" + e.getMessage());}
/* echo
values for serie 1 */
out.println("<PARAM NAME = \"SERIE_DATA_1\" VALUE
= \"" + values1 + "\">");
/* echo
values for serie 2 */
out.println("<PARAM NAME = \"SERIE_DATA_2\" VALUE
= \""+ values2 + "\">");
/* echo
values for labels */
out.println("<PARAM NAME = \"XAXIS_LABELS\" VALUE
= \""+ labels + "\">");
%>
<!-- **** CONSTANT DATA **** -->
<PARAM NAME = "TITLECHART" VALUE = "Sales 1999">
<PARAM NAME = "LEGEND" VALUE = "TRUE">
<PARAM NAME = "XLABEL" VALUE = "Month">
<PARAM NAME = "YLABEL" VALUE = "Million $">
<PARAM NAME = "SERIE_1" VALUE = "Services">
<PARAM NAME = "SERIE_2" VALUE = "Products">
<PARAM NAME = "SERIE_STYLE_1" VALUE = "0.2|0x663300|LINE">
<PARAM NAME = "SERIE_STYLE_2" VALUE = "0.2|0x99|LINE">
<PARAM NAME = "SERIE_FILL_1" VALUE = "RED">
<PARAM NAME = "SERIE_FILL_2" VALUE = "0x99cc">
<PARAM NAME = "SERIE_FONT_1" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_FONT_2" VALUE = "Arial|PLAIN|8">
<PARAM NAME = "SERIE_POINT_1" VALUE = "true">
<PARAM NAME = "SERIE_POINT_2" VALUE = "true">
<PARAM NAME = "SERIE_TYPE_1" VALUE = "LINE">
<PARAM NAME = "SERIE_TYPE_2" VALUE = "LINE">
<PARAM NAME = "CHART_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "CHART_FILL" VALUE = "LIGHTGRAY">
<PARAM NAME = "BIG_TICK_INTERVALX" VALUE = "1">
<PARAM NAME = "BIG_TICK_INTERVALY" VALUE = "1">
<PARAM NAME = "YSCALE_MIN" VALUE = "0">
<PARAM NAME = "TICK_INTERVALY" VALUE = "100">
<PARAM NAME = "LEGEND_BORDER" VALUE = "0.2|BLACK|LINE">
<PARAM NAME = "LEGEND_FILL" VALUE = "WHITE">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "XAXIS_TICKATBASE" VALUE = "true">
<PARAM NAME = "BACK_IMAGE" VALUE = "back13.gif">
</APPLET>
</BODY>
</HTML>
|
11. How do I use the Servlet with JSP |
The following example
will create an area chart (it is very similar to the example Chart2.htm).
It will retrieve
the data from an MSAccess database that contains a table called
"salesMonth". This table has three fields: "Products"
(integer), "Services" (integer) and "salesMonth" (date),
which contains the sales for several months.
The example will
display the sales of the last 6 months. It will create a HTML page that
contains a reference to the Servlet. The JSP will first create a data
file for the servlet. Most of the parameters in this data file are constant,
however the date labels and the sales data is retrieved from the DB.
<HTML>
<HEAD>
<%
/* this is the file where we write the donfiguration for the
servlet, we should use another file name, not constant */
String filename="dataFile.html";
%>
</HEAD>
<BODY>
<BR>
This is the output of the servlet. The data for the servlet has
been calculated in a JSP file.
<BR>
<!-- **** VARIABLE DATA, use Java
to retrieve series data values from database **** -->
<%
java.sql.Statement
st;
java.sql.ResultSet rs;
java.sql.Connection db=null;
int i=1;
String labels="";
String values1="";
String values2="";
//
connect to database
// open db using a System ODBC data source called "Data"
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
db = java.sql.DriverManager.getConnection("jdbc:odbc:data",
"", "");
}
catch(Exception e) {
System.err.println("Error eonnecting to DB:" + e.getMessage());
}
try {
st
= db.createStatement();
/*get
sales data, execute SQL*/
rs = st.executeQuery("Select * from SalesMonth Order by salesMonth
DESC");
/* iterate on sales data, up to 6 rows */
while ((i <= 6) && (rs.next())) {
/* concatenate | separator */
if (i>1) {
values1= "|" + values1;
values2= "|" + values2;
labels= "|" + labels;
}
/*
concatenate value */
values1= "" + rs.getString("Services") +
values1;
values2= "" + rs.getString( "Product") +
values2;
java.text.SimpleDateFormat df= new java.text.SimpleDateFormat("MMM");
labels= "" + df.format(rs.getDate("salesMonth"))
+ labels;
i++;
}
rs.close();
db.close();
}
catch(Exception
e) {
System.err.println("Error:" + e.getMessage());}
try {
/* open output data file */
java.io.File fi=new java.io.File("..\\webapps\\rchart\\data\\"
+ filename);
java.io.FileWriter fw=new java.io.FileWriter(fi);
/* write
values for serie 1 */
fw.write("SERIE_DATA_1=" +values1 + "\n");
/* write
values for serie 2 */
fw.write("SERIE_DATA_2=" +values2+ "\n");
/* write
values for labels */
fw.write("XAXIS_LABELS=" +labels+ "\n");
/* write constant data to configuration file*/
fw.write("TITLECHART=Sales 1999\n");
fw.write("LEGEND=TRUE\n");
fw.write("XLABEL=Month\n");
fw.write("YLABEL=Million $\n");
fw.write("SERIE_1=Services\n");
fw.write("SERIE_2=Products\n");
fw.write("SERIE_STYLE_1=0.2|0x663300|LINE\n");
fw.write("SERIE_STYLE_2=0.2|0x99|LINE\n");
fw.write("SERIE_FILL_1=RED\n");
fw.write("SERIE_FILL_2=0x99cc\n");
fw.write("SERIE_FONT_1=Arial|PLAIN|8\n");
fw.write("SERIE_FONT_2=Arial|PLAIN|8\n");
fw.write("SERIE_POINT_1=true\n");
fw.write("SERIE_POINT_2=true\n");
fw.write("SERIE_TYPE_1=LINE\n");
fw.write("SERIE_TYPE_2=LINE\n");
fw.write("CHART_BORDER=0.2|BLACK|LINE\n");
fw.write("CHART_FILL=LIGHTGRAY\n");
fw.write("BIG_TICK_INTERVALX=1\n");
fw.write("BIG_TICK_INTERVALY=1\n");
fw.write("YSCALE_MIN=0\n");
fw.write("TICK_INTERVALY=100\n");
fw.write("LEGEND_BORDER=0.2|BLACK|LINE\n");
fw.write("LEGEND_FILL=WHITE\n");
fw.write("XAXIS_TICKATBASE=true\n");
fw.write("XAXIS_TICKATBASE=true\n");
fw.write("BACK_IMAGE=back13.gif\n");
fw.close();
}
catch(Exception
e) {
System.err.println("Error writing data file:" + e.getMessage());
}
%>
<!-- **** LINK to the servlet that
will use the data file we just created **** -->
<img src="http://localhost:8080/rchart/servlet/RChartServlet?DATAFILE=http://localhost:8080/rchart/data/<%=filename%>">
</BODY>
</HTML>
|
12. How do I use the
Bean with JSP |
The following example
will create an area chart (it is very similar to the example Chart2.htm).
It will retrieve
the data from an MSAccess database that contains a table called
"salesMonth". This table has three fields: "Products"
(integer), "Services" (integer) and "salesMonth" (date),
which contains the sales for several months.
The example will
display the sales of the last 6 months. It will create a HTML page that
contains a reference to the a jpg file that has been created by the Bean.
Most of the parameters are constant, however the date labels and the sales
data is retrieved from the DB.
<HTML>
<HEAD>
</HEAD>
<BODY>
<BR>
This is the output of the BEAN.
<BR>
<BR> <!-- **** VARIABLE DATA, use Java to retrieve series
data values from database ****
-->
<jsp:useBean
id="cha" scope="session" class="com.java4less.rchart.JChartBean"
/>
<%java.sql.Statement st;
java.sql.ResultSet rs;
java.sql.Connection db=null;
int i=1;
String labels="";
String values1="";
String values2="";// connect to database
// open db using a System ODBC entry called "Data"
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
db = java.sql.DriverManager.getConnection("jdbc:odbc:data",
"", "");
}
catch(Exception e) {
System.err.println("Error eonnecting to DB:" + e.getMessage());
}try {st = db.createStatement();
rs = st.executeQuery("Select * from SalesMonth Order by salesMonth
DESC");
/*
iterate on sales data, up to 6 rows */
while ((i <= 6) && (rs.next())) {
/* concatenate | separator */
if (i>1) {
values1= "|" + values1;
values2= "|" + values2;
labels= "|" + labels;
}
/*
concatenate value */
values1= "" + rs.getString("Services") + values1;
values2= "" + rs.getString( "Product") + values2;
java.text.SimpleDateFormat df= new java.text.SimpleDateFormat("MMM");
labels= "" + df.format(rs.getDate("salesMonth"))
+ labels; i++; }rs.close();
db.close();}
catch(Exception
e) {
System.err.println("Error:" + e.getMessage());
}
try {
/*
set parameters *//* write values for serie 1 */
cha.setParameter("SERIE_DATA_1",""+values1);/*
write values for serie 2 */
cha.setParameter("SERIE_DATA_2",""+values2);/*
write values for labels */
cha.setParameter("XAXIS_LABELS",""+labels);
/* write constant data to configuration file*/
cha.setParameter("TITLECHART","Sales 1999");
cha.setParameter("LEGEND","TRUE");
cha.setParameter("XLABEL","Month");
cha.setParameter("YLABEL","Million $");
cha.setParameter("SERIE_1","Services");
cha.setParameter("SERIE_2","Products");
cha.setParameter("SERIE_STYLE_1","0.2|0x663300|LINE");
cha.setParameter("SERIE_STYLE_2","0.2|0x99|LINE");
cha.setParameter("SERIE_FILL_1","RED");
cha.setParameter("SERIE_FILL_2","0x99cc");
cha.setParameter("SERIE_FONT_1","Arial|PLAIN|8");
cha.setParameter("SERIE_FONT_2","Arial|PLAIN|8");
cha.setParameter("SERIE_POINT_1","true");
cha.setParameter("SERIE_POINT_2","true");
cha.setParameter("SERIE_TYPE_1","LINE");
cha.setParameter("SERIE_TYPE_2","LINE");
cha.setParameter("CHART_BORDER","0.2|BLACK|LINE");
cha.setParameter("CHART_FILL","LIGHTGRAY");
cha.setParameter("BIG_TICK_INTERVALX","1");
cha.setParameter("BIG_TICK_INTERVALY","1");
cha.setParameter("YSCALE_MIN","0");
cha.setParameter("TICK_INTERVALY","100");
cha.setParameter("LEGEND_BORDER","0.2|BLACK|LINE");
cha.setParameter("LEGEND_FILL","WHITE");
cha.setParameter("XAXIS_TICKATBASE","true");
cha.setParameter("XAXIS_TICKATBASE","true");
cha.setParameter("BACK_IMAGE","back13.gif");
}
catch(Exception
e) {
System.err.println("Error: " + e.getMessage());
}
/* create jpg file */
cha.buildChart();
cha.setChartSize(300,300);
cha.saveToFile("..\\webapps\\rchart\\chart.jpg","JPEG");
%>
<!-- **** LINK to the jpg file
we just created **** -->
<img
src="chart.jpg">
</BODY>
</HTML>
|
13. Servlet running on Linux does not show texts |
RChart uses "Arial"
as default font which does not exist in Linux. The solution is use another
font. For example:
TITLE_FONT=Dialog|BOLD|12
|
|
|