You are viewing documentation for an older version. For current documentation - click here.

To use the Styles feature in FusionWidgets XT, you first need to define your styles in the XML/JSON data document.

To define Styles, the following data is used:

<chart>
<!-- Your data here -->
  <styles>

    <definition>
        <style name='MyFirstFontStyle' type='font' font='Verdana' size='12' color='FF0000' bold='1' bgColor='FFFFDD' />
        <style name='MyFirstAnimationStyle' type='animation' param='_xScale' start='0' duration='2' />
        <style name='MyFirstShadow' type='Shadow' color='CCCCCC' />
    </definition>

    <application>
        <apply toObject='Caption' styles='MyFirstFontStyle,MyFirstShadow' />
<apply toObject='Canvas' styles='MyFirstAnimationStyle' /> <apply toObject='DataPlot' styles='MyFirstShadow' /> </application> </styles> </chart>
{
  "chart": {},
  "styles": {
    "definition": [
      {
        "name": "MyFirstFontStyle",
        "type": "font",
        "font": "Verdana",
        "size": "12",
        "color": "FF0000",
        "bold": "1",
        "bgcolor": "FFFFDD"
      },
      {
        "name": "MyFirstAnimationStyle",
        "type": "animation",
        "param": "_xScale",
        "start": "0",
        "duration": "2"
      },
      {
        "name": "MyFirstShadow",
        "type": "Shadow",
        "color": "CCCCCC"
      }
    ],
    "application": [
      {
        "toobject": "Caption",
        "styles": "MyFirstFontStyle,MyFirstShadow"
      },
      {
        "toobject": "Canvas",
        "styles": "MyFirstAnimationStyle"
      },
      {
        "toobject": "DataPlot",
        "styles": "MyFirstShadow"
      }
    ]
  }
}

As you can see above, all the style related elements and attributes appear under the <styles> parent element. It should effectively contain all your style related code. FusionWidgets XT will not recognize any style definition outside the <styles> parent element.

Children to the <styles> element are <definition> and <application> elements. As the name suggests, <definition> element contains your custom styles definition for the chart while under the <application> element, you apply your custom defined Styles to different chart objects.

Now, let's first get to the definition of styles.

Defining your Styles

Cruising back through the above XML/JSON code, you'll see that we've defined three custom styles namely:

  • MyFirstFontStyle, which will later help us in setting font properties for text on the chart.
  • MyFirstAnimationStyle, which will help us in animating a chart object, and
  • MyFirstShadow that can render a shadow effect on any chart object.

Each style has to be defined using the <style> element. Multiple style elements may be placed one after another under <definition> element. So, if you wish to define five custom styles, you need to create five <style> elements.

Depending on the style type you are defining, each <style> element can have multiple attributes. In the above code example, each <style> element has its own set of properties. However, following two attributes are common to all:

  1. name
  2. type

Both the attributes are mandatory for each style definition.

Mandatory Attributes
name

Name attribute lets you assign your custom name for the style definition. For example, in the above code, we have named the font style as MyFirstFontStyle, which could well have been JohnFirstStyle or GlobalFont or BigFont etc.

Format:

name='stylename'

Example:

<style name='MyFirstFontStyle' type='font' face='Verdana'.../>
<style name='MyFirstAnimationStyle' type='animation' .../>
<style name='MyFirstShadow' type='Shadow' .../>
"definition":[{ "name":"MyFirstFontStyle", "type":"font", "face":"Verdana", ...},
    { "name":"MyFirstAnimationStyle", "type":"animation", ...},
    { "name":"MyFirstShadow", "type":"Shadow", ...}]

There are no restrictions on the style name, barring the pointers below:

  • Style name can only include alphabets and numbers. Punctuation marks (including underscore) shouldn't be used.
  • Style name must be unique, i.e., two style definitions cannot have the same name as there will be a conflict between the two.
type

Each style needs to be defined as to what type it is. The type defines what this style is going to do. FusionWidgets XT supports six style types:

  • Font
  • Animation
  • Shadow
  • Glow
  • Blur
  • Bevel

So, the type attribute expects one of the above six values as its parameter. In our example, we've defined the first style type as "font", second one as "animation" and third one as "shadow", which is self explanatory.

Format:

type='parameter' (must be either 'Font' or 'Animation' or 'Shadow' or 'Glow' or 'Blur' or 'Bevel')

Example:

<style name='MyFirstFontStyle' type='font' face='Verdana' .../>
<style name='MyFirstAnimationStyle' type='animation' .../>
<style name='MyFirstShadow' type='Shadow' .../>
"definition":[{ "name":"MyFirstFontStyle", "type":"font", "face":"Verdana", ...},
    { "name":"MyFirstAnimationStyle", "type":"animation", ...},
    { "name":"MyFirstShadow", "type":"Shadow", ...}]

If you do not define a style type for a particular style, FusionWidgets XT will ignore the style definition and log an error in the Debug Window.

Other Attributes

The rest of the attributes of a Style element are dependent on its type. For example, we can use face, size, color, bold etc. property for a Font style type. However, the same is not valid for Animation style type, as these parameters make no sense for an animation. Each style type has therefore its own set of attributes which you can specify which will be discussed next.

Now, if you're already eager to apply the styles to chart objects, let's get to the application part of the story.

Applying custom defined Styles to chart objects

To apply your defined Styles to chart objects, you first need to make sure that you've the list of chart objects present in each chart. This can be found here in the Chart Objects section of the XML Sheet for each chart.

For example, we've the following chart objects for Angular Gauge:

Object Name Description Features Supported Animation Parameters Supported
BACKGROUND Background refers to the background for entire chart.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
  • _xScale
  • _yScale
DIAL All the dials on the gauge.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
  • _xScale
  • _yScale
  • _rotation
GAUGE The color range (qualitative range) for the chart.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
  • _xScale
  • _yScale
  • _rotation
PIVOT The base circle from which dial emanates.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
  • _xScale
  • _yScale
VALUE Value textfield for the dial (if visible).
  • Animation
  • Font
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
TICKMARKS Tick marks on the gauge scale.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
TICKVALUES Value for tick marks.
  • Animation
  • Font
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
LIMITVALUES Textfield representing chart lower and upper limit.
  • Animation
  • Font
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
TRENDPOINTS All defined trend points for the chart.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
TRENDVALUES Value of defined trend lines.
  • Animation
  • Font
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
TRENDMARKERS Trend-markers, if any.
  • Animation
  • Shadow
  • Glow
  • Bevel
  • Blur
  • _alpha
  • _x
  • _y
  • _xScale
  • _yScale
TOOLTIP Tooltip for the chart.
  • Font
 
Each chart has a different list of Objects. So, you need to ensure that you're working with the right Object name for the given chart.

Now, the following XML/JSON does the work of applying styles to different chart objects:

<application>
   <apply toObject='Caption' styles='MyFirstFontStyle,MyFirstShadow' />
   <apply toObject='Canvas' styles='MyFirstAnimationStyle' />
   <apply toObject='DataPlot' styles='MyFirstShadow' />
</application> 
"application":[{ "toobject":"Caption", "styles":"MyFirstFontStyle,MyFirstShadow" },
            { "toobject":"Canvas", "styles":"MyFirstAnimationStyle" },
            { "toobject":"DataPlot", "styles":"MyFirstShadow" }]

Each <apply> element helps to apply multiple styles to one chart object e.g., in our code, we first apply the MyFirstFontStyle font style to Caption of the chart and then apply the shadow style MyFirstShadow to the same object. To apply multiple styles, we separate the names of the respective styles by a comma.

Format:

<apply toObject='Object' styles='Style1, Style2, Style3 ...' />

You need to make sure of few things here:

  • To apply multiple styles to a chart object, you need to separate the style names using comma.

    Example:

    <apply toObject='Caption' styles='MyFirstFontStyle,MyFirstShadow' />
    "application":[{ "toobject":"Caption", "styles":"MyFirstFontStyle,MyFirstShadow" }]
  • To apply a single style to multiple objects, you'll need to define the <apply> element for each object and then assign the style for it.

    Example:

    <apply toObject='Caption' styles='MyFirstShadow' />
    <apply toObject='DataPlot' styles='MyFirstShadow' />
    "application":[{ "toobject":"Caption", "styles":"MyFirstShadow" },
    { "toobject":"DataPlot", "styles":"MyFirstShadow" }]

    You CANNOT separate the object list by comma and then assign a single style to it - the following will be INVALID:

    <apply toObject='Caption,DataPlot' styles='MyFirstShadow' />
    "apply":[{ "toobject":"Caption","DataPlot", "styles":"MyFirstShadow" }]
  • The style name specified during application has been defined earlier in style definition and the spelling is correct, else, FusionWidgets XT will ignore it and log the error in Debug Window.

Applying custom defined Styles to annotation objects

You can also apply custom defined Styles to annotation objects. Whenever you have to apply Styles to annotations, you have to make an annotation group, put the annotations in the annotation group and then just name the ID in the toObject attribute of the <apply> element.

For a detailed discussion (with example) on how to apply Styles to annotations, please have a look at the Using Styles page of the Annotations section.

Note: In JavaScript charts, customized animation, shadow, glow, bevel and blur style types are not available. JavaScript charts provide limited support for customized Font style.

And now that you're familiar with style definition and application, we move on to see the list of parameters supported by each style type. We start with Font style next.