zoukankan      html  css  js  c++  java
  • dev ChartControl 备忘

    一个chartControl 里包括以个diagram(图表)

    diagram里可以设置 x-axis与y-axis ,另外还可以设置SecondaryXAxis与SecondaryYAxis,在Series属性里可以选择使用Secondary Axis

    一个diagram里包括多少个Series,一个Series表示一组(x,y)取值集合

    一个diagram里可以添加多个Panel, 二Series可以设置呈现在那个panel里

    Series的主要属性是DataSource,指定 ArgumentDataMember(X-Axis),ValuesDataMembers(Y-Axis)

    1.自定义标注显示内,首相要设置series.LablesVisibility=True

                chartControl1.CustomDrawSeriesPoint += (s, e) =>
                {
                    if (e.Series == chartControl1.Series["Real"])
                    {
                        var it = e.SeriesPoint;
                        var obj = it.Tag as QualifiedInfo; //Tag里是当前点的记录
                        e.LabelText = string.Format("{0}|{2}|{1}", obj.Disqualification, obj.Amount,obj.DisqualificationWithoutOtherDuty);
                    }
                };
    View Code

    参考代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Linq;
    using System.Windows.Forms;
    using DevExpress.XtraEditors;
    using WinDetectionClockAdmin.Model;
    using DevExpress.XtraCharts;
    using System.Threading;
    using DetectionClock.EFModel;
    namespace WinDetectionClockAdmin
    {
        public partial class frmPercentOfPassCharting : DevExpress.XtraEditors.XtraForm
        {
            private ChartControl CurCharControl { get; set; }
            public SynchronizationContext SyncContext { get; set; }
            public frmPercentOfPassCharting()
            {
                InitializeComponent();
                SyncContext = SynchronizationContext.Current;
    
                #region Tab
                layoutControlGroup3.Shown += (s, e) =>
                {
                    CurCharControl = chartControl1;
                };
                layoutControlGroup4.Shown += (s, e) => { CurCharControl = chartControl2; };
                layoutControlGroup5.Shown += (s, e) => { CurCharControl = chartControl3; };
                layoutControlGroup6.Shown += (s, e) => { CurCharControl = chartControl4; };
                #endregion
                #region 自自定义Lbl显示
                chartControl1.CustomDrawSeriesPoint += (s, e) =>
                {
                    if (e.Series == chartControl1.Series["Real"])
                    {
                        var it = e.SeriesPoint;
                        var obj = it.Tag as QualifiedInfo;
                        e.LabelText = string.Format("{0}|{2}|{1}", obj.Disqualification, obj.Amount,obj.DisqualificationWithoutOtherDuty);
                    }
                };
                #endregion
    
                #region
                bDate.EditValue = DateTime.Now.Date.AddDays(1 - DateTime.Now.Day);
                eDate.EditValue = DateTime.Now.Date.Add(new TimeSpan(23, 59, 59));
                ThreadPool.QueueUserWorkItem(o =>
                {
                    using (var ctx = DBCtx.GetCtx())
                    {
                        var sql = DRecAnalyze.LoadSql("sql04.txt");
                        var mInfoList = ctx.ExecuteStoreQuery<MInfo>(sql).ToList();
                        var batnos = ctx.FO_Task.GroupBy(ent => ent.Batno).Select(ent => ent.Key).Where(ent => ent != null).ToList();
                        
                        var empList = ctx.FO_TaskEmps.ToList();
    
                        SyncContext.Post(s =>
                        {
                            team.Properties.DataSource = empList;
                            mno.Properties.DataSource = mInfoList;
                            batno.Properties.Items.AddRange(batnos.ToArray());
                        }, null);
    
                    }
                }, null);
    
                #endregion
            }
    
            private void btnLoad_Click(object sender, EventArgs e)
            {
                try
                {
                    var sql = DRecAnalyze.LoadSql("sql05.txt");
                    if (bDate.EditValue == null) throw new Exception("请指定开始时间");
                    if (eDate.EditValue == null) throw new Exception("请指定结束时间");
                    var bTime=(DateTime)bDate.EditValue;
                    var eTime=(DateTime)eDate.EditValue;
    
                    var dCondition = string.Format(" And d.AddTime>='{0}' And d.AddTime<='{1}' ",
                        bTime.Date.ToString("yyyy-MM-dd 00:00:00"),
                        eTime.Date.ToString("yyyy-MM-dd 23:59:59")
                        );
    
                    var tCondition = "";
                    if (mno.EditValue != null )
                    {
                        if (!string.IsNullOrWhiteSpace(mno.ToString()))
                        {
                            tCondition += string.Format(" And t.MNo='{0}'", mno.EditValue.ToString());
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(batno.Text))
                    {
                        tCondition += string.Format(" And t.BatNo='{0}'", batno.Text);
                    }
                    if (team.EditValue != null)
                    {
                        if(!string.IsNullOrWhiteSpace(team.EditValue.ToString()))
                        {
                            dCondition += String.Format(" And d.TaskEmpsId={0}", team.EditValue);
                        }
                    }
                    var exeSql= sql.Replace("$DCondition", dCondition).Replace("$TCondition", tCondition);
    
    
                    #region AsyncAction
                    Action act = () =>
                    {
                        var data = DRecAnalyze.LoadData(exeSql);
                        var list = DRecAnalyze.AnalyzePercentOfPass(data);
    
    
                        //所有不良项
                        var symptomList = DRecAnalyze.AnalyzeSymptom(data);
    
                        //生产部不良项
                        var assembleSymptomList = DRecAnalyze.AnalyzeAssembleSymptom(data);
    
                        //主要不良项
                        var mainSymptom = DRecAnalyze.AnalyzeMainSymptom(data);
    
                        SyncContext.Post(o =>
                        {
                            var diagram = chartControl1.Diagram as XYDiagram;
                            if (list.Count > 0)
                            {
                                diagram.AxisY.Range.MaxValue = Math.Floor(list.Max(ent => ent.Disqualification) * 1.6);
                            }
                            chartControl1.Series["Aim"].DataSource = list;
                            chartControl1.Series["Real"].DataSource = list;
                            chartControl1.Series["Disqualification"].DataSource = list;
    
                            chartControl2.Series["Symptom"].DataSource = symptomList;
    
                            chartControl3.Series["Symptom"].DataSource = assembleSymptomList;
    
                            chartControl4.Series[0].DataSource = mainSymptom;
                            chartControl4.Series[1].DataSource = mainSymptom;
                            chartControl4.Series[2].DataSource = mainSymptom;
                        }, null);
                    };
                    #endregion
                    this.AsyncInvoke(act);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
    
            
                    
    
            }
    
            private void btnExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
            {
                SaveFileDialog fileDialog = new SaveFileDialog();
                fileDialog.Filter = "Excel文件|*.xls";
                fileDialog.FileName = this.Text + DateTime.Now.ToString("yyMMddHHmm");
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    CurCharControl.ExportToXls(fileDialog.FileName);
                    XtraMessageBox.Show("操作成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
    }
    View Code
  • 相关阅读:
    Atitti 图像处理 图像混合 图像叠加 blend 原理与实现
    Atitit Gaussian Blur 高斯模糊 的原理and实现and 用途
    Atitit 图像处理 灰度图片 灰度化的原理与实现
    Atitit (Sketch Filter)素描滤镜的实现  图像处理  attilax总结
    Atitit 实现java的linq 以及与stream api的比较
    Atitit attilax在自然语言处理领域的成果
    Atitit 图像处理 常用8大滤镜效果 Jhlabs 图像处理类库 java常用图像处理类库
    Atitit 图像处理--图像分类 模式识别 肤色检测识别原理 与attilax的实践总结
    Atitit apache 和guava的反射工具
    atitit。企业的价值观 员工第一 vs 客户第一.docx
  • 原文地址:https://www.cnblogs.com/wdfrog/p/4123113.html
Copyright © 2011-2022 走看看