Esempio n. 1
0
        /// <summary>
        /// Calculate the values needed to properly display this <see cref="PieItem"/>.
        /// </summary>
        /// <param name="pane">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="maxDisplacement">maximum slice displacement</param>
        private static void CalculatePieChartParams(GraphPane pane, ref double maxDisplacement)
        {
            string lblStr = " ";

            //loop thru slices and get total value and maxDisplacement
            double pieTotalValue = 0;

            foreach (PieItem curve in pane.CurveList)
            {
                if (curve.IsPie)
                {
                    pieTotalValue += curve._pieValue;
                    if (curve.Displacement > maxDisplacement)
                    {
                        maxDisplacement = curve.Displacement;
                    }
                }
            }

            double nextStartAngle = 0;

            //now loop thru and calculate the various angle values
            foreach (PieItem curve in pane.CurveList)
            {
                lblStr           = curve._labelStr;
                curve.StartAngle = (float)nextStartAngle;
                curve.SweepAngle = (float)(360 * curve.Value / pieTotalValue);
                curve.MidAngle   = curve.StartAngle + curve.SweepAngle / 2;
                nextStartAngle   = curve._startAngle + curve._sweepAngle;
                PieItem.BuildLabelString(curve);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param>
 public PieItem(PieItem rhs) : base(rhs)
 {
     this.pieValue             = rhs.pieValue;
     this.fill                 = (Fill)rhs.fill.Clone();
     this.Border               = (Border)rhs.border.Clone();
     this.displacement         = rhs.displacement;
     this.labelDetail          = (TextItem)rhs.labelDetail.Clone();
     this.labelType            = rhs.labelType;
     this.valueDecimalDigits   = rhs.valueDecimalDigits;
     this.percentDecimalDigits = rhs.percentDecimalDigits;
 }
Esempio n. 3
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param>
 public PieItem(PieItem rhs)
     : base(rhs)
 {
     _pieValue             = rhs._pieValue;
     _fill                 = rhs._fill.Clone();
     this.Border           = rhs._border.Clone();
     _displacement         = rhs._displacement;
     _labelDetail          = rhs._labelDetail.Clone();
     _labelType            = rhs._labelType;
     _valueDecimalDigits   = rhs._valueDecimalDigits;
     _percentDecimalDigits = rhs._percentDecimalDigits;
 }
Esempio n. 4
0
        /// <summary>
        /// Build the string that will be displayed as the slice label as determined by
        /// <see cref="LabelType"/>.
        /// </summary>
        /// <param name="curve">reference to the <see cref="PieItem"/></param>
        private static void BuildLabelString(PieItem curve)
        {
            //set up label string formatting
            NumberFormatInfo labelFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            labelFormat.NumberDecimalDigits    = curve._valueDecimalDigits;
            labelFormat.PercentPositivePattern = 1;                                             //no space between number and % sign
            labelFormat.PercentDecimalDigits   = curve._percentDecimalDigits;

            switch (curve._labelType)
            {
            case PieLabelType.Value:
                curve._labelStr = curve._pieValue.ToString("F", labelFormat);
                break;

            case PieLabelType.Percent:
                curve._labelStr = (curve._sweepAngle / 360).ToString("P", labelFormat);
                break;

            case PieLabelType.Name_Value:
                curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString("F", labelFormat);
                break;

            case PieLabelType.Name_Percent:
                curve._labelStr = curve._label._text + ": " + (curve._sweepAngle / 360).ToString("P", labelFormat);
                break;

            case PieLabelType.Name_Value_Percent:
                curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString("F", labelFormat) +
                                  " (" + (curve._sweepAngle / 360).ToString("P", labelFormat) + ")";
                break;

            case PieLabelType.Name:
                curve._labelStr = curve._label._text;
                break;

            case PieLabelType.None:
            default:
                break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Calculate the <see cref="RectangleF"/> that will be used to define the bounding rectangle of
        /// the Pie.
        /// </summary>
        /// <remarks>This rectangle always lies inside of the <see cref="Chart.Rect"/>, and it is
        /// normally a square so that the pie itself is not oval-shaped.</remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="chartRect">The <see cref="RectangleF"/> (normally the <see cref="Chart.Rect"/>)
        /// that bounds this pie.</param>
        /// <returns></returns>
        public static RectangleF CalcPieRect(Graphics g, GraphPane pane, float scaleFactor, RectangleF chartRect)
        {
            //want to draw the largest pie possible within ChartRect
            //but want to leave  5% slack around the pie so labels will not overrun clip area
            //largest pie is limited by the smaller of ChartRect.height or ChartRect.width...
            //this rect (nonExplRect)has to be re-positioned so that it's in the center of ChartRect.
            //Where ChartRect is almost a square - low Aspect Ratio -, need to contract pieRect so that there's some
            //room for labels, if they're visible.
            double     maxDisplacement = 0;
            RectangleF tempRect;               //= new RectangleF(0,0,0,0);

            RectangleF nonExplRect = chartRect;

            if (pane.CurveList.IsPieOnly)
            {
                if (nonExplRect.Width < nonExplRect.Height)
                {
                    //create slack rect
                    nonExplRect.Inflate(-(float)0.05F * nonExplRect.Height, -(float)0.05F * nonExplRect.Width);
                    //get the difference between dimensions
                    float delta = (nonExplRect.Height - nonExplRect.Width) / 2;
                    //make a square	so we end up with circular pie
                    nonExplRect.Height = nonExplRect.Width;
                    //keep the center point  the same
                    nonExplRect.Y += delta;
                }
                else
                {
                    nonExplRect.Inflate(-(float)0.05F * nonExplRect.Height, -(float)0.05F * nonExplRect.Width);
                    float delta = (nonExplRect.Width - nonExplRect.Height) / 2;
                    nonExplRect.Width = nonExplRect.Height;
                    nonExplRect.X    += delta;
                }
                //check aspect ratio
                double aspectRatio = chartRect.Width / chartRect.Height;
                //make an adjustment in rect size,as aspect ratio varies
                if (aspectRatio < 1.5)
                {
                    nonExplRect.Inflate(-(float)(.1 * (1.5 / aspectRatio) * nonExplRect.Width),
                                        -(float)(.1 * (1.5 / aspectRatio) * nonExplRect.Width));
                }

                //modify the rect to determine if any of the labels need to be wrapped....
                //first see if there's any exploded slices and if so, what's the max displacement...
                //also, might as well get all the display params we can
                PieItem.CalculatePieChartParams(pane, ref maxDisplacement);

                if (maxDisplacement != 0)                                        //need new rectangle if any slice exploded
                {
                    CalcNewBaseRect(maxDisplacement, ref nonExplRect);
                }

                foreach (PieItem slice in pane.CurveList)
                {
                    slice._boundingRectangle = nonExplRect;
                    //if exploded, need to re-calculate rectangle for slice
                    if (slice.Displacement != 0)
                    {
                        tempRect = nonExplRect;
                        slice.CalcExplodedRect(ref tempRect);
                        slice._boundingRectangle = tempRect;
                    }
                    //now get all the other slice specific drawing details, including need for wrapping label
                    slice.DesignLabel(g, pane, slice._boundingRectangle, scaleFactor);
                }
            }
            return(nonExplRect);
        }
 /// <summary>
 ///Creates all the <see cref="PieItem"/>s for a single Pie Chart. 
 /// </summary>
 /// <param name="values">double array containing all <see cref="PieItem.Value"/>s
 /// for a single PieChart.
 /// </param>
 /// <param name="labels"> string array containing all <see cref="CurveItem.Label"/>s
 /// for a single PieChart.
 /// </param>
 /// <returns>an array containing references to all <see cref="PieItem"/>s comprising
 /// the Pie Chart.</returns>
 public PieItem[] AddPieSlices( double[] values, string[] labels )
 {
     PieItem[] slices = new PieItem[values.Length];
     for ( int x = 0; x < values.Length; x++ )
     {
         slices[x] = new PieItem( values[x], labels[x] );
         this.CurveList.Add( slices[x] );
     }
     return slices;
 }
        /// <summary>
        /// Add a <see cref="PieItem"/> to the display, providing a gradient fill for the pie color.
        /// </summary>
        /// <param name="value">The value associated with this <see cref="PieItem"/> instance.</param>
        /// <param name="color1">The starting display color for the gradient <see cref="Fill"/> for this
        /// <see cref="PieItem"/> instance.</param>
        /// <param name="color2">The ending display color for the gradient <see cref="Fill"/> for this
        /// <see cref="PieItem"/> instance.</param>
        /// <param name="fillAngle">The angle for the gradient <see cref="Fill"/>.</param>
        /// <param name="displacement">The amount this <see cref="PieItem"/>  instance will be 
        /// displaced from the center point.</param>
        /// <param name="label">Text label for this <see cref="PieItem"/> instance.</param>
        public PieItem AddPieSlice( double value, Color color1, Color color2, float fillAngle,
						double displacement, string label )
        {
            PieItem slice = new PieItem( value, color1, color2, fillAngle, displacement, label );
            this.CurveList.Add( slice );
            return slice;
        }
Esempio n. 8
0
        /// <summary>
        /// Build the string that will be displayed as the slice label as determined by 
        /// <see cref="LabelType"/>.
        /// </summary>
        /// <param name="curve">reference to the <see cref="PieItem"/></param>
        private static void BuildLabelString( PieItem curve )
        {
            //set up label string formatting
            NumberFormatInfo labelFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone();

            labelFormat.NumberDecimalDigits = curve._valueDecimalDigits;
            labelFormat.PercentPositivePattern = 1;					//no space between number and % sign
            labelFormat.PercentDecimalDigits = curve._percentDecimalDigits;

            switch ( curve._labelType )
            {
                case PieLabelType.Value:
                    curve._labelStr = curve._pieValue.ToString( "F", labelFormat );
                    break;
                case PieLabelType.Percent:
                    curve._labelStr = ( curve._sweepAngle / 360 ).ToString( "P", labelFormat );
                    break;
                case PieLabelType.Name_Value:
                    curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString( "F", labelFormat );
                    break;
                case PieLabelType.Name_Percent:
                    curve._labelStr = curve._label._text + ": " + ( curve._sweepAngle / 360 ).ToString( "P", labelFormat );
                    break;
                case PieLabelType.Name_Value_Percent:
                    curve._labelStr = curve._label._text + ": " + curve._pieValue.ToString( "F", labelFormat ) +
                        " (" + ( curve._sweepAngle / 360 ).ToString( "P", labelFormat ) + ")";
                    break;
                case PieLabelType.Name:
                    curve._labelStr = curve._label._text;
                    break;
                case PieLabelType.None:
                default:
                    break;
            }
        }
Esempio n. 9
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param>
 public PieItem( PieItem rhs )
     : base(rhs)
 {
     _pieValue = rhs._pieValue;
     _fill = rhs._fill.Clone();
     this.Border = rhs._border.Clone();
     _displacement = rhs._displacement;
     _labelDetail = rhs._labelDetail.Clone();
     _labelType = rhs._labelType;
     _valueDecimalDigits = rhs._valueDecimalDigits;
     _percentDecimalDigits = rhs._percentDecimalDigits;
 }
Esempio n. 10
0
		public Bitmap Pie_BackInfoStat(string getGrade,string getClass,DateTime getDate,PanelControl pControl)
		{
			using ( RealtimeInfoDataAccess realTimeInfoDataAccess = new RealtimeInfoDataAccess() )
			{
				try
				{
					int getHasGone = 0;
					int getHasnotGone = 0;
					int getStuNumbers = 0;
					
					realTimeInfoDataAccess.GetRealtimeBackInfo_Graphic(getGrade,getClass,getDate,ref getHasGone,ref getHasnotGone,ref getStuNumbers);

					double hasGonePer = (double)getHasGone/(double)getStuNumbers;
					double hasnotGonePer = (double)getHasnotGone/(double)getStuNumbers;

					zedGraph_RealTimeInfoStatStudent = new ZedGraphControl();
					pControl.Controls.Clear();
					pControl.Controls.Add(zedGraph_RealTimeInfoStatStudent);
					zedGraph_RealTimeInfoStatStudent.Dock = DockStyle.Fill;

					GraphPane myPane = zedGraph_RealTimeInfoStatStudent.GraphPane;

					if ( getGrade.Equals("") )
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ "全年级晚接信息统计图\n"+"统计日期: " + getDate.ToString("yyyy-MM-dd");

					else if ( getClass.Equals("") )
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ new StuInfoDataAccess().GetGradeList("",getGrade).Tables[0].Rows[0][1].ToString()
							+ "晚接信息统计图\n"+"统计日期: " + getDate.ToString("yyyy-MM-dd");
					else
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ new RealtimeInfoDataAccess().setClassList("",getClass,getGrade).Tables[0].Rows[0][1].ToString()
							+ "晚接信息统计图\n"+"统计日期: " + getDate.ToString("yyyy-MM-dd");

					double[] statusVal = { hasGonePer, hasnotGonePer };
					string[] statusLabel = { "已接走", "未接走"};

					myPane.PaneFill = new Fill( Color.Cornsilk );
					myPane.AxisFill = new Fill( Color.Cornsilk );
					myPane.Legend.Position = LegendPos.Right ;
					myPane.Legend.FontSpec.Size = 12;

					PieItem [] slices = new PieItem[statusVal.Length] ;
					slices = myPane.AddPieSlices ( statusVal, statusLabel );
					
					((PieItem)slices[0]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[0]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[1]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).Displacement = .1 ;

					BoxItem box = new BoxItem( new RectangleF( 0F, 0F, 1F, 1F ),
						Color.Empty, Color.PeachPuff );
					box.Location.CoordinateFrame = CoordType.AxisFraction;
					box.Border.IsVisible = false;
					box.Location.AlignH = AlignH.Left;
					box.Location.AlignV = AlignV.Top;
					box.ZOrder = ZOrder.E_BehindAxis;

					myPane.GraphItemList.Add( box );

					zedGraph_RealTimeInfoStatStudent.IsShowContextMenu = false;
					zedGraph_RealTimeInfoStatStudent.IsEnableZoom = false;
					zedGraph_RealTimeInfoStatStudent.AxisChange();

					return myPane.Image;
				}
				catch(Exception e)
				{
					Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
					return null;
				}
			}
		}
		public Bitmap Pie_InfoStat(string getGrade,string getClass,GroupControl gControl)
		{
			using ( StudentAttendCalcDataAccess stuAttCalcDataAccess = new StudentAttendCalcDataAccess() )
			{
				try
				{
					stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"健康");
					double healthPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100;
					stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"服药");
					double illPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100;
					stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"观察");
					double watchPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100;
//					stuAttCalcDataAccess.DoAttendCalcForClass(getGrade,getClass,BegDate.ToString("yyyy-MM-dd"),EndDate.ToString("yyyy-MM-dd"),"缺席");
//					double absPer = (double)stuAttCalcDataAccess.StateAmount/((double)stuAttCalcDataAccess.StuAmount*SetAttendDays())*100;
					double absPer = 100-healthPer-illPer-watchPer;

//					Graphics gra = gControl.CreateGraphics();
//					GraphPane myPane = new GraphPane( new Rectangle( 0, 0, gControl.Width, gControl.Height ),
//						"11", "11", "11" );
					zedGraph_StuPiePrint = new ZedGraphControl();
					gControl.Controls.Clear();
					gControl.Controls.Add(zedGraph_StuPiePrint);
					zedGraph_StuPiePrint.Dock = DockStyle.Fill;
					
					GraphPane myPane = zedGraph_StuPiePrint.GraphPane;

					if ( getGrade.Equals("") )
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ "全年级晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 "
							+ EndDate.ToString("yyyy.MM.dd");
					else if ( getClass.Equals("") )
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ new StuInfoDataAccess().GetGradeList("",getGrade).Tables[0].Rows[0][1].ToString()
							+ "晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 "
							+ EndDate.ToString("yyyy.MM.dd");
					else
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ new RealtimeInfoDataAccess().setClassList("",getClass,getGrade).Tables[0].Rows[0][1].ToString()
							+ "晨检信息统计图\n"+"统计日期: " + BegDate.ToString("yyyy.MM.dd") + " 至 "
							+ EndDate.ToString("yyyy.MM.dd");

					double[] statusVal = { healthPer, watchPer, absPer, illPer };
					string[] statusLabel = { "健康", "观察", "缺席", "服药"  };

					myPane.PaneFill = new Fill( Color.Cornsilk );
					myPane.AxisFill = new Fill( Color.Cornsilk );
					myPane.Legend.Position = LegendPos.Right ;
					myPane.Legend.FontSpec.Size = 14;

					PieItem [] slices = new PieItem[statusVal.Length] ;
					slices = myPane.AddPieSlices ( statusVal, statusLabel ) ;
					
					((PieItem)slices[0]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[0]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[1]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[2]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[2]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[3]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[3]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).Displacement = .2 ;
					((PieItem)slices[2]).Displacement = .2 ;

					BoxItem box = new BoxItem( new RectangleF( 0F, 0F, 1F, 1F ),
						Color.Empty, Color.PeachPuff );
					box.Location.CoordinateFrame = CoordType.AxisFraction;
					box.Border.IsVisible = false;
					box.Location.AlignH = AlignH.Left;
					box.Location.AlignV = AlignV.Top;
					box.ZOrder = ZOrder.E_BehindAxis;

					myPane.GraphItemList.Add( box );
//					myPane.AxisChange(gra);
//					myPane.Draw(gra);

//					myPane.ReSize(gra,new RectangleF(150, 300, 800,600));

					zedGraph_StuPiePrint.IsShowContextMenu = false;
					zedGraph_StuPiePrint.IsEnableZoom = false;
					zedGraph_StuPiePrint.AxisChange();

					return myPane.Image;
				}
				catch(Exception e)
				{
					Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
					return null;
				}
			}
		}
Esempio n. 12
0
 /// <summary>
 /// Add a <see cref="PieItem"/> to the display.
 /// </summary>
 /// <param name="value">The value associated with this <see cref="PieItem"/>item.</param>
 /// <param name="color">The display color for this <see cref="PieItem"/>item.</param>
 /// <param name="displacement">The amount this <see cref="PieItem"/>item will be 
 /// displaced from the center of the <see cref="PieItem"/>.</param>
 /// <param name="label">Text label for this <see cref="PieItem"/></param>
 /// <returns>a reference to the <see cref="PieItem"/> constructed</returns>
 public PieItem AddPieSlice( double value, Color color, double displacement, string label )
 {
     PieItem slice = new PieItem( value, color, displacement, label );
     CurveList.Add( slice );
     return slice;
 }
Esempio n. 13
0
        private void GenerateDistributionGraphAndTable()
        {
            #region Write graph
            GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 512, 384), "", "", "");
            graphPane.CurveList.Clear();
            graphPane.Legend.Position = LegendPos.Right;
            graphPane.Legend.IsVisible = false;

            ArrayList groups = statsEngine.GetClusteredDataSet();
            PieItem []segments = new PieItem[groups.Count];
            for (int idx = 0; idx < groups.Count; idx++)
            {
                ArrayList items = groups[idx] as ArrayList;
                string start = string.Format("{0:f2}", items[0]);
                string end = string.Format("{0:f2}", items[items.Count-1]);
                string label =  start + " - " + end;
                int colorseg = 255 - ((255 / groups.Count) * (idx+1));
                segments[idx] = graphPane.AddPieSlice(items.Count, Color.FromArgb(colorseg, colorseg, colorseg), 0.0, label);
                segments[idx].LabelDetail.FontSpec.Border.IsVisible = false;
                segments[idx].LabelType = PieLabelType.Name_Value_Percent;
            }

            SaveGraphImage(graphPane, reportPath + @"\distribution.png");
            #endregion

            #region Write table
            // write table header
            distTable = new StringBuilder();
            distTable.Append("<table><thead><tr>\n");
            distTable.Append("<th width=\"20%\">Group</th>\n");
            distTable.Append("<th width=\"20%\">Range in milliseconds</th>\n");
            distTable.Append("<th width=\"20%\">Total tests</th>\n");
            distTable.Append("<th width=\"20%\">Percent of total</th>\n");
            distTable.Append("</tr></thead><tbody>\n");

            int totalEntries = 0;
            for (int i=0; i<groups.Count; i++)
            {
                ArrayList items = groups[i] as ArrayList;
                totalEntries += items.Count;
            }

            bool oddline = true;
            for (int i=0; i<groups.Count; i++)
            {
                ArrayList items = groups[i] as ArrayList;
                string start = string.Format("{0:f2}", items[0]);
                string end = string.Format("{0:f2}", items[items.Count-1]);
                string label =  start + " - " + end;

                if (oddline == true)
                    distTable.Append("<tr class=\"odd\">\n");
                else
                    distTable.Append("<tr class=\"even\">\n");

                distTable.Append("<td class=\"s\">");
                distTable.AppendFormat("{0}", i+1);
                distTable.Append("</td>\n");

                distTable.Append("<td class=\"s\">");
                distTable.Append(label);
                distTable.Append("</td>\n");

                distTable.Append("<td class=\"s\">");
                distTable.AppendFormat("{0}", items.Count);
                distTable.Append("</td>\n");

                double percent = 100 - (((double)(totalEntries - items.Count) / (double)totalEntries) * 100.0);
                distTable.Append("<td class=\"s\">");
                distTable.AppendFormat("{0:f2}", percent);
                distTable.Append("</td>\n");

                oddline = !oddline;
            }
            distTable.Append("</tr></table>\n");
            #endregion
        }
