官术网_书友最值得收藏!

Time for action — setting currency notes as the chart background

  1. Create a copy of ChartBackground.html and ChartBackground.xml, and rename them to ImageBackground.html and ImageBackground.xml respectively. Also make the change in XML data URL.
  2. Change the chart type to Column2D.swf in ImageBackground.html using the following line of code:
    var myChart = new FusionCharts("../FusionCharts/Column2D.swf", "myChartId", "400", "300", "0", "1" );
    
  3. Find a nice background image with currency notes. You can either search for an image shared under the Creative Commons license at http://search.creativecommons.org/ or use the beautiful image at http://www.flickr.com/photos/amagill/3367543296/sizes/z/in/photostream/. Save it as money.jpg in the CustomizingCharts folder.
  4. Add the attribute canvasbgAlpha='0' to the<chart> element, and remove bgColor='CCCCCC'.
  5. Add the attributes bgImage='money.jpg' bgImageAlpha='30' bgImageDisplayMode='fit'.
  6. Open ImageBackground.html in a browser to see money sprayed behind the revenue figures in the chart, as shown in the following screenshot:
    Time for action — setting currency notes as the chart background

What just happened?

We changed the chart type to the 2D Column chart as it brings out the background image much better. In a 3D chart, the canvas would come in the way of the image and removing the canvas is not an option as that would leave the columns hanging in thin air. After finding a nice image to go with the chart, we removed the background color of the chart and made the canvas of the chart transparent to get a full view of the currency notes.

To add a background image, all we had to do was specify the relative path of the image to the bgImage attribute. Due to security restrictions, your image file has to reside on the same sub-domain as the chart file and a relative path to it has to be specified. Thereafter, we reduced the transparency of the image using bgImageAlpha so that it did not hinder the comprehensibility of the chart. Finally, to get the image to fit proportionately on the entire chart, we set bgImageDisplayMode to fit. There are other modes that you can select from as well: Stretch, Tile, Fill, and Center. You can either pick any of these modes or manually set the scaling and alignment of the images using the attributes discussed at www.fusioncharts.com/docs | Quick Chart Configuration | Chart Border & Background.

主站蜘蛛池模板: 新宁县| 南宁市| 密山市| 札达县| 元谋县| 承德市| 东莞市| 南和县| 宁国市| 新乡县| 沾益县| 三原县| 察雅县| 黑山县| 黄山市| 木兰县| 黄山市| 鸡泽县| 印江| 措美县| 大埔县| 青田县| 永济市| 岳普湖县| 南木林县| 石嘴山市| 乐至县| 金溪县| 抚顺市| 象州县| 固阳县| 翁源县| 兴安县| 丰台区| 惠来县| 泽普县| 扎赉特旗| 哈尔滨市| 稷山县| 永新县| 罗江县|