ChartDirector 7.0 (Perl Edition)

BaseChart.getHTMLImageMap


Usage

getHTMLImageMap(url [, queryFormat [, extraAttr [, offsetX, offsetY ]]])

Description

Generates an HTML image map to define hot spots and tooltips for the chart.

HTML image maps are a standard way to define hot spots on an image. It defines the hot spot regions and their associate parameters and tooltips. This method generates image maps for the data representation objects (bars for a bar chart, sectors for a pie chart, line segments for a line chart, etc) on a chart. Other methods, such as Axis.getHTMLImageMap and LegendBox.getHTMLImageMap, can be used to generate image maps for other parts of the chart.

Since HTML is an open standard, you can append custom image map entries to define custom hot spots on the chart. For example, if you include your company logo on the chart using BaseChart.addText, you may define a hot spot for the logo to make it clickable. The Box.getImageCoor can be used to obtain the image map coordinates for this purpose.

This method should be called only after creating the chart image (eg. using BaseChart.makeChart or BaseChart.makeChart2). The image map cannot be determined without creating the chart image first.

This method accepts a URL as its argument. When generating an image map, it appends query parameters to the URL to indicate which data point the user has clicked.

The following is an example image map generated for a bar chart with 3 bars.

<area shape="rect" coords="34,219,63,139" href="myurl.pl?x=0&xLabel=Mon&dataSet=0&dataSetName=Revenue&value=100" title="Apple: 174">
<area shape="rect" coords="74,219,103,119" href="myurl.pl?x=1&xLabel=Tue&dataSet=0&dataSetName=Revenue&value=125" title="Orangle: 99">
<area shape="rect" coords="114,219,143,22" href="myurl.pl?x=2&xLabel=Wed&dataSet=0&dataSetName=Revenue&value=245.78" title="Mango: 201">

The image map consists of multiple <area> tags, one for each bar in the chart. In the "href" attribute, query parameters are appended to the URL to provide information on the bar clicked. The image map can also include extra attributes, most commonly used to provide tooltips (the "title" attribute in this example).

The image map produces by ChartDirector does not include the <map> and </map> tag. This is intentional so that you can add additional custom <area> tags to the image map, or append multiple image maps together.

The type of query parameters to append to the URL depends on the chart type and layer type. The default query parameters are as follows .

Chart/Layer TypeDefault Query Format
Pie chartsector={sector}&label={label}&value={value}&percent={percent}
Bar, Line, Spline, Step Line, Area and Scatter layersx={x}&xLabel={xLabel}&dataSet={dataSet}&dataSetName={dataSetName}&value={value}
Percentage Bar and Percentage Area layersx={x}&xLabel={xLabel}&dataSet={dataSet}&dataSetName={dataSetName}&value={value}&percent={percent}
HLOC and CandleStick layersx={x}&xLabel={xLabel}&high={high}&low={low}&open={open}&close={close}
Box-Whisker layerx={x}&xLabel={xLabel}&top={top}&bottom={bottom}&max={max}&min={min}&med={med}
Trend layerdataSetName={dataSetName}
Vector layer and Polar Vector layerx={x}&xLabel={xLabel}&dataSetName={dataSetName}&value={value}&dir={dir}&len={len}
Polar Line, Area, Spline Line and Spline Area layers"x={x}&label={label}&name={name}&value={value}"
Pyramid chart"index={index}&label={label}&value={value}&percent={percent}"
3D Scatter Chart"x={x}&y={y}&z={z}&dataSet={dataSet}&dataSetName={name}"

The texts in curly brackets (e.g. {sector}, {dataSet}, etc.) will be replaced by the actual values when generating the image map. For example, {sector} will be replaced by the sector number of the sector.

ChartDirector allows developers to modify the query parameters by using the queryFormat argument. For example, if "x={x}&v={value}" is used as the queryFormat for an XYChart, only the x position and the value of the data point will be included in query parameters.

Please refer to Parameter Substitution and Formatting on all available parameters and their meanings.

Arguments

ArgumentDefaultDescription
url(Mandatory)The URL to be used in the "href" attribute of the image map. Parameter Substitution and Formatting is supported. Use an empty string if no href attribute is needed.
queryFormat""A text string representing the template of the query parameters to be appended to the URL. Parameter Substitution and Formatting is supported.

The special keyword "{default}" represents the default query parameters. This is useful for specifying appending to the default.

Note that an empty string means to use the default query query parameters. To specify no query parameter, use a space character.
extraAttr""A text string to specify additional attributes to add to the <area> tag. Parameter Substitution and Formatting is supported.
offsetX0An offset to be added to all x coordinates in the image map. This is useful if the current image will be shifted and inserted into another image. In this case, the image map will need to be shifted by the same offset.
offsetY0An offset to be added to all y coordinates in the image map. See offsetX above for description.

Return Value

A text string containing the image map generated.