Esempio n. 14
0
        public PieChartDemo()
            : base("A demo showing some pie chart features of ZedGraph",
										"Pie Chart Demo", DemoType.Pie)
        {
            GraphPane myPane = base.GraphPane;

            // Set the pane title
            myPane.Title.Text = "2004 ZedGraph Sales by Region\n ($M)";

            // Enter some data values
            double [] values =   { 15, 15, 40, 20 } ;
            double [] values2 =   { 250, 50, 400, 50 } ;
            Color [] colors = { Color.Red, Color.Blue, Color.Green, Color.Yellow } ;
            double [] displacement = {	.0,.0,.0,.0 } ;
            string [] labels = { "Europe", "Pac Rim", "South America", "Africa" } ;

            // Fill the pane and axis background with solid color
            myPane.Fill = new Fill( Color.Cornsilk );
            myPane.Chart.Fill = new Fill( Color.Cornsilk );
            myPane.Legend.Position = LegendPos.Right ;

            // Create some pie slices
            PieItem segment1 = myPane.AddPieSlice ( 20, Color.Navy, .20, "North") ;
            PieItem segment2 = myPane.AddPieSlice ( 40, Color.Salmon, 0, "South") ;
            PieItem segment3 = myPane.AddPieSlice ( 30, Color.Yellow,.0, "East") ;
            PieItem segment4 = myPane.AddPieSlice ( 10.21, Color.LimeGreen, 0, "West") ;
            PieItem segment5 = myPane.AddPieSlice ( 10.5, Color.Aquamarine, .3, "Canada") ;

            // Add some more slices as an array
            PieItem [] slices = new PieItem[values2.Length] ;
            slices = myPane.AddPieSlices ( values2, labels ) ;

            // Modify the slice label types
            ((PieItem)slices[0]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[1]).LabelType = PieLabelType.Name_Value_Percent ;
            ((PieItem)slices[2]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[3]).LabelType = PieLabelType.Name_Value ;
            ((PieItem)slices[1]).Displacement = .2 ;
            segment1.LabelType = PieLabelType.Name_Percent ;
            segment2.LabelType = PieLabelType.Name_Value ;
            segment3.LabelType = PieLabelType.Percent ;
            segment4.LabelType = PieLabelType.Value ;
            segment5.LabelType = PieLabelType.Name_Value ;
            segment2.LabelDetail.FontSpec.FontColor = Color.Red ;

            // Sum up the values
            CurveList curves = myPane.CurveList ;
            double total = 0 ;
            for ( int x = 0 ; x <  curves.Count ; x++ )
                total += ((PieItem)curves[x]).Value ;

            // Add a text item to highlight total sales
            TextObj text = new TextObj("Total 2004 Sales - " + "$" + total.ToString () + "M", 0.85F, 0.80F,CoordType.PaneFraction );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Border.IsVisible = false ;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.FontSpec.StringAlignment = StringAlignment.Center ;
            myPane.GraphObjList.Add( text );

            // Add a colored background behind the pie
            BoxObj box = new BoxObj( 0, 0, 1, 1, Color.Empty, Color.PeachPuff );
            box.Location.CoordinateFrame = CoordType.ChartFraction;
            box.Border.IsVisible = false;
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            box.ZOrder = ZOrder.E_BehindCurves;
            myPane.GraphObjList.Add( box );

            base.ZedGraphControl.AxisChange();
        }
		public Bitmap RealtimeBackInfoStat_TeacherGraphPrint(string getDept,PanelControl pControl)
		{
			using ( RealtimeInfo_TeacherDataAccess realTimeInfo_TeacherDataAccess = new RealtimeInfo_TeacherDataAccess() )
			{
				try
				{
					DataSet dsDutyID = realTimeInfo_TeacherDataAccess.GetDutyID(DateTime.Now.ToString("HH:mm:ss"));
					int teaAttOnTimeNumbersInDuty = 0;
					int teaAttNotOnTimeNumbersInDuty = 0;
					int teaLeaveOnTimeNumbersInDuty = 0;
					int teaLeaveNotOnTimeNumbersInDuty = 0;
					int teaShouldLeaveInDuty = 0;

					if ( dsDutyID.Tables[0].Rows.Count > 0 )
					{
						foreach ( DataRow dutyRow in dsDutyID.Tables[0].Rows )
						{
							//teaAttNumbersInDuty += realTimeInfo_TeacherDataAccess.GetTeaNumbers(DateTime.Now.DayOfWeek.ToString(),dutyRow[0].ToString(),getDept);
							realTimeInfo_TeacherDataAccess.GetTeaWorkingNumbers(dutyRow[0].ToString(),ref teaAttOnTimeNumbersInDuty,ref teaAttNotOnTimeNumbersInDuty,getDept,DateTime.Now.Date);
							realTimeInfo_TeacherDataAccess.GetTeaLeaveNumbers(dutyRow[0].ToString(),ref teaLeaveOnTimeNumbersInDuty,ref teaLeaveNotOnTimeNumbersInDuty,getDept,DateTime.Now.Date);
						}
					}

					int noDutyTotal = 0;
					int noDutyAttend = 0;
					int noDutyLeave = 0;

					realTimeInfo_TeacherDataAccess.GetTeacherRealTimeInfoWithNoDuty(getDept,DateTime.Now.DayOfWeek.ToString(), ref noDutyTotal, ref noDutyAttend,ref noDutyLeave);

					teaLeaveOnTimeNumbersInDuty += noDutyLeave;
					teaShouldLeaveInDuty = teaAttOnTimeNumbersInDuty + teaAttNotOnTimeNumbersInDuty + noDutyAttend;

					
					double onTimePer = (double)teaLeaveOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty;
					double notOnTimePer = (double)teaLeaveNotOnTimeNumbersInDuty/(double)teaShouldLeaveInDuty;
					double remainPer = 1-(((double)teaLeaveOnTimeNumbersInDuty+(double)teaLeaveNotOnTimeNumbersInDuty)/(double)teaShouldLeaveInDuty);

					zedGraph_RealtimeMorningInfoStatTeacher = new ZedGraphControl();
					pControl.Controls.Clear();
					pControl.Controls.Add(zedGraph_RealtimeMorningInfoStatTeacher);
					zedGraph_RealtimeMorningInfoStatTeacher.Dock = DockStyle.Fill;

					GraphPane myPane = zedGraph_RealtimeMorningInfoStatTeacher.GraphPane;

					if ( getDept.Equals("") )
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ "全体教职工下班情况实时统计图\n"+"统计日期: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
					else
						myPane.Title = new GardenInfoDataAccess().GetGardenInfo().Tables[0].Rows[0][1].ToString()
							+ getDept+ "部教师下班情况实时统计图\n"+"统计日期: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

					double[] statusVal = { onTimePer, notOnTimePer,remainPer };
					string[] statusLabel = { "离开", "早退" , "剩余" };

					myPane.PaneFill = new Fill( Color.Cornsilk );
					myPane.AxisFill = new Fill( Color.Cornsilk );
					myPane.Legend.Position = LegendPos.Right ;
					myPane.Legend.FontSpec.Size = 12;

					PieItem [] slices = new PieItem[statusVal.Length] ;
					slices = myPane.AddPieSlices ( statusVal, statusLabel );
					
					((PieItem)slices[0]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[0]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[1]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[2]).LabelType = PieLabelType.Percent ;
					((PieItem)slices[2]).LabelDetail.FontSpec.Size = 14;
					((PieItem)slices[1]).Displacement = .1 ;

					BoxItem box = new BoxItem( new RectangleF( 0F, 0F, 1F, 1F ),
						Color.Empty, Color.PeachPuff );
					box.Location.CoordinateFrame = CoordType.AxisFraction;
					box.Border.IsVisible = false;
					box.Location.AlignH = AlignH.Left;
					box.Location.AlignV = AlignV.Top;
					box.ZOrder = ZOrder.E_BehindAxis;

					myPane.GraphItemList.Add( box );

					zedGraph_RealtimeMorningInfoStatTeacher.IsShowContextMenu = false;
					zedGraph_RealtimeMorningInfoStatTeacher.IsEnableZoom = false;
					zedGraph_RealtimeMorningInfoStatTeacher.AxisChange();

					return myPane.Image;
				}
				catch(Exception e)
				{
					Util.WriteLog(e.Message,Util.EXCEPTION_LOG_TITLE);
					return null;
				}
			}
		}