.ig >>
<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
        OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }

        H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
        H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
        H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
        H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>ploticus: clickmap and mouseover support</title>
<body bgcolor=D0D0EE vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td>
  <table cellpadding=2 width=550><tr>
  <td><br><h2>Clickmap and mouseover support</h2></td>
  <td align=right>
  <small>
  <a href="../doc/Welcome.html"><img src="../doc/ploticus.gif" border=0></a><br>
  <a href="../doc/Welcome.html">Welcome</a> &nbsp; &nbsp;
  <a href="../gallery/index.html">Gallery</a> &nbsp; &nbsp;
  <a href="../doc/Contents.html">Handbook</a> 
  <td></tr></table>
</td></tr>
<td>
<br>
<br>
.>>

.TH Clickmap_and_mouseover_support PL "11-APR-2003   PL ploticus.sourceforge.net"

.SH Clickmaps and mouseover labels
.LP
\fBClickmaps\fR (clickable image maps) allow browser users to click on a region in
a graphic, which acts as a hyperlink to a new web page.
\fBMouseover labels\fR allow browser users to move the mouse over a data point or region
(without clicking) and see a text bubble appear to give additional information.
.LP
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 
.ig >>
<a href="svg.html">
.>>
\0SVG.
.ig >>
</a>
.>>
Version 2.11+ supports mouseover text labels via client-side maps for PNG, JPEG, or GIF images.

.LP
You can map
.ig >>
<a href="pie.html">
.>>
\0pie slice labels
.ig >>
</a>
.>>
,
.ig >>
<a href="bars.html">
.>>
\0bars
.ig >>
</a>
.>>
,
.ig >>
<a href="scatterplot.html">
.>>
\0scatterplot points
.ig >>
</a>
.>>
,
.ig >>
<a href="annotate.html">
.>>
\0annotations
.ig >>
</a>
.>>
,
.ig >>
<a href="rect.html">
.>>
\0arbitrary rectangular regions
.ig >>
</a>
.>>
, 
.ig >>
<a href="legend.html">
.>>
\0legend entries
.ig >>
</a>
.>>
, and 
.ig >>
<a href="areadef.html">
.>>
\0the plotting area
.ig >>
</a>
.>>
(either as a grid, or in its entirety).

.ig >>
<br><br><br>
.>>

.SH Examples
A number of
.ig >>
<a href="#examples">
.>>
\0live examples
.ig >>
</a>
.>>
are provided below.

.ig >>
<br><br>
.>>

