[英]Is there a way I can display data via a line graph/pie chart in an wp7 application?
[英]Pie chart in wp7
有沒有什么辦法來繪制餅圖WP7?
如果沒有,有沒有辦法繪制一個具有基於用戶價值的扇形的橢圓?
我已經看到了一些第三方工具來繪制餅圖,但是對此我並不滿意。
請提供任何代碼或任何其他方式來獲取餅圖
我曾嘗試以下,但它不工作:
EllipseGeometry OuterEllipse = new EllipseGeometry();
EllipseGeometry InnerEllipse = new EllipseGeometry();
OuterEllipse.Center = new Point(100, 100);
OuterEllipse.RadiusX = 100;
OuterEllipse.RadiusY = 100;
InnerEllipse.Center = new Point(100, 100);
InnerEllipse.RadiusX = 90;
InnerEllipse.RadiusY = 90;
System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
System.Windows.Shapes.Path path1 = new System.Windows.Shapes.Path();
SolidColorBrush solidbrush = new SolidColorBrush(Colors.Blue);
path.Fill = solidbrush;
path.Data = OuterEllipse;
SolidColorBrush solidbrush1 = new SolidColorBrush(Colors.Yellow);
path1.Fill = solidbrush1;
path1.Data = InnerEllipse;
Chart_stackPanel.Children.Add(path);
Chart_stackPanel.Children.Add(path1);`
任何幫助!
這是一個示例,您可以使用xaml代碼在Windows Phone7中繪制帶有兩個分區的餅圖。
<TextBlock Height="31" HorizontalAlignment="Left" Margin="165,9,0,0" Name="Dashboard_Head_Block" Text="dashboard" Foreground="GreenYellow" FontFamily="Times New Roman" FontSize="26" VerticalAlignment="Top" Width="124" />
<TextBlock Height="30" FontWeight="Bold" HorizontalAlignment="Left" Margin="12,48,0,0" Name="storageDetails_textBlock" Text="mystorage details" VerticalAlignment="Top" Width="175" />
<Border Name="ChartBorder" BorderBrush="GreenYellow" CornerRadius="20" BorderThickness="1" Margin="6,82,8,363">
<StackPanel Background="Black" x:Name="DashBoardOuter_Panel" Loaded="DashBoardOuter_Panel_Loaded" Margin="3,6,7,6">
<Border Name="PieBorder" BorderBrush="BlueViolet" BorderThickness="5" HorizontalAlignment="Right" Height="214" Margin="0,50,8,0" Width="150">
<StackPanel Margin="3,2,3,3">
<Rectangle Name="UsedRect" Height="36" Margin="0,30,81,0" StrokeStartLineCap="Round" Stroke="Green" StrokeThickness="5" StrokeMiterLimit="50" StrokeLineJoin="Round" Width="37" >
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF092F7A" Offset="0.613"/>
<GradientStop Color="#FF444AA3" Offset="0.335"/>
<GradientStop Color="#FF4F55C0"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Name="Used_TextBlock" Margin="45,-35,0,0" Height="34" TextWrapping="Wrap" Text="Used" Width="69" />
<Rectangle Name="UnusedRect" Height="34" Margin="-80,60,0,0" StrokeStartLineCap="Round" Stroke="Green" StrokeThickness="5" StrokeMiterLimit="50" StrokeLineJoin="Round" Width="40">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF84DE2F" Offset="1"/>
<GradientStop Color="#FF345812" Offset="0.017"/>
<GradientStop Color="#FF2B4E09" Offset="0.487"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Name="Unused_TextBlock" Height="31" Margin="51,-35,8,0" TextWrapping="Wrap" Text="Unused" Width="71" />
</StackPanel>
</Border>
</StackPanel>
</Border>
<StackPanel Background="Black" Height="291" HorizontalAlignment="Left" x:Name="Dashboard_Panel" VerticalAlignment="Top" Width="279" Margin="12,93,0,0" RenderTransformOrigin="0.57,0.581">
<StackPanel.Projection>
<PlaneProjection x:Name="DStack_Plane"></PlaneProjection>
</StackPanel.Projection>
<StackPanel.Resources>
<Storyboard x:Name="DOuter_Panel">
<DoubleAnimation Storyboard.TargetName="DStack_Plane"
Storyboard.TargetProperty="RotationX"
From="0" To="360" Duration="0:0:1" />
</Storyboard>
</StackPanel.Resources>
<Ellipse Height="291" Margin="8,0" StrokeStartLineCap="Round" Stroke="Green" StrokeThickness="5" StrokeMiterLimit="50" StrokeLineJoin="Round">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FF113987" Offset="1"/>
<GradientStop Color="#FF444AA3" Offset="0.683"/>
<GradientStop Color="#FF252B99"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<es:Arc ArcThickness="1" ArcThicknessUnit="Percent" EndAngle="360" Height="288" Margin="10,-290,8,0" StrokeStartLineCap="Round" Stretch="None" Stroke="Green" StrokeThickness="5" StrokeMiterLimit="50" StrokeLineJoin="Round" StartAngle="95" UseLayoutRounding="False">
<es:Arc.Fill>
<RadialGradientBrush>
<GradientStop Color="#FF3AAF22" Offset="0.652"/>
<GradientStop Color="#FF1B700C" Offset="0.996"/>
<GradientStop Color="#FF258914"/>
</RadialGradientBrush>
</es:Arc.Fill>
</es:Arc>
</StackPanel>
<Ellipse HorizontalAlignment="Left" Height="36" Margin="145,215,0,0" StrokeStartLineCap="Round" Stroke="#FF252B99" StrokeThickness="5" StrokeMiterLimit="50" StrokeLineJoin="Round" VerticalAlignment="Top" Width="35" RenderTransformOrigin="0.871,1.653">
<Ellipse.Fill>
<RadialGradientBrush>
<GradientStop Color="#FF6162B4" Offset="0.165"/>
<GradientStop Color="#FF161760" Offset="0.457"/>
<GradientStop Color="#FF5455AD" Offset="0.761"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.