繁体   English   中英

WP7中的饼图

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM