How to: |
Chart annotations support the ability to specify an arbitrary SVG object and define events and tooltips for the SVG object, enabling you to create your own interactive buttons and icons on the chart canvas.
You have to add a separate eventDispatcher object to the request in order to add interactivity to an annotation. For information, see the Creating HTML5 Charts With WebFOCUS Language manual.
"annotations" = [{ "position": { "parent": "string", "x": x, "y": y }, "marker": { "visible": boolean, "shape": "svg code", "color": "string", "border": {"width": number, "color": "string", "dash": "string"} }, "tooltip": "string" }]
where:
Defines the position of the annotation marker.
Defines the chart object that the x and y values refer to. The default value is undefined. Can be one of the following.
Is the horizontal position for the annotation icon. A synonym for "x" is "left", which measures the horizontal position from the left edge of the frame. You can also use "right", which measures the position from the right edge of the frame.
The default value is undefined. Can be:
If you set multiple horizontal position properties, "x" takes precedence over either "right" or "left", and "left" takes precedence over "right".
Is the vertical position for the annotation icon. A synonym for "y" is "bottom", which measures the horizontal position from the bottom edge of the frame. You can also use "top", which measures the position from the top edge of the frame.
The default value is undefined. Can be:
If you set multiple vertical position properties, "y" takes precedence over either "bottom" or "top", and "bottom" takes precedence over "top".
Defines the properties of the annotation marker or icon.
Defines whether the annotation icon is visible. Valid values are true, which makes the icon visible, and false, which does not make the icon visible. The default value is false.
Is the SVG path data string ('d' attribute) that defines the icon shape and size.
Note: Standard marker shapes such as "circle" or "diamond" are also supported for the marker:shape object.
Is a string that specifies the color of the icon.
Defines the border properties of the icon.
Is the width of the border in pixels.
Is a string that specifies the color of the border.
Is a string that defines the dash style of the border. The default value is "" (a solid line). Use a string of numbers that defines the width of a dash in pixels followed by the width of the gap between dashes in pixels (for example, dash "1 1" draws a dotted line).
Multiple dashes can be defined within the dash string (for example, "2 4 4 2"), in which case the dash types will alternate along the border.
Is a string that defines a tooltip to appear when the mouse hovers over the icon.
The following request creates an annotation that consists of a red icon with a navy dashed border. The event associated with clicking this icon opens the Information Builders home page. The tooltip displays the following text:
Click to go to informationbuilders.com
SET PAGE-NUM=NOLEAD
SET HTMLENCODE=OFF
SET EMBEDHEADING=ON
GRAPH FILE wf_retail_lite
SUM REVENUE_US
BY PRODUCT_CATEGORY
ON GRAPH PCHOLD FORMAT JSCHART
ON GRAPH SET LOOKGRAPH BAR
ON GRAPH SET STYLE *
INCLUDE=IBFS:/FILE/IBI_HTML_DIR/ibi_themes/Warm.sty,$
TYPE=DATA, COLUMN=N1, BUCKET=x-axis, $
TYPE=DATA, COLUMN=N2, BUCKET=y-axis, $
*GRAPH_JS
"eventDispatcher": {
"events": [
{
// This will add a click event handler to the annotation
"event": "click", object: "annotation", series: 0, url: "http://informationbuilders.com", target: "_blank"
}
]
},
annotations:[{
"position": {
"x": 750,
"y": 12,
"parent": "background"
},
"marker": {
"visible": true,
"color": "red",
"border": {"width": 1, "color": "navy", "dash": "2 2"},
"shape": "m 12.666667,8.291667 0,-4.375 c 0,-0.319084 -0.26425,-0.583334 -0.583334,-0.583334 l -4.3749997,0 C 7.4715,3.333333 7.2615,3.479167 7.1705,3.688583 7.0795,3.907333 7.125,4.16225 7.29825,4.32675 l 1.3125,1.3125 -4.8673333,4.867333 c -0.2280834,0.228084 -0.2280834,0.592667 0,0.820167 L 4.67325,12.256583 c 0.2280833,0.228084 0.5926667,0.228084 0.8201667,0 L 10.36075,7.38925 l 1.3125,1.3125 c 0.109083,0.118417 0.2555,0.17325 0.410083,0.17325 0.07292,0 0.155167,-0.01808 0.228084,-0.0455 0.209416,-0.091 0.35525,-0.301 0.35525,-0.537833 z M 15,3.625 l 0,8.75 C 15,13.824 13.824,15 12.375,15 l -8.75,0 C 2.176,15 1,13.824 1,12.375 L 1,3.625 C 1,2.176 2.176,1 3.625,1 l 8.75,0 C 13.824,1 15,2.176 15,3.625 Z",
"tooltip": "Click to go to informationbuilders.com"
}
}]
*END
ENDSTYLE
END
The output is shown in the following image.
WebFOCUS | |
Feedback |