using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Text; using Mesnac.Controls.Base; using System.Drawing; using Steema.TeeChart.Styles; using Steema.TeeChart; using System.Windows.Forms; namespace Mesnac.Controls.Default { [ToolboxBitmap(typeof(TChart), "Images.TChart.bmp")]//暂用曲线图片!!! public partial class MCTeeChartPie : Steema.TeeChart.TChart,IBaseControl { #region 字段定义 private bool _isEventValid = true; //保存事件有效性 private Dictionary _data = null; //称量数据 #endregion #region 构造方法 public MCTeeChartPie() { InitializeComponent(); this.InitMethod(); } public MCTeeChartPie(IContainer container) { container.Add(this); InitializeComponent(); this.InitMethod(); } #endregion #region 属性定义 public Dictionary DataValue { get { return _data; } set { _data = value; } } #endregion #region 方法定义 /// /// 初始化方法 /// public void InitMethod() { this.Series.Clear(); this.Chart.Series.Add(new Steema.TeeChart.Styles.Pie());//饼图现实 this.Chart.Header.Text = ""; this.Chart.Panel.Shadow.Visible = false; this.Chart.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None; this.Chart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None; //this.Chart.Axes.Bottom.Title.Text = "故障原因"; //设置X轴标题 //this.Chart.Axes.Left.Title.Text = "故障占比";//设置Y轴标题 //this.Chart.Series.Add(new Steema.TeeChart.Styles.Pie()); //this.Chart.Series.SeriesMarks.Visible = true; this.Legend.Alignment = LegendAlignments.Right; this.Legend.Visible = true; this.Chart.Legend.Shadow.Visible = false; this.Chart.Legend.Visible = true; setData(); } public void setData() { if (DataValue != null) { foreach (KeyValuePair dv in DataValue) { this.Chart.Series[0].Add(Convert.ToDouble(dv.Value), dv.Key.ToString()); this.Chart.Series[0].Marks.Style = MarksStyles.PercentTotal; } //for (int i = 0; i < DataValue.Count; i++) //{ // this.Chart.Series[i].Title = DataValue.Keys.ElementAt(i).ToString(); //} //for (int i = 0; i < DataValue.Count; i++) //{ // this.Chart.Series[i].Add(Convert.ToDouble(DataValue[DataValue.Keys.ElementAt(i)]), DataValue.Keys.ElementAt(i).ToString()); // this.Chart.Series[i].Marks.Style = MarksStyles.PercentTotal; // this.Chart.Series[i].Title = DataValue.Keys.ElementAt(i).ToString(); //} } } #endregion #region 接口成员实现 public string MCKey { get; set; } public object MCValue { get; set; } public bool IsDbControl { get; set; } public IBaseControl MCRoot { get; set; } public string MCDataSourceID { get; set; } public MCDataSource MCDataSource { get; set; } public string InitDataSource { get; set; } public string ActionDataSource { get; set; } public object BindDataSource { get; set; } public DbOptionTypes DbOptionType { get; set; } public bool MCVisible { get; set; } public bool MCEnabled { get; set; } public bool IsValid { get; set; } public bool IsEventValid { get { return this._isEventValid; } set { this._isEventValid = value; } } #endregion } }