#set TITLE = "Clickmap support"
#include top

.LP
Clickable maps (clickmaps)
allow browser users to click on a region in
a graphic, which acts as a hyperlink to a new web page.
Ploticus 2.03+ can generate either server-side or client-side map
files to accompany images (PNG, JPEG, or GIF);
version 2.04+ supports clickable mapping in 
#set FILE = "svg.html"
#set TAG = "SVG."
#include link
For images, map info is written to a separate file.
For SVG, the mapping information is added to the .svg / .svgz output file (so the
server-side vs. client-side distinction discussed below is moot).

.LP
You can map
#set FILE = pie.html
#set TAG = "pie slice labels"
#include link
,
#set FILE = bars.html
#set TAG = "bars"
#include link
,
#set FILE = scatterplot.html
#set TAG = "scatterplot points"
#include link
,
#set FILE = annotate.html
#set TAG = "annotations"
#include link
, 
#set FILE = legend.html
#set TAG = "legend entries"
#include link
, and 
#set FILE = areadef.html
#set TAG = "the plotting area"
#include link
(either as a grid, or in its entirety).

#include space

.SH Examples
A number of
#set FILE = "#examples"
#set TAG = "live examples"
#include link
are provided below.

#include space

.SH Server-side maps vs. client-side maps
There are two distinct types of clickmaps that can accompany PNG, GIF, or JPEG images:
#set FILE = "http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemapping.html"
#set TAG = "server-side maps"
#include link
and
#set FILE = "http://www.netscape.com/assist/net_sites/html_extensions_3.html"
#set TAG = "client-side maps"
#include link
\0.  
The two types are similar but have different syntaxes and are tied to an HTML web
page slightly differently.
Server-side maps have been around longer, but
may need to be specifically enabled in your web server by the administrator.
Client-side maps are more efficient, but are not supported by earlier 
browser versions, and may need to be embedded in the HTML of the web page
loading the graphic.

#include space

.SH Linking to your web page
.LP
In your web pages, you can use the following HTML construct 
to associate a \fBserver-side\fR map file with an image:
.nf
    <a href="mypic.map"> <img src="mypic.png" ismap > </a>
.fi
.LP
Here's an HTML example that uses an embedded \fBclient-side\fR map for an image:
.nf
   <img src="mypic.png" usemap="#map1">
   <map name="map1">
   ... the map content that pl generates will go here ...
   </map>
.fi
.LP
Note: When ploticus generates a client-side map, it leaves off the opening \fC<map>\fR
and closing \fC</map>\fR tags.  These tags will need to be added by the user.
#include space
.LP
For SVG, no special action is necessary; use the 
#set FILE = svg.html
#set TAG = "normal construct."
#include link

#include space

.SH Generating map files
To generate a server-side map, use the \fB-map\fR option.
To generate a client-side map, use the \fB-csmap\fR option.
For SVG, use either option.
A generated map file will have the same name as the accompanying graphic result file, except
that a \fC.map\fR suffix will be used.  
If neither \fB-map\fR or \fB-csmap\fR are specified, then no map will be generated.
Usage examples:
.IP
\fCpl -png -map -prefab pie ...\fR
.br
\fCpl -png -map pie3.pl \fR
.br
\fCpl -png -csmap pie3.pl \fR
.br
\fCpl -svgz -map results4.pl\fR

.LP
You will
need to supply URL information (discussed below) in your script or
#set FILE = "prefab_stdparms.html#clickmapurl"
#set TAG = "prefab"
#include link
for hyperlink purposes.


#include space
.SH Troubleshooting
If the \fB-debug\fR command line option is used the mapped
regions will be displayed in bright green.  If \fB-debug\fR is used in X11 mode, the regions
are displayed but no map file is generated.
.LP
Note that if two generated mapped regions overlap, they are stacked in the order generated
(the last generated is on "top").

