=== modified file 'src/docbkx/en/dhis2_user_man_web_api.xml' --- src/docbkx/en/dhis2_user_man_web_api.xml 2012-08-01 11:29:29 +0000 +++ src/docbkx/en/dhis2_user_man_web_api.xml 2012-08-02 13:23:42 +0000 @@ -745,8 +745,40 @@ To see a complete working example please visit .
+ Example: Creating a chart carousel with the carousel plugin + The chart plugin also makes it possible to create a chart carousel which for instance can be used to create an attractive front page on a Web portal. To use the carousel we need to import a few files in the head section of our HTML page: + +<link rel="stylesheet" type="text/css" href="http://apps.dhis2.org/demo/dhis-web-commons/javascripts/ext/resources/css/ext-plugin-gray.css" /> +<link rel="stylesheet" type="text/css" href="http://apps.dhis2.org/demo/dhis-web-commons/javascripts/ext-ux/carousel/css/carousel.css" /> +<script type="text/javascript" src="http://extjs-public.googlecode.com/svn/tags/extjs-4.0.7/release/ext-all.js"></script> +<script type="text/javascript" src="http://apps.dhis2.org/demo/dhis-web-commons/javascripts/ext-ux/carousel/Carousel.js"></script> +<script type="text/javascript" src="http://apps.dhis2.org/demo/dhis-web-commons/javascripts/plugin/plugin.js"></script> + The first file is the CSS stylesheet for the chart plugin. The second file is the CSS stylesheet for the carousel widget. The third file is the Ext javascript framework which this plugin depends on. The fourth file is the carousel plugin javascript file. The fifth file is the chart plugin javascript file. The paths in this example points at the DHIS 2 demo site, make sure you update them to point to your own DHIS 2 installation. + Please refer to the section about the chart plugin on how to do authentication. + To create a chart carousel we will first render the charts we want to include in the carousel using the method described in the chart plugin section. Then we create the chart carousel itself. The charts will be rendered into div elements which all have a CSS class called chart. In the carousel configuration we can then define a selector expression which refers to those div elements like this: + DHIS.getChart({ uid: 'R0DVGvXDUNP', el: 'chartA1', url: base }); +DHIS.getChart({ uid: 'X0CPnV6uLjR', el: 'chartA2', url: base }); +DHIS.getChart({ uid: 'j1gNXBgwKVm', el: 'chartA3', url: base }); +DHIS.getChart({ uid: 'X7PqaXfevnL', el: 'chartA4', url: base }); + +new Ext.ux.carousel.Carousel( 'chartCarousel', { + autoPlay: true, + itemSelector: 'div.chart', + interval: 5, + showPlayButton: true +}); + The first argument in the configuration is the id of the div element in which you want to render the carousel. The autoPlay configuration option refers to whether we want the carousel to start when the user loads the Web page. The interval option defines how many seconds each chart should be displayed. The showPlayButton defines whether we want to render a button for the user to start and stop the carousel. Finally we need to insert the div elements in the body of the HTML document: + <div id="chartCarousel"> + +<div id="chartA1" class="chart"></div> +<div id="chartA2" class="chart"></div> +<div id="chartA3" class="chart"></div> +<div id="chartA4" class="chart"></div> + To see a complete working example please visit . +
+
Example: Embedding report tables with the table plugin - In this example we will see how we can embed dynamic data tables in a Web page with data provided from a DHIS back-end server using the table plugin. The table plugin resides inside the same file as the chart plugin so please refer to the above section on how to include the required javascript and CSS files and how to do authentication. The available table options are listed in the table below. + In this example we will see how we can embed dynamic data tables in a Web page with data provided from a DHIS back-end server using the table plugin. The table plugin resides inside the same file as the chart plugin so please refer to the section about the chart plugin above on how to include the required javascript and CSS files and how to do authentication. The available table options are listed in the table below. Table plugin configuration