Setting backgrounds for charts | ||||||||||||||||||||||||
FusionWidgets XT allows you to easily set a background image/movie for your chart. You can use this option to embed background images (GIF, JPEG or PNG), other SWF Files, or data tables (in image format) as your chart background. To embed an image, all you need to do is set the bgImage property of <chart> element. Additionally, you can also configure a lot of other settings like transparency, scale, stretch, tile etc. We will learn about each of these in details soon in this page. Click here to explore all the configurable options of background image using an interactive demo. Let's first see how we may use the bgImage property in a chart, as shown below: |
||||||||||||||||||||||||
<chart caption="Investment Share" isSliced="1" showValues="0" manageResize="1" bgImage="investment-big.jpg" baseFontColor="000000" baseFontSize="11" plotFillAlpha="90" plotBorderAlpha="50" bgColor="E7FFFB,F8FBFA" bgAlpha="80,80" borderColor="C3D1D4" borderAlpha="100"> <set value="10" name="Stocks" color="F8CC48"/> <set value="11" name="Mutual Fund" color="8BBA00"/> <set value="21" name="Government Bonds" color="A66EDD"/> <set value="22" name="Bank Deposits" color="F984A1"/> <styles> <definition> <style name="myShadow" type="shadow" color="FFFFFF" angle="0" distance="1" strength="8" quality="16" blurX="2" blurY="2"/> </definition> <application> <apply toObject="DataLabels" styles="myShadow"/> <apply toObject="DataValues" styles="myShadow"/> <apply toObject="Caption" styles="myShadow"/> </application> </styles> </chart> { "chart": { "caption": "Investment Share", "issliced": "1", "showvalues": "0", "manageresize": "1", "bgimage": "investment-big.jpg", "basefontcolor": "000000", "basefontsize": "11", "plotfillalpha": "90", "plotborderalpha": "50", "bgcolor": "E7FFFB,F8FBFA", "bgalpha": "80,80", "bordercolor": "C3D1D4", "borderalpha": "100" }, "data": [ { "value": "10", "name": "Stocks", "color": "F8CC48" }, { "value": "11", "name": "Mutual Fund", "color": "8BBA00" }, { "value": "21", "name": "Government Bonds", "color": "A66EDD" }, { "value": "22", "name": "Bank Deposits", "color": "F984A1" } ], "styles": { "definition": [ { "name": "myShadow", "type": "shadow", "color": "FFFFFF", "angle": "0", "distance": "1", "strength": "8", "quality": "16", "blurx": "2", "blury": "2" } ], "application": [ { "toobject": "DataLabels", "styles": "myShadow" }, { "toobject": "DataValues", "styles": "myShadow" }, { "toobject": "Caption", "styles": "myShadow" } ] } } |
||||||||||||||||||||||||
In the above code, we're:
When you view this chart (with the background image), you'll get something as under: |
||||||||||||||||||||||||
See it live! | ||||||||||||||||||||||||
Simple and effective - isn't it? In the following sections of this page we will learn how the background image can be configured. |
||||||||||||||||||||||||
Configuring background image | ||||||||||||||||||||||||
FusionWidgets XT allows you to configure the background images. You can configure the following: | ||||||||||||||||||||||||
In the following sections, we will discuss how to implement the above given configurations on the background image. |
||||||||||||||||||||||||
Setting the transparency of the background image | ||||||||||||||||||||||||
You can set the transparency of the image using the bgImageAlpha attribute.The default value of this attribute is '100'. The image remains fully opaque when 100 is set. 0 (zero) turns the image completely transparent. An example code setting the background image 30% transparent is shown as under: | ||||||||||||||||||||||||
In the above code, we have added the attribute bgImageAlpha='50'. The chart will look as under:
| ||||||||||||||||||||||||
Setting the scale of the background image | ||||||||||||||||||||||||
You can also increase or decrease the magnification of the background image. To customize the magnification of the background image the attribute bgImageScale is used. The value of this attribute can be anything between 0-300. The default value of the attribute is 100. Any value less than 100 will reduce the size of the background image and any value more than 100 will increase the size of the background image. | ||||||||||||||||||||||||
In this example below, the value of the bgImageScale attribute is set to 50. Hence, the size of the background image will be reduced to half of its size. |
||||||||||||||||||||||||
The chart for the above code will look as under: | ||||||||||||||||||||||||
See it live! |
||||||||||||||||||||||||
Vertical & Horizontal alignment of the background image | ||||||||||||||||||||||||
You can set the position of the background image on the chart according to your choice by altering the vertical and horizontal alignments of the background image. The two attributes used to set the alignments are bgImageVAlign (top, middle, bottom) and bgImageHAlign (left, middle, right). The default value of these two attributes are bgImageVAlign='top' and bgImageHAlign='left'. By default, the background image will appear on the top-left position of the chart. | ||||||||||||||||||||||||
All possible combinations of vertical and horizontal alignments of the background image are given below: | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
See the samples live! |
||||||||||||||||||||||||
Setting the mode of display of the background image | ||||||||||||||||||||||||
A background image can be displayed using one of the various modes of display. The form can be changed using the bgImageDisplayMode attribute. The values of this attribute are none, center, stretch, tile, fit and fill. By default, the value of the attribute is set to none. Examples with different display modes are shown below: | ||||||||||||||||||||||||
| ||||||||||||||||||||||||
See the samples live! |
||||||||||||||||||||||||
Note: Alignment attributes are ignored for center and stretch display modes and the bgImageScale attribute works only for none, center and tile display modes. |