How do I show only the graph of a chart (No Legend, No Title, Minimum Space Used) in Silverlight 3.0?
I'm writing a Silverlight application that 开发者_StackOverflow中文版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!
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.
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"
精彩评论