Applet Example 7
This example
demonstrates how the applet is able to interact with javascript
functions within the current page. In the graph below clicking
on the Pie Segments will execute a javascript function which
will either show or hide a table of data for that pie.
|
Product X |
N.America |
$
5,000 |
Europe |
$
6,605 |
Asia |
$
3,480 |
Africa |
$
1,940 |
Australia |
$
2,420 |
S.America |
$
1,324 |
|
Product Y |
N.America |
$
8,560 |
Europe |
$
7,240 |
Asia |
$
3,000 |
Africa |
$
2,400 |
Australia |
$
1,500 |
S.America |
$
1,500 |
|
Product Z |
N.America |
$
3,500 |
Europe |
$
2,900 |
Asia |
$
3,000 |
Africa |
$
1,200 |
Australia |
$
4,200 |
S.America |
$
3,500 |
|
and here
is the HTML code for the applet
(note that 'mayscript' has been added to the APPLET tag ),
<applet code="PiechartApplet.class"
archive="PieChart.jar" width="550" height="450"
mayscript>
<!-- Start Up Parameters -->
<PARAM name="LOADINGMESSAGE" value="Creating
Chart - Please Wait."> <!-- Message to be displayed
on Startup -->
<PARAM name="STEXTCOLOR" value="0,0,100">
<!-- Message Text Color-->
<PARAM name="STARTUPCOLOR" value="255,255,255">
<!-- Applet Background color -->
<!-- Data files
-->
<PARAM name="chartproperties" value="piepropsjs.txt">
<PARAM name="chartdata" value="piedatajs.txt">
</applet>
The
configuration parameters are taken from the text file piepropsjs.txt
( click here to view )
and the graph data is read from the text file piedatajs.txt
( click here to view )
If
you "right click" and view source of this page you
will see that we have the following javascript function within
the page which is able to act upon the three tables, "c1",
"c2" and "c3".
<SCRIPT
LANGUAGE="JavaScript">
var table='c1';
function combo(table) {
if (table=='c1')
{
if (document.all.c1.style.visibility=="hidden")
{
document.all.c1.style.visibility="visible";
}
else {document.all.c1.style.visibility="hidden";}
}
if (table=='c2')
{
if (document.all.c2.style.visibility=="hidden")
{
document.all.c2.style.visibility="visible";
}
else {document.all.c2.style.visibility="hidden";}
}
if (table=='c3')
{
if (document.all.c3.style.visibility=="hidden")
{
document.all.c3.style.visibility="visible";
}
else {document.all.c3.style.visibility="hidden";}
}
}
</script>
In
the piedatajs.txt ( click here to
view ) file you will see that each of our data elements
has the word "javascript" entered in the target
field and the javascript function name with the relevant value
entered in the URL field.
Note:
If you are using the evaluation version then in the applet
a pop-up window will appear upon the startup and an evaluation
message will be incorporated by the servlet. Both these
features have been removed from the licensed version. Licensing
information can be found at http://www.jpowered.com/graph_chart/index.htm
<< back to Examples Index
<< back to Getting
Started
|
Getting Started
Documentation
Examples
Purchase
Pie
Chart Home
Graph
& Charting
Pie
Chart
Line Graph
Vertical
Bar Graph
Stacked
Bar Graph
Horizontal
Bar Graph
more...
Advanced
Data Grid Control
|