WPF饼图如何在切片之间添加空间?

我在 WPF 中使用 Telerik(RadPieChart)。如何在切片之间添加空间?

这是我目前拥有的:

http://img1.mukewang.com/61ac768700016b4f07030571.jpg

这就是我希望饼图在切片之间有空格的样子:

http://img1.mukewang.com/61ac76930001d5fc04090333.jpg

这是我的源代码:


private DoughnutSeries CreateDognutSerie(KeyValuePair<ChartSerie, List<ChartDataPoint>> chartSerie, int index, int count)

    {

        double spaceBetweenSperies = 0.0;

        if (count > 1 && index != count - 1)

        {

            spaceBetweenSperies = 0.007;

        }


        var doughnutSerie = new DoughnutSeries()

        {

            ShowLabels = true,

            //LabelConnectorsSettings = new ChartSeriesLabelConnectorsSettings()

            //{


            //},

            InnerRadiusFactor = index / (double)count,

            RadiusFactor      = ((index + 1) / (double)count) - spaceBetweenSperies,

            //LegendSettings = new DataPointLegendSettings()

            //{


            //},

            //SeriesAnimation = new PieChartAngleRangeAnimation()

            //{

            //    InitialStartAngle = -90,

            //    InitialSweepAngle = 180,

            //    Duration          = new TimeSpan(0, 0, 0, 0, 800),

            //}

        };

        foreach (ChartDataPoint serie in chartSerie.Value)

        {

            doughnutSerie.DataPoints.Add(new PieDataPoint()

            {

                Label = serie.XPoint.Label,

                Value = Math.Abs((double?)serie.Value ?? 0),

            });

        }


        return doughnutSerie;

    }


浮云间
浏览 186回答 1
1回答

一只萌萌小番薯

使用中的OffsetFromCenter属性PieDataPoint。类似的东西OffsetFromCenter = 0.015应该类似于上图。public MainWindow(){&nbsp; &nbsp; InitializeComponent();&nbsp; &nbsp; var data = new Dictionary<string, double>&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; { "January", 5 },&nbsp; &nbsp; &nbsp; &nbsp; { "February", 3 },&nbsp; &nbsp; &nbsp; &nbsp; { "March", 5 },&nbsp; &nbsp; &nbsp; &nbsp; { "April", 7 },&nbsp; &nbsp; &nbsp; &nbsp; { "May", 2 },&nbsp; &nbsp; &nbsp; &nbsp; { "June", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "July", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "August", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "September", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "October", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "November", 11 },&nbsp; &nbsp; &nbsp; &nbsp; { "December", 12 },&nbsp; &nbsp; };&nbsp; &nbsp; var series = CreateDougnutSeries(data);&nbsp; &nbsp; var pie = new RadPieChart { Palette = ChartPalettes.Fluent };&nbsp; &nbsp; pie.Series.Add(series);&nbsp; &nbsp; mainGrid.Children.Add(pie);}private DoughnutSeries CreateDougnutSeries(Dictionary<string, double> data){&nbsp; &nbsp; var doughnutSeries = new DoughnutSeries&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; ShowLabels = true,&nbsp; &nbsp; &nbsp; &nbsp; InnerRadiusFactor = 0,&nbsp; &nbsp; &nbsp; &nbsp; RadiusFactor = 1&nbsp; &nbsp; };&nbsp; &nbsp; foreach (var point in data)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; doughnutSeries.DataPoints.Add(new PieDataPoint()&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Label = point.Key,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Value = point.Value,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OffsetFromCenter = 0.015&nbsp; &nbsp; &nbsp; &nbsp; });&nbsp; &nbsp; }&nbsp; &nbsp; return doughnutSeries;}增加OffsetFromCenter说0.1会渲染更粗的线条:
打开App,查看更多内容
随时随地看视频慕课网APP