#include space
.SH Specifying URLs
Usually the programmer supplies URL template(s) or URLs within the script file
(eg. for pie graphs this is done within 
#set FILE = "pie.html"
#set TAG = "proc pie"
#include link
; for the plotting area it is done within
#set FILE = "areadef.html"
#set TAG = "proc areadef"
#include link
).   
#include space
.LP
\fBFor pie graphs, bar graphs, and scatterplots\fR:
.IP
Use \fBproc pie / bars / scatterplot\fR attribute \fCclickmapurl\fR to specify a URL template.
The template may contain 
#set FILE = "attributetypes.html#dfield"
#set TAG = "data field references"
#include link
prefaced by two at-signs (@@@@).
For example: 
.nf
	clickmapurl: http://abc.com/mycgi?id=@@@@3
.fi
would generate a URL for each 
pie slice label, bar, scatterplot point, etc.,
using the value in data field 3 for each.
This example:
.nf
	clickmapurl: @@@@6
.fi
would take the URL for each slice, bar, etc. from
data field 6.
URL templates work well for typical CGI invocations
where the CGI script name is constant and the parameters vary.
If you have a collection of non-uniform URLs that you wish to map,
they may be listed in a data field and accessed there.

#include space
.LP
\fBFor annotations:\fR
.IP
Use \fBproc annotate\fR attribute \fCclickmapurl\fR to specify a URL explicitly.
For example:
.nf
	clickmapurl: http://abc.com/docs/aboutpets.html
.fi

#include space
.LP
\fBFor legend entries:\fR
.IP
Embed a URL into the \fClegendlabel\fR attribute (or if you are using
#set FILE = "legendentry.html"
#set TAG = "proc legendentry"
#include link
the \fClabel\fR attribute).  Use this format: \fCurl:\fIurl\fC  \fIlabel\fR
.br
See this example:
#set FILE = "../gallery/clickmap_leg.htm"
#set TAG = "clickmap_leg"
#include link


#include space
.LP
\fBFor the plotting area to be a single region:\fR
.IP
Use \fBproc areadef\fR attribute \fCclickmapurl\fR to specify a URL.
XVAL and YVAL do not apply.


#include space
.LP
\fBFor grid regions within the plotting area:\fR
.IP
Use \fBproc areadef\fR attribute \fCclickmapurl\fR to specify a URL template.
The template should contain special symbols \fB@@@@XVAL\fR and/or \fB@@@@YVAL\fR.
For example:
.nf
	clickmapurl: http://abc.com/mycgi?x=@@@@XVAL&y=@@@@YVAL
