Ejemplo n.º 1
0
        public void ConstDataPie()
        {
            if (_timePoint != null)
            {
                //TODO БАГ ПРИ СМЕНЕ ДНЯ
                SetDefaultChild();
                List <SectorPart> sectorParts = new List <SectorPart>();
                int allNumber = PieItemSources == null ? 0 : PieItemSources.Sum(x => x.TypeNumber);
                if (allNumber > 0)
                {
                    foreach (var item in PieItemSources)
                    {
                        int    colorCount = sectorParts.Count();
                        double Z_angle    = (double)item.TypeNumber / allNumber * 360;
                        sectorParts.Add(new SectorPart(Z_angle >= 360 ? 359.99 : Z_angle, ColorBrushList[colorCount]));

                        AddIconFill(ColorBrushList[colorCount], allNumber, item);
                    }
                }
                foreach (var shape in GetEllipsePieChartShapes(GetPieCenterPoint(), GetPieWidth(), GetPieWidth(), 0, sectorParts))
                {
                    _timePoint.Children.Add(shape);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 数据动态生成饼图
        /// </summary>
        public void ConstDataPie()
        {
            if (_timePoint != null)
            {
                SetDefaultChild();
                List <SectorPart> sectorParts = new List <SectorPart>();                                  //扇形集合
                int allNumber = PieItemSources == null ? 0 : PieItemSources.Sum(x => x.TypeNumber);       //总数
                if (allNumber > 0)
                {
                    _leftText.Text  += AggregateName + ":\r\n";
                    _rightText.Text += allNumber.ToString() + "\r\n";
                    foreach (var item in PieItemSources)
                    {
                        int    colorCount = sectorParts.Count();
                        double Z_angle    = (double)item.TypeNumber / allNumber * 360;
                        sectorParts.Add(new SectorPart(Z_angle >= 360 ? 359.99 : Z_angle, ColorBrushList[colorCount]));

                        AddIconFill(ColorBrushList[colorCount], allNumber, item);

                        _leftText.Text  += item.TypeName + ":\r\n";
                        _rightText.Text += item.TypeNumber.ToString() + "\r\n";
                    }
                }
                foreach (var shape in GetEllipsePieChartShapes(GetPieCenterPoint(), GetPieWidth(), GetPieWidth(), 0, sectorParts))
                {
                    _timePoint.Children.Add(shape);
                }
            }
        }