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

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.

主站蜘蛛池模板: 肇庆市| 贺州市| 射阳县| 三原县| 射阳县| 合阳县| 平利县| 乳源| 洛阳市| 施秉县| 墨竹工卡县| 崇礼县| 绥芬河市| 湖南省| 微山县| 灵丘县| 河曲县| 临泽县| 尼木县| 孟津县| 黔南| 大邑县| 黄石市| 长白| 浠水县| 阿坝| 玛沁县| 锦州市| 汉源县| 贺兰县| 板桥市| 同德县| 朝阳区| 绥宁县| 宣威市| 华亭县| 马关县| 奎屯市| 新民市| 牡丹江市| 涡阳县|