Annotations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Annotations let you create your own custom objects (shapes, images, text etc.) in the charts. You can create various shapes like polygons, rectangles, circles, arcs, etc., render annotation text at required positions and load external GIF/JPEG/PNG images or other Flash movies in the chart itself. The main features of annotations are:
Shown below are a few samples where we've applied annotation over charts: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There are a lot of cosmetic and functional properties that you can define for each annotation and customize it entirely the way you want. Let's now take a look at a sample XML/JSON data containing the structure required to create annotations. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<chart manageResize="1" origW="270" origH="270" bgColor="333333" bgAlpha="100" gaugeStartAngle="90" gaugeEndAngle="-270" lowerLimit="0" upperLimit="12" lowerLimitDisplay=" " upperLimitDisplay="12" majorTMNumber="12" majorTMThickness="3" majorTMColor="FFFFFF" majorTMHeight="7" minorTMNumber="4" minorTMColor="FFFFFF" minorTMHeight="4" placeValuesInside="1" tickValueStep="3" tickValueDistance="20" gaugeOuterRadius="95" gaugeInnerRadius="95" showShadow="0" pivotRadius="6" pivotFillColor="FFFFFF" annRenderDelay="0"> { "chart": { "manageResize": "1", "origW": "270", "origH": "270", "bgcolor": "333333", "bgalpha": "100", "gaugestartangle": "90", "gaugeendangle": "-270", "lowerlimit": "0", "upperlimit": "12", "lowerlimitdisplay": " ", "upperlimitdisplay": "12", "majortmnumber": "12", "majortmthickness": "3", "majortmcolor": "FFFFFF", "majortmheight": "7", "minortmnumber": "4", "minortmcolor": "FFFFFF", "minortmheight": "4", "placevaluesinside": "1", "tickvaluestep": "3", "tickvaluedistance": "20", "gaugeouterradius": "95", "gaugeinnerradius": "95", "showshadow": "0", "pivotradius": "6", "pivotfillcolor": "FFFFFF", "annrenderdelay": "0" }, "dials": { "dial": [ { "value": "5", "color": "FFFFFF", "basewidth": "3", "topwidth": "1", "radius": "70", "rearextension": "12" } ] }, "annotations": { "groups": [ { "id": "Grp1", "x": "135", "y": "135", "showbelow": "1", "items": [ { "type": "circle", "x": "0", "y": "0", "color": "EBF0F4,85898C,484C4F,C5C6C8", "fillratio": "30,30,30,10", "fillangle": "270", "radius": "120", "fillpattern": "linear" }, { "type": "circle", "x": "0", "y": "0", "color": "8E8E8E,83878A,E7E7E7", "fillangle": "270", "radius": "105", "fillpattern": "linear" }, { "type": "circle", "x": "0", "y": "0", "color": "07476D,19669E,186AA6,D2EAF6", "fillratio": "5,45,40,10", "fillangle": "270", "radius": "103", "fillpattern": "linear" }, { "type": "circle", "x": "0", "y": "0", "color": "07476D,19669E,07476D", "fillratio": "5,90,5", "fillangle": "270", "radius": "100", "fillpattern": "linear" } ] }, { "id": "Grp2", "x": "135", "y": "135", "showbelow": "1", "items": [ { "type": "circle", "x": "0", "y": "0", "radius": "12", "color": "012A46" } ] } ] }, "styles": { "definition": [ { "name": "TTipFont", "type": "font", "color": "FFFFFF", "bgcolor": "706C11", "bordercolor": "706C11", "font": "Verdana", "size": "10" }, { "name": "ValueFont", "font": "Times New Roman", "italic": "1", "type": "font", "size": "18", "color": "FFFFFF", "bold": "1" } ], "application": [ { "toobject": "TOOLTIP", "styles": "TTipFont" }, { "toobject": "TICKVALUES", "styles": "ValueFont" }, { "toobject": "LIMITVALUES", "styles": "ValueFont" } ] } } |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Explanation of the structure | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The <annotations> element signifies the start of annotations in the data. All the code to generate the annotations is enclosed within the <annotations> element in XML. Each annotation has to be placed within one annotation group or the other. An annotation group is created using the <annotationGroup> element in XML. Each annotation group necessarily has to have a unique ID. This ID comes into use when you are using styles, Alert manager or JavaScript API. Individual annotation objects (line, circle, rectangle, arc, polygon, image and text) can be placed within the annotation group using the <annotation> element in XML. Each annotation element has some essential properties like type, x, y etc. and lots of other cosmetic and functional properties. The basic XML/JSON structure to define annotations is as follows: <chart ...> { "chart": { ... }, "annotations": { /* groups Array containing Annotation Group - each item is an Object referring to an Annotation Group */ "groups": [ /* Annotation Group 1 */ { /* ID of Annotation Group 1 */ "id": "Grp1", /* Collection of Annotataion objects for Grp1 in items Array */ "items": [ { "type": "line", "x": "135", "y": "135", "toX" : "135", "toY" : "170", "color": "FF0000" }, { "type": "rectangle", "x": "50", "y": "50", "toX" : "100", "toY" : "100", "color": "8E8E8E" }, ... ] }, /* Annotation Group 2 */ { /* ID of Annotation Group 2 */ "id": "Grp2", /* Collection of Annotataion objects for Grp2 in items Array */ "items": [ { "type": "circle", "x": "135", "y": "135", "radius": "12", "color": "012A46" }, ... ] } ] } ... } Let's take a look at each of these elements in greater detail now. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<annotationGroup> element | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<annotationGroup> elements are used to consolidate a number of annotations under one group. For example, say that you've created your company logo using custom objects and you want the logo to be present on all the charts (on the top left corner). Now, your company logo consists of two polygons, one rectangle, three lines and two textboxes. So, you can group all of these individual annotations under an <annotationGroup>, so that whenever you need to re-position the logo on the chart or scale it, you can directly assign the new position to the annotation group itself, instead of applying the same to all the annotations within. Also, if you need to show an annotation below the chart, you can set the layering depth of the same using annotation group only. For example, you've created a textured background using annotations and now you want all your charts to have that textured background. However, by default if you just place it within an annotation group, the background will appear over the chart. With the showBelow property of the annotationGroup element, you can configure to show the entire annotation group below the chart. In an annotation group, the annotation which has been defined first will appear at the bottom-most position within that respective group and the one which has been defined last will appear at the top-most. If the chart contains more than one annotation group, then the stacking order of various annotation groups is also determined similarly. Let's study the attributes supported by <annotationGroup> element in detail:
You can have as many numbers of annotation groups as you want - however, it is wise to group related annotations under one group, rather than creating groups at random. Now that you're clear with annotation groups, let's have a look at the main element of annotations - the <annotation> element. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<annotation> element | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Each <annotation> element helps you specify an annotation for the chart. And for each annotation, there are a lot of properties which you can define using the attributes of this element. The most important attribute of this element is type, which helps you define what kind of annotation needs to be drawn. Example: The type attribute of the <annotation> element can take the following values: Pretty self explanatory - each of these types of annotation helps you create that shape on the chart. Every annotation needs a few other parameters to function properly. Like the rectangle needs to know where to start from and where to end. Also, it needs the cosmetic properties like border color, fill color etc. It's not necessary to define all the properties, as FusionWidgets XT will take the default value for all those attributes whose value you've not specified. Let's now delve into the attributes for each annotation type that can help you control the annotation better. |