.fi
Then use \fBproc axis\fR attribute \fCclickmap\fR for either the X axis, the Y axis,
or both.
.RS
.IP \(bu
For a clickmap responding to different values in X, the above URL template should contain
\fC@@@@XVAL\fR, and set \fBproc xaxis\fR attribute \fCclickmap: grid\fR.
.IP \(bu
For a clickmap responding to different values in Y, the above URL template should contain
\fC@@@@YVAL\fR, and set \fBproc yaxis\fR attribute \fCclickmap: grid\fR.
.IP \(bu
For a clickmap responding to different values in X and Y, the above URL template should contain
both \fC@@@@XVAL\fR and \fC@@@@YVAL\fR, and set \fBproc xaxis\fR attribute \fCclickmap: xygrid\fR 
and \fBproc yaxis\fR attribute \fCclickmap: xygrid\fR.
.RE
.IP
The mapped regions will be centered around stubs.
Stub values will be substituted into the URL template as XVAL and YVAL.  
These stub values will use the default format (not necessarily the displayed stub format) for the particular
#set FILE = "scaleunits.html"
#set TAG = "scale unit"
#include link
but this can be controlled using \fBproc axis\fR \fCclickmapvalformat\fR attribute.
By default the regions will stop at the plotting area boundary, 
but they can be extended (to encompass stubs for example) using \fBproc axis\fR 
\fCclickmapextent\fR attribute.
.IP
If you need higher (or lower) granularity than what your stubs provide, you can
invoke an additional, invisible X axis using the desired granularity like this:
.nf
	#proc xaxis
	stubs: inc <whatever>
	clickmap: grid
	axisline: no
 	tics: no
	stubomit: *

#include space
.LP
\fBTo set a default URL for the entire image:
.IP
Use \fBproc page\fR attribute \fCclickmapdefault\fR to specify a default URL that will
be invoked if the mouse click is not in a defined region.  

#include  space
.LP
\fBNotes:\fR
.LP
Embedded spaces and newlines that turn up within URLs will be converted to underscores.
.LP
Grid mapping may not be used with more than one plotting area per image.

.ig >>
<a name=examples></a>
.>>

#include space
.SH Examples
Most of the following examples have been run with \fB-debug\fR to add the green
overlay showing where clickable regions are.  
Try clicking on these images..
they are mapped to a live CGI program that will echo the passed parameters.
.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_pie.htm">clickmap_pie</a><br>
<a href="../gallery/clickmap_pie.map"> <img src="../gallery/clickmap_pie.gif" ismap> </a>
<br>
.>>
Click on pie slice labels.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_annot.htm">clickmap_annot</a><br>
<a href="../gallery/clickmap_annot.map"> <img src="../gallery/clickmap_annot.gif" ismap> </a>
<br>
.>>
Click on annotations.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_leg.htm">clickmap_leg</a><br>
<a href="../gallery/clickmap_leg.map"> <img src="../gallery/clickmap_leg.gif" ismap> </a>
<br>
.>>
Click on legend entries.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_area2.htm">clickmap_area2</a><br>
<a href="../gallery/clickmap_area2.map"> <img src="../gallery/clickmap_area2.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid.  Numeric in X and Y.  Click on plotting area.
To try the SVG equivalent 
#set FILE = "../gallery/clickmap_area2.svgz"
#set TAG = "click here."
#include link

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_area3.htm">clickmap_area3</a><br>
<a href="../gallery/clickmap_area3.map"> <img src="../gallery/clickmap_area3.gif" ismap> </a>
<br>
.>>
Same as above, but with finer granularity.
This is done by executing an invisible X axis and an invisible Y axis
for the clickmap (in addition to the visible axes) using the automatically
determined stub increment, divided by 4.

.ig >>
<br>
<br>
<br>
<a href="../gallery/snpmap1.htm">snpmap1</a><br>
<a href="../gallery/clickmap_snp.map"> <img src="../gallery/clickmap_snp.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid.  Numeric in X; categories in Y.
Note that the mapped grid (Y) is influenced by \fCstubslide\fR.


.ig >>
<br>
<br>
<br>
<a href="../gallery/colorgrid.htm">colorgrid</a><br>
<a href="../gallery/colorgrid.map"> <img src="../gallery/colorgrid.gif" ismap> </a>
<br>
.>>
Data points are mapped.  Click on any data point.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_area.htm">clickmap_area</a><br>
<a href="../gallery/clickmap_area.map"> <img src="../gallery/clickmap_area.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid.  Months in X, numeric in Y.  
Note that month format is controlled using \fBproc axis\fR \fCclickmapvalformat\fR.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_log.htm">clickmap_log</a><br>
<a href="../gallery/clickmap_log.map"> <img src="../gallery/clickmap_log.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid in Y.  Log example.  Click on plotting area.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_time2.htm">clickmap_time2</a><br>
<a href="../gallery/clickmap_time2.map"> <img src="../gallery/clickmap_time2.gif" ismap> </a>
<br>
.>>
Mapped timeline bars.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_mouse.htm">clickmap_mouse</a><br>
<a href="../gallery/clickmap_mouse.map"> <img src="../gallery/clickmap_mouse.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid.  Categories in X.  Note that the X stubs are (mostly) included in
the mapped regions.  This is done using the \fBproc xaxis\fR \fCclickmapextent\fR attribute.

.ig >>
<br>
<br>
<br>
<a href="../gallery/clickmap_hit.htm">clickmap_hit</a><br>
<a href="../gallery/clickmap_hit.map"> <img src="../gallery/clickmap_hit.gif" ismap> </a>
<br>
.>>
Mapped plotting area grid.  Datetimes in X.  The datetimes are mapped in 6 hour increments,
even though stubs appear every 24 hours.  
This is done by executing an invisible X axis 
for the clickmap, using 6 hour increments.


#include bottom
