GraphicsLayer selectionGraphicslayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; selectionGraphicslayer.ClearGraphics();
<Grid Style="{StaticResource WrapperStyle}">
<chartingToolkit:Chart Title="AnimationSequence = FirstToLast" Palette="{StaticResource GrowPieDataPointPalette}" Style="{StaticResource ChartStyle}" MouseLeftButtonDown="OnMouseLeftButtonDown" Margin="1,4,-1,-4">
<chartingToolkit:Chart.Series>
<chartingToolkit:PieSeries ItemsSource="{Binding ElementName=Map, Path=Layers[MySelectionGraphicsLayer].Graphics}" DependentValueBinding="{Binding Attributes[DISPDESC]}" AnimationSequence="FirstToLast"/>
</chartingToolkit:Chart.Series>
</chartingToolkit:Chart>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock x:Name="DataDisplayTitle" Text="Search Results" FontSize="9" Grid.Row="0" FontWeight="Bold" FontFamily="Arial" Foreground="#FFFFFFFF" />
<esriWidgets:FeatureDataGrid Grid.Row="1" x:Name="QueryDetailsDataGrid" Height="170"
Map="{Binding ElementName=Map}"
GraphicsLayer="{Binding Layers[MySelectionGraphicsLayer], ElementName=Map}" />
</Grid>
Check :
- that the attribute SHAPE_Length is exposed by your service,
- that your are using the right case
- and that you included this attribute in the list of returned attributes (i.e. OutFields="*" or OutFields="........, SHAPE_Length")
WHAT NEXT TO DO TO SOLVE THIS ISSUE
As I saw your are displaying the SHAPE_Length in the grid, can you check that there is no special values (such as null or infinity) that could explain why the sum is crashing?
If it's the case, you may need a converter to replace these special values by something else (likely 0).
If it's not the case, I guess you need more debugging to figure out what are the lengths when the sum is crashing.
Hope this help.
public class AttributeGroup
{
public string Key { get; set; }
public int Sum { get; set; }
public int Count { get; set; }
public int Key2 { get; set; }
public IEnumerable<Graphic> Graphics { get; set; } // only useful for graphics selection from sliver selection
}
DataContext = graphicsLayer.Graphics.GroupBy(graphic => (string)graphic.Attributes["TYPECODE"],
(typecode, graphics) => new AttributeGroup
{
Key = typecode,
Key2 = graphics.GroupBy(g => (int)g.Attributes["CALL"]),
Count = graphics.Count(),
Sum = graphics.Select(g => (int)g.Attributes["DOW"]).Sum(),
Graphics = graphics
}).ToArray(); <userControls:CollapsiblePanel x:Name="LineGrid" IsExpanded="False" VerticalAlignment="Top"
HorizontalAlignment="Right" Margin="0,75,10,0" Width="420" Height="320" Effect="{StaticResource dropShadow}" >
<Grid Width="400" Height="300" HorizontalAlignment="Right" VerticalAlignment="Center">
<Border Background="{StaticResource CommonPanelBorderBackgroundBrush}" BorderBrush="{StaticResource CommonBorderBrush}" BorderThickness="1" CornerRadius="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Border Effect="{StaticResource miniDropShadow}" Style="{StaticResource RibbonElementBorder}" Padding="15" Margin="10" >
<chartingToolkit:Chart Title="Police DATA">
<chartingToolkit:Chart.Series>
<chartingToolkit:LineSeries IsSelectionEnabled="True" SelectionChanged="LineSeries_SelectionChanged"
Title="CAD CALL TYPE"
ItemsSource="{Binding}"
IndependentValuePath="KEY2"
DependentValuePath="Count"
/>
</chartingToolkit:Chart.Series>
</chartingToolkit:Chart>
</Border>
</Border>
<Image Source="images/CloseX.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="3" Stretch="None" Cursor="Hand" ToolTipService.ToolTip="Close" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown" >
<actions:ToggleCollapseAction TargetName="LineGrid" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
</Grid>
</userControls:CollapsiblePanel>
// PIE CHART - create an enumeration of AttributeGroup from the graphics in your layer
DataContext = graphicsLayer.Graphics.GroupBy(graphic => (string)graphic.Attributes["TYPECODE"],
(typecode, graphics) => new AttributeGroup
{
Key = typecode,
Count = graphics.Count(),
Sum = graphics.Select(g => (int)g.Attributes["DOW"]).Sum(),
Graphics = graphics
}).ToArray();
//END PIE CHART
//LINE CHART
DataContext = graphicsLayer.Graphics.GroupBy(graphic => (int)graphic.Attributes["CALL"],
(call, graphics) => new AttributeGroup
{
Key2 = call,
// GISDATE = DateTime.ParseExact(gisdate.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture),
Count = graphics.Count(),
Sum = graphics.Select(g => (int)g.Attributes["DOW"]).Sum(),
Graphics = graphics
}).ToArray();
//END LINE CHART