views:

598

answers:

2

I'm writing a Silverlight application that is showing a pie chart of completed items as an item in a DataGrid. I currently can get the graph to show as an item in the DataGrid using a DataGridTemplateColumn.

My problem is the grid blows out the height of the data row because it has a title and a legend and a lot of allocated whitespace around it. I JUST want to show the pie chart only, with no extra padding or information.

I have found a few convoluted styling ways to do this but they seem to throw syntax errors (perhaps they are Silverlight 2.0 solutions?)

Does anyone have a working way of doing this in Silverlight 3.0?

thanks in advance!

A: 

Try adding a negative margin to the Pie chart. This will cause the chart to be placed lower in the grid and crop the (invisible) title.

Margin = "-10,-10,-10,-10"
NotDan
This doesn't seems to work. It appears to just move the border, with the graph staying there.. and this doesn't solve my legend issue either. Thanks for the suggestion.This is what I tried: <chartingToolkit:Chart x:Name="CompleteGraph" Margin="-10,-10,-10,-10" VerticalAlignment="Bottom" d:LayoutOverrides="Width">
Evildonald
+2  A: 

The Chart can be styled extensively, if you want to have a super-frugal chart which basically only has a ChartArea and thats all then you can supply a minimal template for it:-

<charting:Chart>
 <charting:Chart.Style>
  <Style TargetType="charting:Chart">
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate TargetType="charting:Chart">
      <chartingprimitives:EdgePanel x:Name="ChartArea" />
     </ControlTemplate>
    </Setter.Value>
   </Setter>
  </Style>
 </charting:Chart.Style>
 <charting:PieSeries ItemsSource="{Binding}" IndependentValuePath="Value" DependentValuePath="ID" />
</charting:Chart>

Note I'm using the Nov09 Silverlight 3 tool kit. The above contains just the PieChart no borders, padding, title, legend, gradient background or anything but the raw chart itself.

AnthonyWJones
Thanks Anthony! I also found you can auto-generate these styles by (in Blend) right-clicking on the graph -> Edit Template -> Edit a copy...This will generate the full layout and then you can trim away what you don't need!
Evildonald