=== modified file 'src/docbkx/en/dhis2_user_man_web_api.xml' --- src/docbkx/en/dhis2_user_man_web_api.xml 2013-12-31 09:31:56 +0000 +++ src/docbkx/en/dhis2_user_man_web_api.xml 2014-01-02 10:52:56 +0000 @@ -1441,14 +1441,79 @@ DHIS 2 comes with plugins which enables you to embed live data directly in your web portal or web site. Currently, plugins exist for charts, maps and pivot tables.
Embedding pivot tables with the Pivot table plug-in + In this example we will see how we can embed good-looking, light-weight html pivot tables with data served from a DHIS back-end into a Web page. To accomplish this we will use the Pivot table plug-in. The plug-in is written in Javascript and depends on the Ext JS library only. A complete working example can be found at . Open the page in a web browser and view the source to see how it is set up. - We start by including three files in the header section of the HTML document. The first + + We start by having a look at what the complete html file could look like. This setup puts two tables in our web page. The first one is referring to an existing table. The second is configured inline. + <!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v214/ext/resources/css/ext-plugin-gray.css" /> + <script src="http://dhis2-cdn.org/v214/ext/ext-all.js"></script> + <script src="http://dhis2-cdn.org/v214/plugin/table.js"></script> + + <script> + var base = "http://apps.dhis2.org/demo"; + + // Login - if OK, call the setLinks function + + Ext.onReady( function() { + Ext.Ajax.request({ + url: base + "dhis-web-commons-security/login.action", + method: "POST", + params: { j_username: "portal", j_password: "Portal123" }, + success: setLinks + }); + }); + + function setLinks() { + + // Referring to an existing table through the id parameter, render to "tableA1" div + + DHIS.getTable({ url: base, el: "tableA1", id: "R0DVGvXDUNP" }); + + // Full table configuration, render to "tableB1" div + + DHIS.getTable({ + url: base, + el: "tableB1", + columns: [ + {dimension: "de", items: [{id: "YtbsuPPo010"}, {id: "l6byfWFUGaP"}]} + ], + rows: [ + {dimension: "pe", items: [{id: "LAST_12_MONTHS"}]} + ], + filters: [ + {dimension: "ou", items: [{id: "USER_ORGUNIT"}]} + ], + // All following options are optional + showTotals: false, + showSubTotals: false, + hideEmptyRows: true, + showHierarchy: true, + displayDensity: "comfortable", + fontSize: "large", + digitGroupSeparator: "comma", + legendSet: {id: "BtxOoQuLyg1"} + }); + } + </script> +</head> + +<body> + <div id="tableA1"></div> + <div id="tableB1"></div> +</body> +</html> + + + Three files are included in the header section of the HTML document. The first two files are the Ext JS javascript library (we use the DHIS 2 content delivery network in this case) and its css stylesheet. The third file is the Pivot table plug-in. Make sure the path is pointing to your DHIS server installation. - <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v213/ext/resources/css/ext-plugin-gray.css" /> -<script src="http://dhis2-cdn.org/v213/ext/ext-all.js"></script> -<script src="http://dhis2-cdn.org/v213/plugin/table.js"></script> + <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v214/ext/resources/css/ext-plugin-gray.css" /> +<script src="http://dhis2-cdn.org/v214/ext/ext-all.js"></script> +<script src="http://dhis2-cdn.org/v214/plugin/table.js"></script> To authenticate with the DHIS server we use the same approach as in the previous section. In the header of the HTML document we include the following Javascript inside a script element. The setLinks method will be implemented later. Make sure the base variable is pointing to your DHIS installation. var base = "http://apps.dhis2.org/demo/"; @@ -1600,32 +1665,32 @@ We continue by adding one pre-defined and one dynamic pivot table to our HTML document. You can browse the list of available pivot tables using the Web API here: . - function setLinks() { - PT.plugin.getTable({ url: base, el: 'tableA1', id: 'R0DVGvXDUNP' }); + function setLinks() { + DHIS.getTable({ url: base, el: "tableA1", id: "R0DVGvXDUNP" }); - PT.plugin.getTable({ - url: base, - el: 'tableB1', - type: 'stackedBar', - columns: [ - {dimension: 'de', items: [{id: 'YtbsuPPo010'}, {id: 'l6byfWFUGaP'}]} - ], - rows: [ - {dimension: 'pe', items: [{id: 'LAST_12_MONTHS'}]} - ], - filters: [ - {dimension: 'ou', items: [{id: 'USER_ORGUNIT'}]} - ], - showTotals: false, // All following options are optional - showSubTotals: false, - hideEmptyRows: true, - showHierarchy: true, - displayDensity: "comfortable", - fontSize: "large", - digitGroupSeparator: "comma", - legendSet: {id: "BtxOoQuLyg1"} + DHIS.getTable({ + url: base, + el: "tableB1", + columns: [ + {dimension: "de", items: [{id: "YtbsuPPo010"}, {id: "l6byfWFUGaP"}]} + ], + rows: [ + {dimension: "pe", items: [{id: "LAST_12_MONTHS"}]} + ], + filters: [ + {dimension: "ou", items: [{id: "USER_ORGUNIT"}]} + ], + // All following options are optional + showTotals: false, + showSubTotals: false, + hideEmptyRows: true, + showHierarchy: true, + displayDensity: "comfortable", + fontSize: "large", + digitGroupSeparator: "comma", + legendSet: {id: "BtxOoQuLyg1"} }); -}; +} Finally we include some div elements in the body section of the HTML document with the identifiers referred to in the plug-in Javascript. <div id="tableA1"></div> <div id="tableB1"></div> @@ -1634,13 +1699,78 @@
Embedding charts with the Visualizer chart plug-in In this example we will see how we can embed good-looking Ext JS charts () with data served from a DHIS back-end into a Web page. To accomplish this we will use the DHIS Visualizer plug-in. The plug-in is written in Javascript and depends on the Ext JS library only. A complete working example can be found at . Open the page in a web browser and view the source to see how it is set up. - We start by including three files in the header section of the HTML document. The first + + We start by having a look at what the complete html file could look like. This setup puts two charts in our web page. The first one is referring to an existing chart. The second is configured inline. + <!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v214/ext/resources/css/ext-plugin-gray.css" /> + <script src="http://dhis2-cdn.org/v214/ext/ext-all.js"></script> + <script src="http://dhis2-cdn.org/v214/plugin/chart.js"></script> + + <script> + var base = "http://apps.dhis2.org/demo"; + + // Login - if OK, call the setLinks function + + Ext.onReady( function() { + Ext.Ajax.request({ + url: base + "dhis-web-commons-security/login.action", + method: "POST", + params: { j_username: "portal", j_password: "Portal123" }, + success: setLinks + }); + }); + + function setLinks() { + + // Referring to an existing chart through the id parameter, render to "chartA1" div + + DHIS.getChart({ url: base, el: "chartA1", id: "R0DVGvXDUNP" }); + + // Full chart configuration, render to "chartB1" div + + DHIS.getChart({ + url: base, + el: "chartB1", + type: "stackedBar", + columns: [ // Chart series + {dimension: "de", items: [{id: "YtbsuPPo010"}, {id: "l6byfWFUGaP"}]} + ], + rows: [ // Chart categories + {dimension: "pe", items: [{id: "LAST_12_MONTHS"}]} + ], + filters: [ + {dimension: "ou", items: [{id: "USER_ORGUNIT"}]} + ], + // All following options are optional + showData: false, + targetLineValue: 70, + baseLineValue: 20, + showTrendLine: true, + hideLegend: true, + title: "My chart title", + domainAxisTitle: "Periods", + rangeAxisTitle: "Percent" + }); + } + </script> +</head> + +<body> + <div id="chartA1"></div> + <div id="chartB1"></div> +</body> +</html> + + + Three files are included in the header section of the HTML document. The first two files are the Ext JS javascript library (we use the DHIS 2 content delivery network in this case) and its stylesheet. The third file is the Visualizer plug-in. Make sure the path is pointing to your DHIS server installation. <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v213/ext/resources/css/ext-plugin-gray.css" /> <script src="http://dhis2-cdn.org/v213/ext/ext-all.js"></script> -<script src="http://dhis2-cdn.org/v213/plugin/table.js"></script> +<script src="http://dhis2-cdn.org/v213/plugin/chart.js"></script> To authenticate with the DHIS server we use the same approach as in the previous section. In the header of the HTML document we include the following Javascript inside a script element. The setLinks method will be implemented later. Make sure the base variable is pointing to your DHIS installation. var base = "http://apps.dhis2.org/demo/"; @@ -1828,31 +1958,32 @@ We continue by including two pre-defined charts and to dynamic charts to our HTML document. You can browse the list of available charts using the Web API here: . function setLinks() { - DV.plugin.getChart({ url: base, el: 'chartA1', id: 'R0DVGvXDUNP' }); + DHIS.getChart({ url: base, el: "chartA1", id: "R0DVGvXDUNP" }); - DV.plugin.getChart({ - url: base, - el: 'chartB1', - type: 'stackedBar', - columns: [ - {dimension: 'de', items: [{id: 'YtbsuPPo010'}, {id: 'l6byfWFUGaP'}, {id: 's46m5MS0hxu'}]} - ], - rows: [ - {dimension: 'pe', items: [{id: 'LAST_12_MONTHS'}]} - ], - filters: [ - {dimension: 'ou', items: [{id: 'USER_ORGUNIT'}]} - ], - showData: false, // All following options are optional - targetLineValue: 70, - baseLineValue: 20, - showTrendLine: true, - hideLegend: true, - title: 'My chart title', - domainAxisTitle: 'Periods', - rangeAxisTitle: 'Percent' + DHIS.getChart({ + url: base, + el: "chartB1", + type: "stackedBar", + columns: [ // Chart series + {dimension: "de", items: [{id: "YtbsuPPo010"}, {id: "l6byfWFUGaP"}]} + ], + rows: [ // Chart categories + {dimension: "pe", items: [{id: "LAST_12_MONTHS"}]} + ], + filters: [ + {dimension: "ou", items: [{id: "USER_ORGUNIT"}]} + ], + // All following options are optional + showData: false, + targetLineValue: 70, + baseLineValue: 20, + showTrendLine: true, + hideLegend: true, + title: "My chart title", + domainAxisTitle: "Periods", + rangeAxisTitle: "Percent" }); -}; +} Finally we include some div elements in the body section of the HTML document with the identifiers referred to in the plug-in Javascript. <div id="chartA1"></div> <div id="chartB1"></div> @@ -1862,21 +1993,71 @@
Embedding maps with the GIS map plug-in In this example we will see how we can embed maps with data served from a DHIS back-end into a Web page. To accomplish this we will use the GIS map plug-in. The plug-in is written in Javascript and depends on the Ext JS library only. A complete working example can be found at . Open the page in a web browser and view the source to see how it is set up. - We start by including four files and Google Maps in the header section of the HTML + We start by having a look at what the complete html file could look like. This setup puts two maps in our web page. The first one is referring to an existing map. The second is configured inline. + + <!DOCTYPE html> +<html> +<head> + <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v214/ext/resources/css/ext-plugin-gray.css" /> + <script src="http://dhis2-cdn.org/v214/ext/ext-all.js"></script> + <script src="https://maps.google.com/maps/api/js?sensor=false"></script> + <script src="http://dhis2-cdn.org/v214/openlayers/OpenLayers.js"></script> + <script src="http://dhis2-cdn.org/v214/plugin/map.js"></script> + + <script> + var base = "http://apps.dhis2.org/demo"; + + // Login - if OK, call the setLinks function + + Ext.onReady( function() { + Ext.Ajax.request({ + url: base + "dhis-web-commons-security/login.action", + method: "POST", + params: { j_username: "portal", j_password: "Portal123" }, + success: setLinks + }); + }); + + function setLinks() { + DHIS.getMap({ url: base, el: "mapA1", id: "ytkZY3ChM6J" }); + + DHIS.getMap({ + url: base, + el: "mapB1", + mapViews: [{ + columns: [{dimension: "in", items: [{id: "Uvn6LCg7dVU"}]}], // data + rows: [{dimension: "ou", items: [{id: "LEVEL-3"}, {id: "ImspTQPwCqd"}]}], // organisation units, + filters: [{dimension: "pe", items: [{id: "LAST_3_MONTHS"}]}], // period + // All following options are optional + classes: 7, + colorLow: "02079c", + colorHigh: "e5ecff", + opacity: 0.9, + legendSet: {id: "fqs276KXCXi"} + }] + }); + } + </script> +</head> + +<body> + <div id="mapA1"></div> + <div id="mapB1"></div> +</body> +</html> + Four files and Google Maps are included in the header section of the HTML document. The first two files are the Ext JS javascript library (we use the DHIS 2 content delivery network in this case) and its stylesheet. The third file is the OpenLayers javascript mapping framework () and finally we include the GIS map plug-in. Make sure the path is pointing to your DHIS server installation. - <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v213/ext/resources/css/ext-plugin-gray.css" /> -<script src="http://dhis2-cdn.org/v213/ext/ext-all.js"></script> + <link rel="stylesheet" type="text/css" href="http://dhis2-cdn.org/v214/ext/resources/css/ext-plugin-gray.css" /> +<script src="http://dhis2-cdn.org/v214/ext/ext-all.js"></script> <script src="https://maps.google.com/maps/api/js?sensor=false"></script> -<script src="http://dhis2-cdn.org/v213/openlayers/OpenLayers.js"></script> -<script src="http://dhis2-cdn.org/v213/plugin/map.js"></script> +<script src="http://dhis2-cdn.org/v214/openlayers/OpenLayers.js"></script> +<script src="http://dhis2-cdn.org/v214/plugin/map.js"></script> To authenticate with the DHIS server we use the same approach as in the previous section. In the header of the HTML document we include the following Javascript inside a script element. The setLinks method will be implemented later. Make sure the base variable is pointing to your DHIS installation. - var base = "http://apps.dhis2.org/demo/"; - -Ext.onReady( function() { + Ext.onReady( function() { Ext.Ajax.request({ url: base + "dhis-web-commons-security/login.action", method: "POST", @@ -2080,31 +2261,30 @@ We continue by adding one pre-defined and one dynamically configured map to our HTML document. You can browse the list of available maps using the Web API here: . function setLinks() { - Ext.onReady(function() { - var url = "http://apps.dhis2.org/demo/"; - - GIS.plugin.getMap({ - url: url, - el: "mapA1", - id: "ytkZY3ChM6J" - }); - - GIS.plugin.getMap({ - url: url, - el: "mapB1", - mapViews: [{ - columns: [{dimension: 'in', items: [{id: 'Uvn6LCg7dVU'}]}], // data - rows: [{dimension: 'ou', items: [{id: 'LEVEL-3'}, {id: 'ImspTQPwCqd'}]}], // organisation units - filters: [{dimension: 'pe', items: [{id: 'LAST_3_MONTHS'}]}], // period - classes: 7, - colorLow: '02079c', - colorHigh: 'e5ecff', - opacity: 0.9 - legendSet: {id: 'fqs276KXCXi'} // Optional - }] - }); -}); -}; + DHIS.getMap({ url: base, el: "mapA1", id: "ytkZY3ChM6J" }); + + DHIS.getMap({ + url: base, + el: "mapB1", + mapViews: [ + columns: [ // Chart series + columns: [{dimension: "in", items: [{id: "Uvn6LCg7dVU"}]}], // data + ], + rows: [ // Chart categories + rows: [{dimension: "ou", items: [{id: "LEVEL-3"}, {id: "ImspTQPwCqd"}]}], // organisation units + ], + filters: [ + filters: [{dimension: "pe", items: [{id: "LAST_3_MONTHS"}]}], // period + ], + // All following options are optional + classes: 7, + colorLow: "02079c", + colorHigh: "e5ecff", + opacity: 0.9, + legendSet: {id: "fqs276KXCXi"} + ] + }); +} Finally we include some div elements in the body section of the HTML document with the identifiers referred to in the plug-in Javascript. <div id="mapA1"></div> <div id="mapB1"></div>