Select to view content in your preferred language

Question regarding the chart widget.

865
2
03-11-2011 11:30 AM
DougKampe
Regular Contributor
Hello,

I've successfully modified the chart widget for our organization's needs, but it has one minor quirk with it; when it displays the statistics results, it gives a nonsense value. Actually, I believe it is even doing it on the Flex interactive example: http://www.arcgis.com/home/item.html?id=51558a31b24a4139bf915a0ba47bd25d

So, what should be happening is the widget sumarizes the bumber of features selected and the sum of a user-defined field <summaryfield>DRAIN_ACRES</summaryfield> from the ChartWidget.xml. (Drain acres in my case.) The correct sum should be 370.327, but here is the result straight from the widget: "Total for selected area [1 features]: 2,221. (Again, actual is 370.327.)

Since I'm not a developer (I'm using Flex Builder 4 triall version since yesterday), and I am fruitlessly trying to figure this out, is there something in the code below that is causing this? I highlighted the bottom-most code below which populates the result string.

Thanks,
Doug
ArcGIS Server 9.3.1, Flex 2.2, ChartWidget 2.2


private function calculateStatistics(featureSet:FeatureSet):void
{
summaryValue = 0;

for (var i:Number = 0; i < chartFields.length; i++)
{
var chartFieldArray:Array = chartFields.split(",");
var chartValueArray: Array = [];
for (var j:Number = 0; j < chartFieldArray.length; j++)
{
var label:String = chartFieldArray;
var value: Number = 0;
for (var r:Number = 0; r < featureSet.features.length; r++)
{
value += Number(featureSet.attributes[label]);
summaryValue += Number(featureSet.attributes[summaryField]);
}
var obj:Object = new Object();
obj.label = label;
obj.value = value;
chartValueArray.push(obj);
}
chartSeries.push(chartValueArray);
}
ColumnChartStatistics.visible=false;
PieChartStatistics.visible=true;
PieChartStatistics.dataProvider = chartSeries[0];
var msg:String = chartLabel + " [" + featureSet.features.length + " " + entitiesLabel + "]: " + numFormatter.format(summaryValue);
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Doug,

   I don't know what to tell you about your data but the data on the live site is working fine the summary field is POP2007 and when you use a point to select an individual "Census Block Group" the value in the summary is just the POP2007 value of that block and when you select more than one block than it correctly sums those POP2007 values.
0 Kudos
DougKampe
Regular Contributor
Well, I finally realized that the tool was taking my summaryField and was increasing it by a factor of 6.  Of course, I have no idea why, but as a quick fix I took the final line of code, and divided the summaryValue by 6.  Now it's reporting the correct number!

var msg:String = chartLabel + " [" + featureSet.features.length + " " + entitiesLabel + "]: " + numFormatter.format(summaryValue/6) 

This tool is great! 

Doug
0 Kudos