.SH Server-side maps, client-side maps, and SVG
.LP
.IP \(bu
.ig >>
<a href="http://hoohoo.ncsa.uiuc.edu/docs/tutorials/imagemapping.html">
.>>
\0Server-side maps
.ig >>
</a>
.>>
are used with image formats (PNG, GIF, JPEG).
To generate a server-side map, use the \fC-map\fR option.
The map coordinates and URLs reside in a separate file that accompanies the image file.
Some web servers do not enable these by default.
.IP \(bu
.ig >>
<a href="http://www.netscape.com/assist/net_sites/html_extensions_3.html">
.>>
\0client-side maps
.ig >>
</a>
.>>
are also used with image formats (PNG, GIF, JPEG).
They support mouseover text labels.
To generate a client-side map, use the \fC-csmap\fR option.
The map coordinates, URLs, and/or labels reside in the HTML that is loading the image.
In dynamic content situations, the \fC-mapfile stdout\fR option may be used to
dump the map information to standard output.
Client-side maps are not supported by earlier browser versions.
.IP \(bu
SVG clickable regions are embedded directly into the SVG result and are enabled using
the \fC-map\fR option.

.ig >>
<br><br><br>
.>>
.SH Mouseover text labels
Mouseover text bubbles are done in a similar way to clickmaps, for most of the same types of plots.
You must use a client-side image map (\fC-csmap\fR) to accompany a PNG, GIF, or JPEG
image.  Mouseover may be done alone or with clickability and URLs.  In plotting procs, 
mouseover text bubble messages are specified similarly to URLs using an attribute 
called \fCclickmaplabel\fR.  In situations where URLs are generated by way of embedded 
@variables, the text messages should be generated that way too.
Here's a 
.ig >>
<a href="../gallery/cs_mouseover.htm">
.>>
\0gallery example
.ig >>
</a>
.>>
that uses a client-side imagemap to implement mouseover text labels (move your mouse
over the bars).


.ig >>
<br><br><br>
.>>

.SH Generating map files
Map generation is triggered by the presence of the \fC-map\fR or \fC-csmap\fR command
line option.  If these aren't specified, then no map will be generated.
.LP
You can use the \fB-mapfile\fR command line option (or proc page equivalent) to
explicitly name your map file.
Using \fC-mapfile stdout\fR will dump the map to standard output which can be useful
in dynamic content situations.
If -mapfile is not specified, the
map file will have the same name as the accompanying graphic result file, except
with a \fC.map\fR suffix.
.LP
Usage examples:
.IP \0 \0
\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



.ig >>
<br><br><br>
.>>

.SH Linking an HTML page with the generated image map
.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
   <map name="map1">
   ... the map content that pl generates will go here ...
   </map>
   <img src="mypic.png" usemap="#map1">
.fi
.LP
Note: When ploticus generates a client-side map, it leaves off the opening \fC<map>\fR
and closing \fC</map>\fR tags.
.LP
For SVG, no special action is necessary; use the 
.ig >>
<a href="svg.html">
.>>
\0normal construct.
.ig >>
</a>
.>>

.ig >>
<br><br><br>
.>>
.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").

.ig >>
<br><br><br>
.>>
.SH Specifying URLs and/or mouseover labels
Ploticus will need to know how to build the URLs
and/or mouseover labels that will be present in the image map result.
For clickmaps, you will
need to supply URLs (or arrange for URLs to be built from data fields) in your script or
.ig >>
<a href="prefab_stdparms.html#clickmapurl">
.>>
\0prefab, 
.ig >>
</a>
.>>
usually through an attribute called \fBclickmapurl\fR.
For mouseover text messages, you will need to supply the text messages
or arrange for them to be built, usually through an attribute called \fBclickmaplabel\fR.

.ig >>
<br><br><br>
.>>
.SH ..for pie graphs, bar graphs, and scatterplots
.IP \0
Use \fBproc pie / bars / scatterplot\fR attribute \fCclickmapurl\fR to specify a URL template.
The template may contain 
.ig >>
<a href="attributetypes.html#dfield">
.>>
\0data field references
.ig >>
</a>
.>>
prefaced by two at-signs (@@).
For example: 
.nf
	clickmapurl: http://abc.com/mycgi?id=@@3
	clickmaplabel: @@4
.fi
would generate a URL for each 
pie slice label, bar, scatterplot point, etc.,
using the value in data field 3 for each.
Mouseover text label will be the contents of data field 4 (this will only have an effect
if client-side image map is being generated).

.ig >>
<br><br><br>
.>>
.SH ..for annotations and arbitrary rectangles
.IP \0
Use \fBproc annotate\fR or \fBproc rect\fR attribute \fCclickmapurl\fR to specify a 
URL and/or mouseover label explicitly.  For example:
.nf
	clickmapurl: http://abc.com/docs/aboutpets.html
	clickmaplabel: A complete description of how to care for your new pet
.fi

.ig >>
<br><br><br>
.>>
.SH ..for legend entries
.IP \0
Embed a URL into the \fClegendlabel\fR attribute (or if you are using
.ig >>
<a href="legendentry.html">
.>>
\0proc legendentry
.ig >>
</a>
.>>
the \fClabel\fR attribute).  Use this format: \fCurl:\fIurl\fC  \fIlabel\fR
.br
Mouseover labels are not supported for legend entries.
.br
See this example:
.ig >>
<a href="../gallery/clickmap_leg.htm">
.>>
\0clickmap_leg
.ig >>
</a>
.>>


.ig >>
<br><br><br>
.>>
.SH ..for the plotting area to be a single region
.IP \0
Use \fBproc areadef\fR attribute \fCclickmapurl\fR to specify a URL.
XVAL and YVAL do not apply.  Use \fCclickmaplabel\fR to specify a mouseover label.


.ig >>
<br><br><br>
.>>
.SH ..for grid regions within the plotting area
.IP \0
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 \0
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
.ig >>
<a href="scaleunits.html">
.>>
\0scale unit
.ig >>
</a>
.>>
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 \0
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: *
.fi
\fBMouseover text labels\fR are not directly supported for plotting area grid, but a workaround
for doing this is to use proc bars with the \fCconstantlength\fR attribute to draw
invisible bars (use white for the color) that extend to cover the entire plotting area.
Here's a 
.ig >>
<a href="../gallery/cs_mouseover.htm">
.>>
\0gallery example
.ig >>
</a>
.>>
that illustrates.

.ig >>
<br><br><br>
.>>
.SH To set a default URL for the entire image
.IP \0
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.  

.ig >>
<br><br><br>
.>>
.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>
.>>

.ig >>
<br><br><br>
.>>
.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>
.>>
.ig >>
<br>
<h3><a href="../gallery/cs_mouseover.htm">Click here</a> to see a gallery example
that uses a client-side imagemap with mouseover text labels (but no URLs)</h3>
<br><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 
.ig >>
<a href="../gallery/clickmap_area2.svgz">
.>>
\0click here.
.ig >>
</a>
.>>

.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.


.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="../doc/Welcome.html">
<img src="../doc/ploticus.gif" border=0></a><br><small>data display engine &nbsp; <br>
<a href="../doc/Copyright.html">Copyright Steve Grubb</a>
<br>
<br>
<center>
<img src="../gallery/all.gif">
</center>
</td></tr>
</table>
.>>
