Dashboard Results
DashboardResults.mxml
<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2008-2014 Esri // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this software, with or without // modification, provided you include the original copyright and use // restrictions. See use restrictions in the file use_restrictions.txt. // //////////////////////////////////////////////////////////////////////////////// --> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:drs="com.esri.drs.*" minWidth="600" minHeight="400" pageTitle="Dashboard Get Results by SEVERITY Sample" viewSourceURL="srcview/index.html"> <!-- Data Reviewer's dashboard statistics provides the ability to report on the quality of the data. Statistics are total counts of a unique value in a specific or custom (user-defined) field in the Reviewer workspace's tables. This sample shows how to retrieve and display dashboard statistics by Severity using the getDashboardResults function. The DashboardTask class exposes methods to retrieve these statistics and the field names from which statistics are generated. --> <fx:Declarations> <!-- Create a DashboardTask and configure its URL and BaseTask settings --> <drs:DashboardTask id="dashboardTask" url="{_soeUrl}" showBusyCursor="true" disableClientCaching="true" getDashboardFieldNamesComplete="dashboardTask_getDashboardFieldNamesCompleteHandler(event)" /> </fx:Declarations> <fx:Script> <![CDATA[ import com.esri.drs.DashboardResult; import com.esri.drs.DashboardTask; import com.esri.drs.DataReviewerTaskEvent; import mx.collections.ArrayList; import mx.events.FlexEvent; import mx.rpc.AsyncResponder; import mx.rpc.Fault; import mx.rpc.events.FaultEvent; import spark.events.IndexChangeEvent; // use this as the pie chart's data provider [Bindable]private var _resultList:ArrayList = new ArrayList(); //Dashboard Field Name collection [Bindable]public var dashboardFieldNames:ArrayList = new ArrayList(); //Amazon instance for Data Reviewer Server. Change to your Data Reviewer Server SOE URL to run this sample in your environment private var _soeUrl:String = "http://datareviewer.arcgisonline.com/arcgis/rest/services/Samples/reviewerDashboard/MapServer/exts/DataReviewerServer"; protected function getDashboardFieldNames(event:FlexEvent): void { // hide chart currentState = "normal"; dashboardTask.getDashboardFieldNames(); } protected function dashboardTask_getDashboardFieldNamesCompleteHandler(event:DataReviewerTaskEvent):void { for each (var fieldName:String in event.result) { dashboardFieldNames.addItem(fieldName); } fieldNamesList.selectedIndex=0; } protected function fieldNamesList_changeHandler(event:IndexChangeEvent):void { currentState = "normal"; } protected function getData_clickHandler(event:MouseEvent):void { //call dashboardTask to get the results dashboardTask.getDashboardResults(fieldNamesList.selectedItem, null, new AsyncResponder(resultHandler, faultHandler)); } private function resultHandler(result:DashboardResult, token:* = null):void { //clear previous results first _resultList = new ArrayList(); if (result == null) { currentState = "error"; } else { // parse the results and convert into a pie chart data provider for each (var item:Object in result.fieldValues) { _resultList.addItem({ text: item, count: result.getCount(item)}); } currentState = "data"; } } private function faultHandler(fault:Fault, token:* = null):void { var msg:String = fault.faultString; if (fault.content != null && fault.content as Array != null) msg = fault.content[1].message; errorMsg.text = "Error: " + msg; currentState = "error"; } ]]> </fx:Script> <s:states> <s:State name="normal"/> <s:State name="data"/> <s:State name="error"/> </s:states> <s:controlBarContent> <s:Label width="100%" text="The following sample displays dashboard statistics from an ArcGIS Data Reviewer for Server hosted on Amazon. Dashboard statistics are displayed in a pie chart. To run the sample against your own Data Reviewer Server, see comments in code for _soeUrl variable."/> </s:controlBarContent> <s:Scroller width="100%" height="100%"> <s:VGroup width="100%" paddingLeft="20" paddingRight="20"> <s:Form width="30%"> <s:layout> <s:FormLayout gap="-5"/> </s:layout> <s:FormHeading label="Dashboard Result by Field Name"/> <s:FormItem label="Dashboard Result By: "> <s:DropDownList id="fieldNamesList" creationComplete="getDashboardFieldNames(event)" dataProvider="{dashboardFieldNames}" width="100%" change="fieldNamesList_changeHandler(event)" /> </s:FormItem> <s:FormItem> <s:layout> <s:HorizontalLayout horizontalAlign="right"/> </s:layout> <s:Button id="getData" height="25" label="Get Dashboard Results" click="getData_clickHandler(event)"/> </s:FormItem> </s:Form> <!-- Chart and Data Grid --> <s:HGroup id="charts" includeIn="data" gap="30"> <mx:PieChart id="fcPieChart" width="380" height="100%" fontWeight="bold" paddingLeft="25" dataProvider="{_resultList}" showDataTips="true"> <mx:series> <mx:PieSeries id="fcPieSeries" calloutGap="1" field="count" labelPosition="callout" maxLabelRadius="0.3" nameField="text" reserveExplodeRadius="0.1"/> </mx:series> </mx:PieChart> <mx:Legend width="150" height="100%" paddingLeft="-10" paddingTop="80" dataProvider="{fcPieChart}"/> <s:VGroup paddingLeft="15" paddingTop="80" gap="4"> <s:Group width="380" verticalScrollPosition="50"> <mx:DataGrid id="fcDG" width="350" dataProvider="{_resultList}" rowCount="5"> <mx:columns> <mx:DataGridColumn id="dataGridColumn1" textAlign="center" minWidth="35" headerText="{fieldNamesList.selectedItem}" dataField="text"/> <mx:DataGridColumn id="dataGridColumn2" textAlign="center" minWidth="20" headerText="COUNT" dataField="count" headerWordWrap="false"/> </mx:columns> </mx:DataGrid> </s:Group> </s:VGroup> </s:HGroup> <!-- Error message --> <s:HGroup id="error" color="red" horizontalAlign="center" paddingLeft="20" paddingTop="20" includeIn="error" itemCreationPolicy="immediate"> <s:Label id="errorMsg" fontSize="15" text="Error"/> </s:HGroup> </s:VGroup> </s:Scroller> </s:Application>
Copyright © 1995-2015 Esri. All rights reserved.
2/23/2015