Image |
Let us take a look at the Image Annotation here. The Image Annotation allows you to display an image on the chart. |
The XML/JSON to create the above is: |
<chart> ... <annotations> <annotationGroup id='Grp1' > <annotation type='image' x='125' y='5' URL='logo.gif' /> </annotationGroup> </annotations> ... </chart> { "chart": {}, ... "annotations": { "groups": [ { "id": "Grp1", "items": [ { "type": "image", "x": "125", "y": "5", "url": "logo.gif" } ] } ] ... } } See it live! |
As it is very clear from the code above, we need to set the annotation type to image, specify the x and y co-ordinates where we want the image to be placed and finally provide the URL where the image is located. This URL has to lie in the same domain as the URL of the chart. |
Scaling Images |
You can x-scale and y-scale images using the xScale and yScale attributes. Setting xScale='50' yScale='200' will reduce the image to half horizontally and double it vertically. |
See it live! |
The various attributes using which the image annotation can be customized are: |
Application |
See it live! |
The XML/JSON for the above is: |
<chart ...> ... <annotations origW='400' origH='200'> <annotationGroup id='Grp1' showBelow='1' autoScale='1'> <annotation type='rectangle' x='0' y='0' toX='400' toY='200' radius='10' fillColor='333333, 453269' fillAngle='180' /> <annotation type='rectangle' x='5' y='5' toX='395' toY='195' radius='10' color='000000' fillAlpha='0' showBorder='1' borderColor='FFFFFF' borderThickness='3'/> </annotationGroup> <annotationGroup id='Grp2' showBelow='0' autoScale='0'> <annotation type='image' x='125' y='5' URL='logo.gif' /> </annotationGroup> </annotations> </chart> { "chart": {...}, ... "annotations": { "origw": "400", "origh": "200", "groups": [ { "id": "Grp1", "showbelow": "1", "autoscale": "1", "items": [ { "type": "rectangle", "x": "0", "y": "0", "tox": "400", "toy": "200", "radius": "10", "fillcolor": "333333, 453269", "fillangle": "180" }, { "type": "rectangle", "x": "5", "y": "5", "tox": "395", "toy": "195", "radius": "10", "color": "000000", "fillalpha": "0", "showborder": "1", "bordercolor": "FFFFFF", "borderthickness": "3" } ] }, { "id": "Grp2", "showbelow": "0", "autoscale": "0", "items": [ { "type": "image", "x": "85", "y": "7", "url": "logo.png" } ] } ] } } |