Exemplo n.º 1
0
        public RunStatus()
        {
            InitializeComponent();

            // 格式化饼状图标签字符串
            //PointLabel = chartPoint =>
            //    string.Format("{1:P}", chartPoint.Y, chartPoint.Participation);
            PointLabel = chartPoint =>
                         string.Format($"{Math.Floor(chartPoint.Y / 3600)}时{Math.Floor((chartPoint.Y - (Math.Floor(chartPoint.Y / 3600) * 3600)) / 60)}分 {chartPoint.Participation:P}");

            //添加初始化饼状图数据
            for (int i = 0; i < MainWindow.TimeList.Length; i++)
            {
                BrushConverter brushconverter = new BrushConverter();
                // 添加数据
                UserPieChart.Add(new PieSeries
                {
                    Title      = MainWindow.TimeList[i % MainWindow.FaultList.Length],
                    Values     = new ChartValues <double>(),
                    DataLabels = true,
                    LabelPoint = PointLabel,
                    Fill       = (Brush)brushconverter.ConvertFromString(MainWindow.TimeColorList[i % MainWindow.TimeColorList.Length]),
                    FontSize   = 24,
                });
            }

            // 添加图表数据
            SetChartValue();

            // 设置页面主题颜色
            FontColor = MainWindow.WindowFontColor;
            BgColor   = MainWindow.WindowBgColor;

            DataContext = this;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 故障饼状图图表
        /// </summary>
        /// <param name="Type">小时/天/月</param>
        /// <param name="Position">标签显示位置</param>
        public BreakDownPieChart(string Type, string Position)
        {
            InitializeComponent();
            // 格式化饼状图标签字符串
            PointLabel = chartPoint =>
                         string.Format("{0}", chartPoint.Y, chartPoint.Participation);

            //添加初始化饼状图数据
            for (int i = 0; i < MainWindow.FaultList.Length; i++)
            {
                BrushConverter brushconverter = new BrushConverter();
                // 添加数据
                UserPieChart.Add(new PieSeries
                {
                    Title      = MainWindow.FaultList[i % MainWindow.FaultList.Length],
                    Values     = new ChartValues <double>(),
                    DataLabels = true,
                    LabelPoint = PointLabel,
                    Fill       = (Brush)brushconverter.ConvertFromString(MainWindow.ColorList[i % MainWindow.ColorList.Length])
                });
            }
            // 运行获取图表数据
            GetPieChartData(Type, Position);

            FontColor = MainWindow.WindowFontColor;

            this.DataContext = this;
        }