/// <summary> /// Default Constructor /// </summary> public ZeeGraphControl() { _dragPane = null; InitializeComponent(); // Use double-buffering for flicker-free updating: SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); _resourceManager = new ResourceManager("ZeeGraph.ZeeGraphLocale", Assembly.GetExecutingAssembly()); Rectangle rect = new Rectangle(0, 0, Size.Width, Size.Height); _masterPane = new MasterPane("", rect); _masterPane.Margin.All = 0; _masterPane.Title.IsVisible = false; string titleStr = _resourceManager.GetString("title_def"); string xStr = _resourceManager.GetString("x_title_def"); string yStr = _resourceManager.GetString("y_title_def"); GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr); using (Graphics g = CreateGraphics()) { graphPane.AxisChange(g); //g.Dispose(); } _masterPane.Add(graphPane); hScrollBar1.Minimum = 0; hScrollBar1.Maximum = 100; hScrollBar1.Value = 0; vScrollBar1.Minimum = 0; vScrollBar1.Maximum = 100; vScrollBar1.Value = 0; _xScrollRange = new ScrollRange(true); _yScrollRangeList = new ScrollRangeList(); _y2ScrollRangeList = new ScrollRangeList(); _yScrollRangeList.Add(new ScrollRange(true)); _y2ScrollRangeList.Add(new ScrollRange(false)); _zoomState = null; _zoomStateStack = new ZoomStateStack(); }
/// <summary> /// Restore the states of the GraphPanes to a previously saved condition (via /// <see cref="ZoomStateSave" />. This is essentially an "undo" for live /// pan and scroll actions. Restores a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> private void ZoomStateRestore(GraphPane primaryPane) { if (_isSynchronizeXAxes || _isSynchronizeYAxes) { for (int i = 0; i < _masterPane._paneList.Count; i++) { if (i < _zoomStateStack.Count) _zoomStateStack[i].ApplyState(_masterPane._paneList[i]); } } else if (_zoomState != null) _zoomState.ApplyState(primaryPane); ZoomStateClear(); }
/// <summary> /// Zoom a specified pane in or out according to the specified zoom fraction. /// </summary> /// <remarks> /// The zoom will occur on the <see cref="XAxis" />, <see cref="YAxis" />, and /// <see cref="Y2Axis" /> only if the corresponding flag, <see cref="IsEnableHZoom" /> or /// <see cref="IsEnableVZoom" />, is true. Note that if there are multiple Y or Y2 axes, all of /// them will be zoomed. /// </remarks> /// <param name="pane">The <see cref="GraphPane" /> instance to be zoomed.</param> /// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than /// 1 to zoom out. For example, 0.9 will zoom in such that the scale is 90% of what it was /// originally.</param> /// <param name="centerPt">The screen position about which the zoom will be centered. This /// value is only used if <see paramref="isZoomOnCenter" /> is true. /// </param> /// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point /// <see paramref="centerPt" />, false to center on the <see cref="Chart.Rect" />. /// </param> public void ZoomPane(GraphPane pane, double zoomFraction, PointF centerPt, bool isZoomOnCenter) { ZoomPane(pane, zoomFraction, centerPt, isZoomOnCenter, true); }
/// <summary> /// Gets a flag indicating if the X axis is the independent axis for this <see cref="CurveItem" /> /// </summary> /// <param name="pane">The parent <see cref="GraphPane" /> of this <see cref="CurveItem" />. /// </param> /// <value>true if the X axis is independent, false otherwise</value> override internal bool IsXIndependent(GraphPane pane) { return(pane._barSettings.Base == BarBase.X); }
/// <summary> /// Handler for the "Set Scale to Default" context menu item. Sets the scale ranging to /// full auto mode for all axes. /// </summary> /// <remarks> /// This method differs from the <see cref="ZoomOutAll" /> method in that it sets the scales /// to full auto mode. The <see cref="ZoomOutAll" /> method sets the scales to their initial /// setting prior to any user actions (which may or may not be full auto mode). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to have the /// scale restored</param> public void RestoreScale( GraphPane primaryPane ) { if ( primaryPane != null ) { //Go ahead and save the old zoomstates, which provides an "undo"-like capability //ZoomState oldState = primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom ); ZoomState oldState = new ZoomState( primaryPane, ZoomState.StateType.Zoom ); using ( Graphics g = this.CreateGraphics() ) { if ( _isSynchronizeXAxes || _isSynchronizeYAxes ) { foreach ( GraphPane pane in _masterPane._paneList ) { pane.ZoomStack.Push( pane, ZoomState.StateType.Zoom ); ResetAutoScale( pane, g ); } } else { primaryPane.ZoomStack.Push( primaryPane, ZoomState.StateType.Zoom ); ResetAutoScale( primaryPane, g ); } // Provide Callback to notify the user of zoom events if ( this.ZoomEvent != null ) this.ZoomEvent( this, oldState, new ZoomState( primaryPane, ZoomState.StateType.Zoom ) ); //g.Dispose(); } Refresh(); } }
/// <summary> /// Creates a new CurveItem using the PointPairList and add it the the given pane. /// </summary> /// <param name="pane">the GraphPane object to which to add the new curve</param> /// <param name="points">a PointPairList collection defining the points for this curve</param> /// <returns>the newly created CurveItem added to the given GraphPane</returns> /// <remarks>This method must be overriden by childs</remarks> public abstract CurveItem CreateInPane( GraphPane pane, PointPairList points );
/// <summary> /// This method collects all the data relative to rendering this <see cref="PieItem"/>'s label. /// </summary> /// <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 graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="rect">The rectangle used for rendering this <see cref="PieItem"/> /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="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> public void DesignLabel(Graphics g, GraphPane pane, RectangleF rect, float scaleFactor) { if (!_labelDetail.IsVisible) { return; } _labelDetail.LayoutArea = new SizeF(); //this.labelDetail.IsWrapped = false; //label line will come off the explosion radius and then pivot to the horizontal right or left, //dependent on position.. //text will be at the end of horizontal segment... CalculateLinePoints(rect, _midAngle); //now get size of bounding rect for label SizeF size = _labelDetail.FontSpec.BoundingBox(g, _labelStr, scaleFactor); //how much room left for the label - most likely midangles for wrapping //Right - 315 -> 45 degrees //Bottom - 45 -> 135 //Left - 135 -> 225 //Top - 225 -> 315 RectangleF chartRect = pane.Chart._rect; float fill = 0; if (_midAngle > 315 || _midAngle <= 45) { //correct by wrapping text fill = chartRect.X + chartRect.Width - _endPoint.X - 5; if (size.Width > fill) { //need to wrap, so create label rectangle for overloaded DrawString - two rows, max _labelDetail.LayoutArea = new SizeF(fill, size.Height * 3.0F); } } if (_midAngle > 45 && _midAngle <= 135) { //correct by moving radial line toward one or the other end of the range fill = chartRect.Y + chartRect.Height - _endPoint.Y - 5; //is there enuf room for the label if (size.Height / 2 > fill) { //no, so got to move explosion radius if (_midAngle > 90) //move _label clockwise one-third of way to the end of the arc { CalculateLinePoints(rect, _midAngle + (_sweepAngle + _startAngle - _midAngle) / 3); } else //move _label counter-clockwise one-third of way to the start of the arc { CalculateLinePoints(rect, _midAngle - (_midAngle - (_midAngle - _startAngle) / 3)); } } } if (_midAngle > 135 && _midAngle <= 225) { //wrap text fill = _endPoint.X - chartRect.X - 5; //need to wrap, so create label rectangle for overloaded DrawString - two rows, max if (size.Width > fill) { _labelDetail.LayoutArea = new SizeF(fill, size.Height * 3.0F); } } if (_midAngle > 225 && _midAngle <= 315) { //correct by moving radial line toward one or the other end of the range fill = _endPoint.Y - 5 - chartRect.Y; //is there enuf room for the label if (size.Height / 2 > fill) { //no, so got to move explosion radius if (_midAngle < 270) //move _label counter-clockwise one-third of way to the start of the arc { CalculateLinePoints(rect, _midAngle - (_sweepAngle + _startAngle - _midAngle) / 3); } else //move _label clockwise one-third of way to the end of the arc { CalculateLinePoints(rect, _midAngle + (_midAngle - _startAngle) / 3); } } } //complete the location Detail info _labelDetail.Location.AlignV = AlignV.Center; _labelDetail.Location.CoordinateFrame = CoordType.PaneFraction; _labelDetail.Location.X = (_endPoint.X - pane.Rect.X) / pane.Rect.Width; _labelDetail.Location.Y = (_endPoint.Y - pane.Rect.Y) / pane.Rect.Height; _labelDetail.Text = _labelStr; }
public static void ClearGraphPane(GraphPane graphPane) { graphPane.CurveList.Clear(); graphPane.GraphObjList.Clear(); }
/// <summary> /// Do all rendering associated with this <see cref="PieItem"/> item to the specified /// <see cref="Graphics"/> device. This method is normally only /// called by the Draw method of the parent <see cref="CurveList"/> /// collection object. /// </summary> /// <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="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="pos">Not used for rendering Pies</param>param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="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> override public void Draw(Graphics g, GraphPane pane, int pos, float scaleFactor) { if (pane.Chart._rect.Width <= 0 && pane.Chart._rect.Height <= 0) { //pane.PieRect = RectangleF.Empty; _slicePath = null; } else { //pane.PieRect = CalcPieRect( g, pane, scaleFactor, pane.ChartRect ); CalcPieRect(g, pane, scaleFactor, pane.Chart._rect); _slicePath = new GraphicsPath(); if (!_isVisible) { return; } RectangleF tRect = _boundingRectangle; if (tRect.Width >= 1 && tRect.Height >= 1) { SmoothingMode sMode = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; Fill tFill = _fill; Border tBorder = _border; if (this.IsSelected) { tFill = Selection.Fill; tBorder = Selection.Border; } using (Brush brush = tFill.MakeBrush(_boundingRectangle)) { g.FillPie(brush, tRect.X, tRect.Y, tRect.Width, tRect.Height, this.StartAngle, this.SweepAngle); //add GraphicsPath for hit testing _slicePath.AddPie(tRect.X, tRect.Y, tRect.Width, tRect.Height, this.StartAngle, this.SweepAngle); if (this.Border.IsVisible) { using (Pen borderPen = tBorder.GetPen(pane, scaleFactor)) { g.DrawPie(borderPen, tRect.X, tRect.Y, tRect.Width, tRect.Height, this.StartAngle, this.SweepAngle); } } if (_labelType != PieLabelType.None) { DrawLabel(g, pane, tRect, scaleFactor); } //brush.Dispose(); } g.SmoothingMode = sMode; } } }
/// <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="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="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> /// Gets a flag indicating if the X axis is the independent axis for this <see cref="CurveItem" /> /// </summary> /// <param name="pane">The parent <see cref="GraphPane" /> of this <see cref="CurveItem" />. /// </param> /// <value>true if the X axis is independent, false otherwise</value> override internal bool IsXIndependent(GraphPane pane) { return(true); }
/// <summary> /// Renders the demo graph with one call. /// </summary> /// <param name="g">A <see cref="Graphics"/> object for which the drawing will be done.</param> /// <param name="pane">A reference to the <see cref="GraphPane"/></param> public static void RenderDemo(IGraphics g, GraphPane pane) { // Set the titles and axis labels pane.Title.Text = "Wacky Widget Company\nProduction Report"; pane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)"; pane.YAxis.Title.Text = "Widget Production\n(units/hour)"; LineItem curve; // Set up curve "Larry" double[] x = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}; double[] y = {20, 10, 50, 25, 35, 75, 90, 40, 33, 50}; // Use green, with circle symbols curve = pane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle); curve.Line.Width = 1.5F; // Fill the area under the curve with a white-green gradient curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F); // Make it a smooth line curve.Line.IsSmooth = true; curve.Line.SmoothTension = 0.6F; // Fill the symbols with white curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 10; // Second curve is "moe" double[] x3 = {150, 250, 400, 520, 780, 940}; double[] y3 = {5.2, 49.0, 33.8, 88.57, 99.9, 36.8}; // Use a red color with triangle symbols curve = pane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle); curve.Line.Width = 1.5F; // Fill the area under the curve with semi-transparent pink using the alpha value curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F); // Fill the symbols with white curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 10; // Third Curve is a bar, called "Wheezy" double[] x4 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}; double[] y4 = {30, 45, 53, 60, 75, 83, 84, 79, 71, 57}; BarItem bar = pane.AddBar("Wheezy", x4, y4, Color.SteelBlue); // Fill the bars with a RosyBrown-White-RosyBrown gradient bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown); // Fourth curve is a bar double[] x2 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000}; double[] y2 = {10, 15, 17, 20, 25, 27, 29, 26, 24, 18}; bar = pane.AddBar("Curly", x2, y2, Color.RoyalBlue); // Fill the bars with a RoyalBlue-White-RoyalBlue gradient bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue); // Fill the pane background with a gradient pane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F); // Fill the axis background with a gradient pane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F); // Make each cluster 100 user scale units wide. This is needed because the X Axis // type is Linear rather than Text or Ordinal pane.BarSettings.ClusterScaleWidth = 100; // Bars are stacked pane.BarSettings.Type = BarType.Stack; // Enable the X and Y axis grids pane.XAxis.MajorGrid.IsVisible = true; pane.YAxis.MajorGrid.IsVisible = true; // Manually set the scale maximums according to user preference pane.XAxis.Scale.Max = 1200; pane.YAxis.Scale.Max = 120; // Add a text item to decorate the graph var text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F); // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates text.Location.AlignH = AlignH.Center; text.Location.AlignV = AlignV.Bottom; text.FontSpec.Fill = new Fill(Color.White, Color.PowderBlue, 45F); text.FontSpec.StringAlignment = StringAlignment.Near; pane.GraphObjList.Add(text); // Add an arrow pointer for the above text item var arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; pane.GraphObjList.Add(arrow); // Add a another text item to to point out a graph feature text = new TextObj("Upgrade", 700F, 50.0F); // rotate the text 90 degrees text.FontSpec.Angle = 90; // Align the text such that the Right-Center is at (700, 50) in user scale coordinates text.Location.AlignH = AlignH.Right; text.Location.AlignV = AlignV.Center; // Disable the border and background fill options for the text text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; pane.GraphObjList.Add(text); // Add an arrow pointer for the above text item arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; arrow.Line.Width = 2.0F; pane.GraphObjList.Add(arrow); // Add a text "Confidential" stamp to the graph text = new TextObj("Confidential", 0.85F, -0.03F); // use ChartFraction coordinates so the text is placed relative to the ChartRect text.Location.CoordinateFrame = CoordType.ChartFraction; // rotate the text 15 degrees text.FontSpec.Angle = 15.0F; // Text will be red, bold, and 16 point text.FontSpec.FontColor = Color.Red; text.FontSpec.IsBold = true; text.FontSpec.Size = 16; // Disable the border and background fill options for the text text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; // Align the text such the the Left-Bottom corner is at the specified coordinates text.Location.AlignH = AlignH.Left; text.Location.AlignV = AlignV.Bottom; pane.GraphObjList.Add(text); // Add a BoxObj to show a colored band behind the graph data var box = new BoxObj(0, 110, 1200, 10, Color.Empty, Color.FromArgb(225, 245, 225)); box.Location.CoordinateFrame = CoordType.AxisXYScale; // Align the left-top of the box to (0, 110) box.Location.AlignH = AlignH.Left; box.Location.AlignV = AlignV.Top; // place the box behind the axis items, so the grid is drawn on top of it box.ZOrder = ZOrder.D_BehindAxis; pane.GraphObjList.Add(box); // Add some text inside the above box to indicate "Peak Range" var myText = new TextObj("Peak Range", 1170, 105); myText.Location.CoordinateFrame = CoordType.AxisXYScale; myText.Location.AlignH = AlignH.Right; myText.Location.AlignV = AlignV.Center; myText.FontSpec.IsItalic = true; myText.FontSpec.IsBold = false; myText.FontSpec.Fill.IsVisible = false; myText.FontSpec.Border.IsVisible = false; pane.GraphObjList.Add(myText); pane.AxisChange(g); }
/// <summary> /// Adds content to the <see cref="GraphPane"/> instance based on the web controls state elements. /// This requires applying each <see cref="ZedGraphWebCurveItem"/> to the <see cref="GraphPane"/> /// including all the values and sub objects. /// </summary> /// <param name="g"><see cref="Graphics"/></param> /// <param name="pane"><see cref="GraphPane"/></param> protected void SetWebProperties(IGraphics g, GraphPane pane) { try { pane.Title.IsVisible = IsShowTitle; pane.BarSettings.Type = BarType; XAxis.CopyTo(pane.XAxis); YAxis.CopyTo(pane.YAxis); Y2Axis.CopyTo(pane.Y2Axis); pane.IsIgnoreInitial = IsIgnoreInitial; pane.IsIgnoreMissing = IsIgnoreMissing; pane.LineType = LineType; ChartBorder.CopyTo(pane.Chart.Border); ChartFill.CopyTo(pane.Chart.Fill); pane.BarSettings.MinClusterGap = MinClusterGap; pane.BarSettings.MinBarGap = MinBarGap; pane.BarSettings.Base = BarBase; Legend.CopyTo(pane.Legend); FontSpec.CopyTo(pane.Title.FontSpec); pane.Title.Text = Title; PaneBorder.CopyTo(pane.Border); PaneFill.CopyTo(pane.Fill); pane.Margin.Left = Margins.Left; pane.Margin.Right = Margins.Right; pane.Margin.Top = Margins.Top; pane.Margin.Bottom = Margins.Bottom; pane.BaseDimension = BaseDimension; pane.IsFontsScaled = IsFontsScaled; pane.IsPenWidthScaled = IsPenWidthScaled; } catch (Exception ex) { Log.Debug("Exception thrown at SetWebProperties: " + ex.Message, ex); } }
private void DepthTimeChart_Load(object sender, System.EventArgs e) { //backgroundWorker1_depthshow.WorkerSupportsCancellation = true; //声明是否支持取消线程 // *** BEGIN 控件整体设置 *** zed1.IsShowPointValues = false; //显示网格上对应值 zed1.IsEnableZoom = false; zed1.IsEnableVZoom = false; zed1.IsEnableHZoom = false; zed1.IsShowContextMenu = false; //禁用右键弹出菜单 //zed1.IsZoomOnMouseCenter = true; //加上这个鼠标中间可以缩放,但是有问题 zed1.BackColor = _BACK_COLOR; zed1.BorderStyle = BorderStyle.None; // *** END 控件整体值显示 *** // *** BEGIN myPane设置 *** myPane = this.zed1.GraphPane; myPane.Fill = new Fill(_BACK_COLOR); //chart外框背景颜色 myPane.Border.IsVisible = false; //chart图边框不显示 myPane.Title.IsVisible = false; //chart图抬头不显示 myPane.Chart.Fill = new Fill(_BACK_COLOR); //chart内容绘制区域颜色 myPane.Chart.Border.IsVisible = false; //chart曲线边框不显示 // *** END myPane设置 *** // *** BEGIN X轴设置 *** myPane.XAxis.Cross = 0.0d; //X轴交叉刻度 myPane.XAxis.CrossAuto = true; myPane.XAxis.Title.IsVisible = false; //X轴不显示抬头 myPane.XAxis.IsVisible = false; //X轴直接不显示 myPane.XAxis.Color = Color.Transparent; //X轴颜色 myPane.XAxis.Scale.IsVisible = true; //X轴显示 myPane.XAxis.Scale.FontSpec.FontColor = Color.GreenYellow; //X轴字体颜色 myPane.XAxis.MajorGrid.IsVisible = false; //X轴显示网格 myPane.XAxis.MajorGrid.Color = Color.Gray; //X轴网格颜色 myPane.XAxis.Scale.Min = -0.1; //X轴最小值0 myPane.XAxis.Scale.Max = 10.1; //X轴最大60 //myPane.XAxis.Scale.MajorStepAuto = true; //X轴显示步长 myPane.XAxis.Scale.FontSpec.IsUnderline = false; //myPane.XAxis.Scale.MajorStep = 1; //X轴小步长1,也就是小间隔 // *** END X轴设置 *** // *** BEGIN Y轴设置 *** myPane.YAxis.Title.IsVisible = false; //Y轴1显示抬头 //myPane.YAxis.Title.Text = "Timing"; //Y轴1时间类型 //myPane.YAxis.Title.FontSpec.FontColor = Color.YellowGreen; //Y轴字体颜色 //myPane.YAxis.Title.FontSpec.Size = 22; myPane.YAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.Color = Color.YellowGreen; //Y轴颜色 myPane.YAxis.Scale.IsVisible = true; //Y轴显示 myPane.YAxis.Scale.Align = AlignP.Inside; myPane.YAxis.Scale.AlignH = AlignH.Center; myPane.YAxis.Scale.FontSpec.Size = 20; myPane.YAxis.Scale.FontSpec.FontColor = Color.GreenYellow; //Y轴字体颜色 myPane.YAxis.MajorGrid.IsVisible = false; //Y轴显示网格 myPane.YAxis.MajorGrid.Color = Color.Gray; //Y轴网格颜色 myPane.YAxis.Scale.Max = Comm.ConvertDateTimeInt(DateTime.Now) / 1000; //Y轴从0开始,这个地方要影响X轴的显示 myPane.YAxis.Scale.Min = myPane.YAxis.Scale.Max - _YCount; //Y轴上放200个点,这样看起来曲线更平滑 //myPane.YAxis.Scale.MajorStepAuto = true; //Y轴显示步长 myPane.YAxis.Scale.MajorStep = _YCount / 10; //X轴大步长,也就是显示文字的大间隔 myPane.YAxis.Scale.IsReverse = true; //从上到下画线 zed1.GraphPane.YAxis.ScaleFormatEvent += new Axis.ScaleFormatHandler(YAxis_ScaleFormatEvent); m_dBaseTime = myPane.YAxis.Scale.Max;// (myPane.YAxis.Scale.Max + myPane.YAxis.Scale.Min) / 2; //改变轴的刻度 zed1.AxisChange(); }
public void Zed() { GraphPane myPane = zed.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Mõõtetulemused"; myPane.XAxis.Title.Text = "Time, ms"; myPane.Y2Axis.Title.Text = "Tõmme, N"; myPane.YAxis.Title.Text = "Vääne, N"; // Generate a red curve with diamond symbols, and "Velocity" in the legend LineItem myCurve = myPane.AddCurve("Vääne", TorquePoints, Color.Red, SymbolType.None); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Generate a blue curve with circle symbols, and "Acceleration" in the legend myCurve = myPane.AddCurve("Tõmme", PullPoints, Color.Blue, SymbolType.None); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Associate this curve with the Y2 axis myCurve.IsY2Axis = true; // Generate a green curve with square symbols, and "Distance" in the legend myCurve = myPane.AddCurve("Temperatuur", TempPoints, Color.Green, SymbolType.None); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Associate this curve with the second Y axis myCurve.YAxisIndex = 1; // Generate a Black curve with triangle symbols, and "Energy" in the legend myCurve = myPane.AddCurve("RPM", RPMPoints, Color.DarkOrange, SymbolType.None); // Fill the symbols with white myCurve.Symbol.Fill = new Fill(Color.White); // Associate this curve with the Y2 axis myCurve.IsY2Axis = true; // Associate this curve with the second Y2 axis myCurve.YAxisIndex = 1; myPane.YAxis.Type = AxisType.Linear; // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; // Make the Y axis scale red myPane.YAxis.Scale.FontSpec.FontColor = Color.Red; myPane.YAxis.Title.FontSpec.FontColor = Color.Red; // turn off the opposite tics so the Y tics don't show up on the Y2 axis myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; // Don't display the Y zero line myPane.YAxis.MajorGrid.IsZeroLine = false; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; myPane.YAxis.Scale.Max = 100; // Enable the Y2 axis display myPane.Y2Axis.IsVisible = true; // Make the Y2 axis scale blue myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Blue; myPane.Y2Axis.Title.FontSpec.FontColor = Color.Blue; // turn off the opposite tics so the Y2 tics don't show up on the Y axis myPane.Y2Axis.MajorTic.IsOpposite = false; myPane.Y2Axis.MinorTic.IsOpposite = false; // Display the Y2 axis grid lines myPane.Y2Axis.MajorGrid.IsVisible = true; // Align the Y2 axis labels so they are flush to the axis myPane.Y2Axis.Scale.Align = AlignP.Inside; //myPane.Y2Axis.Scale.Min = 1.5; myPane.Y2Axis.Scale.Max = 100; // Create a second Y Axis, green YAxis yAxis3 = new YAxis("Temperatuur, °C"); myPane.YAxisList.Add(yAxis3); yAxis3.Scale.FontSpec.FontColor = Color.Green; yAxis3.Title.FontSpec.FontColor = Color.Green; yAxis3.Color = Color.Green; // turn off the opposite tics so the Y2 tics don't show up on the Y axis yAxis3.MajorTic.IsInside = false; yAxis3.MinorTic.IsInside = false; yAxis3.MajorTic.IsOpposite = false; yAxis3.MinorTic.IsOpposite = false; // Align the Y2 axis labels so they are flush to the axis yAxis3.Scale.Align = AlignP.Inside; yAxis3.Scale.Max = 100; Y2Axis yAxis4 = new Y2Axis("RPM, p/min"); yAxis4.IsVisible = true; myPane.Y2AxisList.Add(yAxis4); yAxis4.Scale.FontSpec.FontColor = Color.DarkOrange; yAxis4.Title.FontSpec.FontColor = Color.DarkOrange; // turn off the opposite tics so the Y2 tics don't show up on the Y axis yAxis4.MajorTic.IsInside = false; yAxis4.MinorTic.IsInside = false; yAxis4.MajorTic.IsOpposite = false; yAxis4.MinorTic.IsOpposite = false; // Align the Y2 axis labels so they are flush to the axis yAxis4.Scale.Align = AlignP.Inside; yAxis4.Type = AxisType.Linear; yAxis4.Scale.Max = 100; // Fill the axis background with a gradient // myPane.Chart.Fill = new Fill(Color.Gray, Color.Black, 45.0f); myPane.Chart.Fill = new Fill(Color.WhiteSmoke); // Tell ZedGraph to calculate the axis ranges // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets // up the proper scrolling parameters zed.AxisChange(); // Make sure the Graph gets redrawn zed.Invalidate(); }
// Call this method from the Form_Load method public void CreateChartComb() { GraphPane myPane = this.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Wacky Widget Company\nProduction Report"; myPane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)"; myPane.YAxis.Title.Text = "Widget Production\n(units/hour)"; LineItem curve; // Set up curve "Larry" double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y = { 20, 10, 50, 25, 35, 75, 94, 40, 33, 50 }; // Use green, with circle symbols curve = myPane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle); curve.Line.Width = 1.5F; // Fill the area under the curve with a white-green gradient curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F); // Make it a smooth line curve.Line.IsSmooth = true; curve.Line.SmoothTension = 0.6F; // Fill the symbols with white curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 10; // Second curve is "moe" double[] x3 = { 150, 250, 400, 520, 780, 940 }; double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 }; // Use a red color with triangle symbols curve = myPane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle); curve.Line.Width = 1.5F; // Fill the area under the curve with semi-transparent pink using the alpha value curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F); // Fill the symbols with white curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 10; // Third Curve is a bar, called "Wheezy" double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y4 = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 }; BarItem bar = myPane.AddBar("Wheezy", x4, y4, Color.SteelBlue); // Fill the bars with a RosyBrown-White-RosyBrown gradient bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown); // Fourth curve is a bar double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 }; bar = myPane.AddBar("Curly", x2, y2, Color.RoyalBlue); // Fill the bars with a RoyalBlue-White-RoyalBlue gradient bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue); // Fill the pane background with a gradient myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F); // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F); // Make each cluster 100 user scale units wide. This is needed because the X Axis // type is Linear rather than Text or Ordinal myPane.BarSettings.ClusterScaleWidth = 100; // 堆叠柱状图 Bars are stacked myPane.BarSettings.Type = BarType.Stack; // 显示X轴Y轴栅格 myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; // 设置X和Y轴的最大值,最小值 //myPane.XAxis.Scale.Max = 1400; //myPane.YAxis.Scale.Max = 120; //myPane.XAxis.Scale.Min = -100; // 加入文本标识 TextObj text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F); // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates text.Location.AlignH = AlignH.Center; text.Location.AlignV = AlignV.Bottom; text.FontSpec.Fill = new Fill(Color.White, Color.PowderBlue, 45F); text.FontSpec.StringAlignment = StringAlignment.Near; myPane.GraphObjList.Add(text); // 为上面的文本加箭头 ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; myPane.GraphObjList.Add(arrow); // 再加一个文本 text = new TextObj("Upgrade", 700F, 50.0F); // 旋转90度 text.FontSpec.Angle = 90; // 修改对齐方式 Align the text such that the Right-Center is at (700, 50) in user scale coordinates text.Location.AlignH = AlignH.Right; text.Location.AlignV = AlignV.Center; // 去掉文本框的填充和外框 text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(text); // 再为上面的文本加入一个箭头 arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80); arrow.Location.CoordinateFrame = CoordType.AxisXYScale; //arrow.PenWidth = 2.0F; myPane.GraphObjList.Add(arrow); // 添加文本 text = new TextObj("内部资料", 0.85F, -0.03F); // 使用 ChartFraction coordinates,以便文本和图形矩形坐标相关 text.Location.CoordinateFrame = CoordType.ChartFraction; // 旋转15度 text.FontSpec.Angle = 15.0F; // 设置文本特性 text.FontSpec.FontColor = Color.Red; text.FontSpec.IsBold = true; text.FontSpec.Size = 16; // 去除填充和外框显示 text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; // 设置对齐方式 text.Location.AlignH = AlignH.Left; text.Location.AlignV = AlignV.Bottom; myPane.GraphObjList.Add(text); // 增加 BoxObj 在数据上部显示一个颜色条 BoxObj box = new BoxObj(0, 110, 1200, 10, Color.Empty, Color.FromArgb(225, 245, 225)); box.Location.CoordinateFrame = CoordType.AxisXYScale; // 对齐到 left-top of the box to (0, 110) box.Location.AlignH = AlignH.Left; box.Location.AlignV = AlignV.Top; // 设置Z方向的次序 place the box behind the axis items, so the grid is drawn on top of it box.ZOrder = ZOrder.F_BehindGrid; myPane.GraphObjList.Add(box); // Add some text inside the above box to indicate "Peak Range" TextObj myText = new TextObj("Peak Range", 1170, 105); myText.Location.CoordinateFrame = CoordType.AxisXYScale; myText.Location.AlignH = AlignH.Right; myText.Location.AlignV = AlignV.Center; myText.FontSpec.IsItalic = true; myText.FontSpec.IsBold = false; myText.FontSpec.Fill.IsVisible = false; myText.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(myText); // Calculate the Axis Scale Ranges this.AxisChange(); }
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_BehindAxis; myPane.GraphObjList.Add(box); base.ZedGraphControl.AxisChange(); }
// Fill the graph with the data provided. private void FillGraphWithData(ZedGraph.ZedGraphControl zgc, int thresholdId, int deviceId, string deviceType, string thresholdName) { if (zgc == null) { return; } GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels per selection thresholdName = thresholdName.Replace(" ", String.Empty);//remove whitespaces myPane.Title.Text = thresholdName + " - " + "last 24 hours"; // myPane.Title.Text = "last 24 hours"; myPane.XAxis.Title.Text = "Time (Sec)"; myPane.YAxis.Title.Text = "%"; // Change the color of the title // myPane.Title.FontSpec.FontColor = Color.Blue; //Set the font size myPane.Title.FontSpec.Size = 20.0f; myPane.YAxis.Title.FontSpec.Size = 20.0f; myPane.YAxis.Scale.FontSpec.Size = 20.0f; myPane.XAxis.Title.FontSpec.Size = 20.0f; myPane.XAxis.Scale.FontSpec.Size = 20.0f; myPane.CurveList.Clear();// clear the graph myPane.Legend.IsVisible = false; XDate minDate = XDate.JulDayMax; XDate maxDate = XDate.JulDayMin; //Create Random colors to show on Graph PointPairList listDeviceValues = GetValuesForDevice(deviceId, thresholdId); //use this to add line width 3.0F LineItem myCurve = new LineItem("", listDeviceValues, Color.Blue, SymbolType.XCross); myPane.CurveList.Add(myCurve); if (listDeviceValues.Count > 0) { XDate firstDate = (XDate)(listDeviceValues[0].X); XDate lastDate = (XDate)listDeviceValues[listDeviceValues.Count - 1].X; if (minDate == XDate.JulDayMax) //The max valid Julian Day, which corresponds to January 1st, 4713 B.C { minDate = firstDate; } else if (firstDate < minDate) { minDate = firstDate; } if (maxDate == XDate.JulDayMin)//The minimum valid Julian Day, which corresponds to January 1st, 4713 B.C { maxDate = lastDate; } else if (lastDate > maxDate) { maxDate = lastDate; } } Int32 thresholdValue = GetContractThreshold(deviceType, thresholdId);//Read the Threshold values PointPairList thresholdPointList = new PointPairList(); thresholdPointList.Add(new PointPair(minDate, thresholdValue)); thresholdPointList.Add(new PointPair(maxDate, thresholdValue)); myPane.CurveList.Insert(0, new LineItem("Threshold", thresholdPointList, Color.FromArgb(255, 0, 0, 0), SymbolType.XCross, 3.0f)); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F); // Fill the pane background with a color gradient myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F); //This informs ZedGraph to use the labels supplied by the user in Axis.Scale.TextLabels Axis.Default.Type = AxisType.Text; ////Show tooltips when the mouse hovers over a point //zgc.IsShowPointValues = true; //zgc.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); // Set the XAxis to date type myPane.XAxis.Type = AxisType.Date; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MinorGrid.IsVisible = true; // Calculate the Axis Scale Ranges axisChangeZedGraph(zgc); //refrsh the graph }
/// <summary> /// Creates overall graph for the first file /// </summary> private void createWholeGraph() { GraphPane myPane = new GraphPane(); GraphPane myPane1 = new GraphPane(); myPane = zedGraphControl1.GraphPane; myPane1 = zedGraphControl2.GraphPane; myPane.Title.Text = "Overall Graph of First File"; myPane.XAxis.Title.Text = "Time in second"; myPane.YAxis.Title.Text = "Heart Rate "; myPane1.Title.Text = "Overall Graph of Second File"; myPane1.XAxis.Title.Text = "Time in second"; myPane1.YAxis.Title.Text = "Parameters "; zedGraphControl2.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt = new PointPairList(); PointPairList pt2 = new PointPairList(); PointPairList pt3 = new PointPairList(); PointPairList pt1 = new PointPairList(); PointPairList pt4 = new PointPairList(); PointPairList pt5 = new PointPairList(); PointPairList pt6 = new PointPairList(); PointPairList pt7 = new PointPairList(); PointPairList pt8 = new PointPairList(); PointPairList pt9 = new PointPairList(); pt = buildPointPairList(heart.ToArray()); pt1 = buildPointPairList(speed.ToArray()); pt2 = buildPointPairList(cadence.ToArray()); pt3 = buildPointPairList(power.ToArray()); pt4 = buildPointPairList(altitude.ToArray()); pt5 = buildPointPairList(heart11.ToArray()); pt6 = buildPointPairList(speed11.ToArray()); pt7 = buildPointPairList(cadence11.ToArray()); pt8 = buildPointPairList(power11.ToArray()); pt9 = buildPointPairList(altitude11.ToArray()); LineItem teamACurve = myPane.AddCurve("Heart Rate", pt, Color.Red, SymbolType.None); LineItem teamACurve1 = myPane.AddCurve("Speed", pt1, Color.Blue, SymbolType.None); LineItem teamACurve2 = myPane.AddCurve("Cadence", pt2, Color.Yellow, SymbolType.None); LineItem teamACurve3 = myPane.AddCurve("Altitude", pt3, Color.Green, SymbolType.None); LineItem teamACurve4 = myPane.AddCurve("Power", pt4, Color.Pink, SymbolType.None); LineItem teamACurve5 = myPane1.AddCurve("Heart Rate", pt5, Color.Red, SymbolType.None); LineItem teamACurve6 = myPane1.AddCurve("Speed", pt6, Color.Blue, SymbolType.None); LineItem teamACurve7 = myPane1.AddCurve("Cadence", pt7, Color.Yellow, SymbolType.None); LineItem teamACurve8 = myPane1.AddCurve("Altitude", pt8, Color.Green, SymbolType.None); LineItem teamACurve9 = myPane1.AddCurve("Power", pt9, Color.Pink, SymbolType.None); zedGraphControl1.AxisChange(); zedGraphControl2.AxisChange(); }
private void ResetAutoScale( GraphPane pane, Graphics g ) { pane.XAxis.ResetAutoScale( pane, g ); pane.X2Axis.ResetAutoScale( pane, g ); foreach ( YAxis axis in pane.YAxisList ) axis.ResetAutoScale( pane, g ); foreach ( Y2Axis axis in pane.Y2AxisList ) axis.ResetAutoScale( pane, g ); }
/// <summary> /// Creates individual graph for first file /// </summary> public void CreateIndividualGraph() { GraphPane myPane = new GraphPane(); myPane = zedGraphControl3.GraphPane; myPane.Title.Text = "Graph of HeartRate"; myPane.XAxis.Title.Text = "Time in second"; myPane.YAxis.Title.Text = "Reading "; zedGraphControl3.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt = buildPointPairList(heart.ToArray()); LineItem teamACurve = myPane.AddCurve("Heart Rate", pt, Color.Red, SymbolType.None); zedGraphControl3.AxisChange(); GraphPane myPane1 = new GraphPane(); myPane1 = zedGraphControl4.GraphPane; myPane1.Title.Text = "Graph of Speed"; myPane1.XAxis.Title.Text = "Time in second"; myPane1.YAxis.Title.Text = "Reading "; zedGraphControl4.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt1 = buildPointPairList(speed.ToArray()); LineItem teamACurve1 = myPane1.AddCurve("Speed", pt1, Color.Blue, SymbolType.None); zedGraphControl4.AxisChange(); GraphPane myPane2 = new GraphPane(); myPane2 = zedGraphControl5.GraphPane; myPane2.Title.Text = "Graph of Cadence"; myPane2.XAxis.Title.Text = "Time in second"; myPane2.YAxis.Title.Text = "Reading "; zedGraphControl5.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt3 = buildPointPairList(cadence.ToArray()); LineItem teamACurve2 = myPane2.AddCurve("Cadence", pt3, Color.Yellow, SymbolType.None); zedGraphControl5.AxisChange(); GraphPane myPane3 = new GraphPane(); myPane3 = zedGraphControl6.GraphPane; myPane3.Title.Text = "Graph of Altitude"; myPane3.XAxis.Title.Text = "Time in second"; myPane3.YAxis.Title.Text = "Reading "; zedGraphControl6.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt4 = buildPointPairList(altitude.ToArray()); LineItem teamACurve4 = myPane3.AddCurve("Altitude", pt4, Color.Green, SymbolType.None); zedGraphControl6.AxisChange(); GraphPane myPane5 = new GraphPane(); myPane5 = zedGraphControl7.GraphPane; myPane5.Title.Text = "Graph of Power"; myPane5.XAxis.Title.Text = "Time in second"; myPane5.YAxis.Title.Text = "Reading "; zedGraphControl7.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt5 = buildPointPairList(power.ToArray()); LineItem teamACurve5 = myPane5.AddCurve("Power", pt5, Color.Pink, SymbolType.None); zedGraphControl7.AxisChange(); GraphPane myPane6 = new GraphPane(); myPane5 = zedGraphControl8.GraphPane; myPane5.Title.Text = "Graph of Heart Rate"; myPane5.XAxis.Title.Text = "Time in second"; myPane5.YAxis.Title.Text = "Reading "; zedGraphControl7.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt6 = buildPointPairList(heart11.ToArray()); LineItem teamACurve6 = myPane5.AddCurve("Heart", pt6, Color.Red, SymbolType.None); zedGraphControl8.AxisChange(); GraphPane myPane7 = new GraphPane(); myPane1 = zedGraphControl9.GraphPane; myPane1.Title.Text = "Graph of Speed"; myPane1.XAxis.Title.Text = "Time in second"; myPane1.YAxis.Title.Text = "Reading "; zedGraphControl9.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt7 = buildPointPairList(speed11.ToArray()); LineItem teamACurve7 = myPane1.AddCurve("Speed", pt7, Color.Blue, SymbolType.None); zedGraphControl9.AxisChange(); GraphPane myPane8 = new GraphPane(); myPane2 = zedGraphControl10.GraphPane; myPane2.Title.Text = "Graph of Cadence"; myPane2.XAxis.Title.Text = "Time in second"; myPane2.YAxis.Title.Text = "Reading "; zedGraphControl5.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt8 = buildPointPairList(cadence11.ToArray()); LineItem teamACurve8 = myPane2.AddCurve("Cadence", pt8, Color.Yellow, SymbolType.None); zedGraphControl10.AxisChange(); GraphPane myPane9 = new GraphPane(); myPane2 = zedGraphControl11.GraphPane; myPane2.Title.Text = "Graph of Altitude"; myPane2.XAxis.Title.Text = "Time in second"; myPane2.YAxis.Title.Text = "Reading "; zedGraphControl5.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt9 = buildPointPairList(altitude11.ToArray()); LineItem teamACurve9 = myPane2.AddCurve("Altitude", pt9, Color.Green, SymbolType.None); zedGraphControl11.AxisChange(); GraphPane myPane10 = new GraphPane(); myPane5 = zedGraphControl12.GraphPane; myPane5.Title.Text = "Graph of Power"; myPane5.XAxis.Title.Text = "Time in second"; myPane5.YAxis.Title.Text = "Reading "; zedGraphControl7.GraphPane.Chart.Fill.Color = System.Drawing.Color.Black; PointPairList pt11 = buildPointPairList(power11.ToArray()); LineItem teamACurve10 = myPane5.AddCurve("Power", pt5, Color.Pink, SymbolType.None); zedGraphControl12.AxisChange(); }
/// <summary> /// Creates a new CurveItem using the PointPairList and add it the the given pane. /// </summary> /// <param name="pane">the GraphPane object to which to add the new curve</param> /// <param name="points">a PointPairList collection defining the points for this curve</param> /// <returns>the newly created CurveItem added to the given GraphPane</returns> /// <remarks>This method must be overriden by childs</remarks> public override CurveItem CreateInPane( GraphPane pane, PointPairList points ) { BarItem x = pane.AddBar( this.Label, points, this.Color ); this.CopyTo( x ); return x; }
// ------------------ CHARTING ROUTINES --------------------- // Set up the chart public void SetupChart() { MasterPane masterPane = chartControl.MasterPane; masterPane.PaneList.Clear(); // get a reference to the GraphPane _temperaturePane = new GraphPane(new Rectangle(5, 5, 890, 350), "Temperature controller", "Time (s)", "Temperature (C)"); masterPane.Add(_temperaturePane); //var temperaturePane = chartControl.GraphPane; // Set the Titles //temperaturePane.Title.Text = "Temperature controller"; //temperaturePane.XAxis.Title.Text = "Time (s)"; //temperaturePane.YAxis.Title.Text = "Temperature (C)"; // Create data arrays for rolling points _analog1List = new RollingPointPairList(3000); _analog3List = new RollingPointPairList(3000); _analog1List.Clear(); _analog3List.Clear(); // Create a smoothened red curve for the current temperature LineItem myCurve1 = _temperaturePane.AddCurve("Current temperature", _analog1List, Color.Red, SymbolType.None); myCurve1.Line.Width = 2; myCurve1.Line.IsSmooth = true; myCurve1.Line.SmoothTension = 0.2f; // Create a smoothened blue curve for the goal temperature LineItem myCurve3 = _temperaturePane.AddCurve("Goal temperature", _analog3List, Color.Blue, SymbolType.None); myCurve3.Line.Width = 2; myCurve3.Line.IsSmooth = true; myCurve3.Line.SmoothTension = 0.2f; // Tell ZedGraph to re-calculate the axes since the data have changed chartControl.AxisChange(); _heaterPane = new GraphPane(new Rectangle(5, 360, 890, 250), null, null, null); masterPane.Add(_heaterPane); _heaterList = new RollingPointPairList(3000); _heaterPwmList = new RollingPointPairList(3000); _heaterList.Clear(); _heaterPwmList.Clear(); // Create a red curve for the heater value LineItem heaterCurve = _heaterPane.AddCurve(null, _heaterList, Color.YellowGreen, SymbolType.None); heaterCurve.Line.Width = 2; heaterCurve.Line.IsSmooth = false; // Create a red curve for the current heater pwm value LineItem heaterPwmCurve = _heaterPane.AddCurve(null, _heaterPwmList, Color.Blue, SymbolType.None); heaterPwmCurve.Line.Width = 2; heaterPwmCurve.Line.IsSmooth = false; SetChartScale(0); }
/// <summary> /// Provides binding between <see cref="DataSource"/> and the specified pane. Extracts the /// data from <see cref="DataSource"/> and copies it into the appropriate /// <see cref="ZedGraph.IPointList"/> for each <see cref="ZedGraph.CurveItem"/> in the /// specified <see cref="ZedGraph.GraphPane"/>. /// </summary> /// <param name="g">The <see cref="Graphics"/> object to be used for rendering the data.</param> /// <param name="pane">The <see cref="ZedGraph.GraphPane"/> object which will receive the data.</param> protected void PopulateByDataSource(IGraphics g, GraphPane pane) { if (CurveList.Count == 0) { return; } //If the Datasource column names are available we can bind them // correctly to their corresponding DataMember. if (!string.IsNullOrEmpty(DataMember) && DataSource != null && DataSource is ITypedList && DataSource is IListSource) { var tlist = DataSource as ITypedList; var listSource = DataSource as IListSource; IList list = listSource.GetList(); PropertyDescriptorCollection pdc = tlist.GetItemProperties(null); bool bListContainsList = listSource.ContainsListCollection; //Get the DataMember and Type of the base axis in the DataSource string baseDataMember = DataMember; PropertyDescriptor basePd = pdc.Find(baseDataMember, true); if (basePd == null) { throw new Exception("Can't find DataMember '" + baseDataMember + "' in DataSource for the base axis."); } //Foreach bar/curve // Get its DataMember and Type in the DataSource // Add the curve to the pane // Add all corresponding points(baseAxis,valueAxis,0) //Note: Z axis is not supported foreach (ZedGraphWebCurveItem curveItem in CurveList) { //Axis valueAxis = curveItem.ValueAxis; PropertyDescriptorCollection pdcValue = pdc; IList valueList = list; bool bValueListContainsList = bListContainsList; //If present, use DataSource of Curve instead of main DataSource if (curveItem.DataSource != null && curveItem.DataSource is ITypedList && curveItem.DataSource is IListSource) { var valueTlist = curveItem.DataSource as ITypedList; pdcValue = valueTlist.GetItemProperties(null); var valueListSource = curveItem.DataSource as IListSource; valueList = valueListSource.GetList(); bValueListContainsList = valueListSource.ContainsListCollection; } string valueDataMember = curveItem.DataMember; PropertyDescriptor pd = pdcValue.Find(valueDataMember, true); if (pd == null) { throw new Exception("Can't find DataMember '" + valueDataMember + "' in DataSource for the " + curveItem.Label + " axis."); } int indexValueColumn = pdcValue.IndexOf(pd); //Add points var points = new PointPairList(); var pair = new PointPair(); object oColumnValue; try { int nRow = 0; foreach (object row in list) { // // Value axis binding (Y axis) // object valueRow = valueList[nRow]; //Get item value in 'row' if (bValueListContainsList) { if (!(valueRow is IList)) { throw new InvalidCastException("The DataSource contains a list which declares its items as lists, but these don't support the IList interface."); } oColumnValue = (valueRow as IList)[indexValueColumn]; } else { oColumnValue = pd.GetValue(valueRow); } //Convert value to double (always double) double v = 0; if (oColumnValue != null) { switch (oColumnValue.GetType().ToString()) { case "System.DateTime": v = new XDate(Convert.ToDateTime(oColumnValue)).XLDate; break; default: try { v = Convert.ToDouble(oColumnValue); } catch { throw new NotImplementedException("Conversion from " + oColumnValue.GetType() + " to double not implemented."); } break; } // // Base axis binding (X axis) // pair.Tag = oColumnValue; //Original typed value } pair.Y = v; if (XAxis.Type == AxisType.DateAsOrdinal || XAxis.Type == AxisType.Date) { pair.X = new XDate(Convert.ToDateTime(basePd.GetValue(row))).XLDate; } else { pair.X = Convert.ToDouble(basePd.GetValue(row)); } points.Add(pair); nRow++; } } catch (ArgumentOutOfRangeException) { //A local datasource was set on this curve but it has fewer rows than the axis datasource. //So we stop feeding this curve. } //Create curve in pane with its points curveItem.CreateInPane(pane, points); } } else { //Add curves and values set in designer ZedGraphWebCurveItem curve; for (int i = 0; i < CurveList.Count; i++) { curve = CurveList[i]; var points = new PointPairList(); var pair = new PointPair(); for (int j = 0; j < curve.Points.Count; j++) { curve.Points[j].CopyTo(pair); points.Add(pair); } curve.CreateInPane(pane, points); } } //NOTE: ZedGraphWeb.DataMember = base axis //NOTE: ZedGraphCurveItem.DataMember = Y //NOTE: Z values are only supported via the callback (???) //TODO: cache the data-map table before processing rows (???) }
/// <summary> /// Default Constructor /// </summary> public GraphControl() { InitializeComponent(); // These commands do nothing, but they get rid of the compiler warnings for // unused events bool b = MouseDown == null || MouseUp == null || MouseMove == null; // Link in these events from the base class, since we disable them from this class. base.MouseDown += ZedGraphControl_MouseDown; base.MouseUp += ZedGraphControl_MouseUp; base.MouseMove += ZedGraphControl_MouseMove; //this.MouseWheel += new System.Windows.Forms.MouseEventHandler( this.ZedGraphControl_MouseWheel ); // Use double-buffering for flicker-free updating: SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.ResizeRedraw, true); //isTransparentBackground = false; //SetStyle( ControlStyles.Opaque, false ); SetStyle(ControlStyles.SupportsTransparentBackColor, true); //this.BackColor = Color.Transparent; _resourceManager = new ResourceManager("UIGraphLib.GraphLocale", Assembly.GetExecutingAssembly()); Rectangle rect = new Rectangle(0, 0, Size.Width, Size.Height); _masterPane = new MasterPane("", rect); _masterPane.Margin.All = 0; _masterPane.Title.IsVisible = false; string titleStr = _resourceManager.GetString("title_def"); string xStr = _resourceManager.GetString("x_title_def"); string yStr = _resourceManager.GetString("y_title_def"); //GraphPane graphPane = new GraphPane( rect, "Title", "X Axis", "Y Axis" ); GraphPane graphPane = new GraphPane(rect, titleStr, xStr, yStr); using (Graphics g = CreateGraphics()) { graphPane.AxisChange(g); //g.Dispose(); } _masterPane.Add(graphPane); hScrollBar1.Minimum = 0; hScrollBar1.Maximum = 100; hScrollBar1.Value = 0; vScrollBar1.Minimum = 0; vScrollBar1.Maximum = 100; vScrollBar1.Value = 0; _xScrollRange = new ScrollRange(true); _yScrollRangeList = new ScrollRangeList(); _y2ScrollRangeList = new ScrollRangeList(); _yScrollRangeList.Add(new ScrollRange(true)); _y2ScrollRangeList.Add(new ScrollRange(false)); _zoomState = null; _zoomStateStack = new ZoomStateStack(); }
/// <summary> /// Gets a flag indicating if the Z data range should be included in the axis scaling calculations. /// </summary> /// <remarks> /// IsZIncluded is true for <see cref="OHLCBarItem" /> objects, since the Y and Z /// values are defined as the High and Low values for the day.</remarks> /// <param name="pane">The parent <see cref="GraphPane" /> of this <see cref="CurveItem" />. /// </param> /// <value>true if the Z data are included, false otherwise</value> override internal bool IsZIncluded(GraphPane pane) { return(true); }
private void btnVistaPrevia_Click(object sender, EventArgs e) { double[,] datos = new double[45, 36]; double[,] media = new double[5, 35]; double[] ua = new double[30]; double[] va = new double[30]; double[] xa = new double[30]; double[] ya = new double[30]; double[] wa = new double[30]; double[] za = new double[30]; double[] xaa = new double[2]; double[] C200 = new double[2]; double min = 0; double max = 330; int[] ren = new int[45]; int[] dic = new int[30]; int col, d1, d2, renm, dia, ren28, ren07, ren03, ren01; string Etiqueta = " Edad", Titulo; double suma; dsDatos1.Clear(); dsGraDis1.Clear(); /* if (chbTodas.Checked == false) * { * * cryInfGrDiCo1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; * cryInfGrDiCo1.SetDataSource(dsGraDis1); * * sqlDADatos.SelectCommand.Parameters["@IdObra"].Value = txtIdobra.Text; * sqlDADatos.SelectCommand.Parameters["@FechaIni"].Value = dtpIni.Text; * sqlDADatos.SelectCommand.Parameters["@FechaFin"].Value = dtpFin.Text; * sqlDADatos.SelectCommand.Parameters["@TipoCon"].Value = cmbTipo.SelectedValue; * sqlDADatos.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue; * sqlDADatos.SelectCommand.Parameters["@Resis1"].Value = txtResis1.Text; * sqlDADatos.SelectCommand.Parameters["@Resis2"].Value = txtResis2.Text; * sqlDADatos.SelectCommand.Parameters["@Resis3"].Value = txtResis3.Text; * sqlDADatos.SelectCommand.Parameters["@Resis4"].Value = txtResis4.Text; * sqlDADatos.SelectCommand.Parameters["@Lan15EE"].Value = txtLan15EE.Text; * sqlDADatos.SelectCommand.Parameters["@Lan20EE"].Value = txtLan20EE.Text; * sqlDADatos.SelectCommand.Parameters["@Lan25EE"].Value = txtLan25EE.Text; * sqlDADatos.SelectCommand.Parameters["@Lan30EE"].Value = txtLan30EE.Text; * sqlDADatos.SelectCommand.Parameters["@Lan1507"].Value = txtLan1507.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2007"].Value = txtLan2007.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2507"].Value = txtLan2507.Text; * sqlDADatos.SelectCommand.Parameters["@Lan3007"].Value = txtLan3007.Text; * sqlDADatos.SelectCommand.Parameters["@Lan1503"].Value = txtLan1503.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2003"].Value = txtLan2003.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2503"].Value = txtLan2503.Text; * sqlDADatos.SelectCommand.Parameters["@Lan3003"].Value = txtLan3003.Text; * sqlDADatos.SelectCommand.Parameters["@Lan1501"].Value = txtLan1501.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2001"].Value = txtLan2001.Text; * sqlDADatos.SelectCommand.Parameters["@Lan2501"].Value = txtLan2501.Text; * sqlDADatos.SelectCommand.Parameters["@Lan3001"].Value = txtLan3001.Text; * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 0; * sqlDADatos.SelectCommand.Parameters["@IdConcretera"].Value = (cmbConcretera.SelectedValue.ToString() == "Todas" ? "%" : cmbConcretera.SelectedValue); * sqlDADatos.SelectCommand.Parameters["@IdPlanta"].Value = cmbPlanta.SelectedValue.ToString(); * sqlDADatos.Fill(dsDatos1, "InfDistribucion"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 1; * sqlDADatos.Fill(dsDatos1, "Total"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 2; * sqlDADatos.Fill(dsDatos1, "Media"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 3; * sqlDADatos.Fill(dsDatos1, "Erre"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 4; * sqlDADatos.Fill(dsDatos1, "Semanal"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 5; * sqlDADatos.Fill(dsGraDis1, "Estadisticos"); * sqlDADatos.SelectCommand.Parameters["@IdReporte"].Value = 6; * sqlDADatos.Fill(dsDatos1, "Barra"); * } * else * {*/ cryInfGrDiCo1.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; cryInfGrDiCo1.SetDataSource(dsGraDis1); sqlDADatosT.SelectCommand.Parameters["@IdObra"].Value = txtIdobra.Text; sqlDADatosT.SelectCommand.Parameters["@FechaIni"].Value = dtpIni.Text; sqlDADatosT.SelectCommand.Parameters["@FechaFin"].Value = dtpFin.Text; sqlDADatosT.SelectCommand.Parameters["@TipoCon"].Value = cmbTipo.SelectedValue; sqlDADatosT.SelectCommand.Parameters["@IdUnidad"].Value = cmbUnidad.SelectedValue; sqlDADatosT.SelectCommand.Parameters["@Inc7aEE"].Value = textBox4.Text; sqlDADatosT.SelectCommand.Parameters["@Inc3aEE"].Value = textBox3.Text; sqlDADatosT.SelectCommand.Parameters["@Inc1aEE"].Value = textBox2.Text; sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 0; sqlDADatosT.SelectCommand.Parameters["@IdConcretera"].Value = (cmbConcretera.SelectedValue.ToString() == "Todas" ? "%" : cmbConcretera.SelectedValue); sqlDADatosT.SelectCommand.Parameters["@IdPlanta"].Value = cmbPlanta.SelectedValue.ToString(); sqlDADatosT.Fill(dsDatos1, "InfDistribucion"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 1; sqlDADatosT.Fill(dsDatos1, "Total"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 2; sqlDADatosT.Fill(dsDatos1, "Media"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 3; sqlDADatosT.Fill(dsDatos1, "Erre"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 4; sqlDADatosT.Fill(dsDatos1, "Semanal"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 5; sqlDADatosT.Fill(dsGraDis1, "Estadisticos"); sqlDADatosT.SelectCommand.Parameters["@IdReporte"].Value = 6; sqlDADatosT.Fill(dsDatos1, "Barra"); //} int renDatos = dsDatos1.InfDistribucion.Rows.Count; col = renm = ren28 = ren07 = ren03 = ren01 = 0; int d1ant = int.Parse(dsDatos1.InfDistribucion.Rows[0]["d1"].ToString()); for (int i = 0; i < 45; i++) { ren[i] = 0; } for (int i = 0; i < renDatos; i++) { d1 = int.Parse(dsDatos1.InfDistribucion.Rows[i]["d1"].ToString()); if (d1 == d1ant) { dia = int.Parse(dsDatos1.InfDistribucion.Rows[i]["Dia"].ToString()); if (dia > 6 && dia < 14) { dia = dia - 1; } else if (dia > 13 && dia < 21) { dia = dia - 2; } else if (dia > 20 && dia < 28) { dia = dia - 3; } else if (dia > 27 && dia < 35) { dia = dia - 4; } datos[ren[dia], 35] = d1; datos[ren[dia]++, dia] = double.Parse(dsDatos1.InfDistribucion.Rows[i]["Resul"].ToString()); } else { renm = ren[0]; for (int j = 0; j < 35; j++) { if (renm < ren[j]) { renm = ren[j]; } } datos[renm, 35] = d1ant; ren28 = (d1ant >= 14 ? renm : ren28); ren07 = (d1ant == 07 ? renm : ren07); ren03 = (d1ant == 03 ? renm : ren03); ren01 = (d1ant == 01 ? renm : ren01); renm = renm + 4; for (int j = 0; j < 35; j++) { ren[j] = renm; } d1ant = d1; dia = int.Parse(dsDatos1.InfDistribucion.Rows[i]["Dia"].ToString()); if (dia > 6 && dia < 14) { dia = dia - 1; } else if (dia > 13 && dia < 21) { dia = dia - 2; } else if (dia > 20 && dia < 28) { dia = dia - 3; } else if (dia > 27 && dia < 35) { dia = dia - 4; } datos[ren[dia], 35] = d1; datos[ren[dia]++, dia] = double.Parse(dsDatos1.InfDistribucion.Rows[i]["Resul"].ToString()); } renm = ren[0]; for (int j = 0; j < 35; j++) { if (renm < ren[j]) { renm = ren[j]; } } datos[renm, 35] = d1ant; ren28 = (d1ant >= 14 ? renm : ren28); ren07 = (d1ant == 07 ? renm : ren07); ren03 = (d1ant == 03 ? renm : ren03); ren01 = (d1ant == 01 ? renm : ren01); } renDatos = dsDatos1.Media.Rows.Count; for (int i = 0; i < renDatos; i++) { d2 = d1 = int.Parse(dsDatos1.Media.Rows[i]["d1"].ToString()); if (d1 >= 14) { d1 = ren28; } else if (d1 == 07) { d1 = ren07; } else if (d1 == 03) { d1 = ren03; } else if (d1 == 01) { d1 = ren01; } dia = int.Parse(dsDatos1.Media.Rows[i]["Dia"].ToString()); if (dia > 6 && dia < 14) { dia = dia - 1; } else if (dia > 13 && dia < 21) { dia = dia - 2; } else if (dia > 20 && dia < 28) { dia = dia - 3; } else if (dia > 27 && dia < 35) { dia = dia - 4; } datos[d1 + 1, 35] = d2; datos[d1 + 1, dia] = double.Parse(dsDatos1.Media.Rows[i]["Resul"].ToString()); } ren01 = (ren01 == 0 ? 40 : ren01); renDatos = dsDatos1.Semanal.Rows.Count; for (int i = 0; i < renDatos; i++) { d2 = d1 = int.Parse(dsDatos1.Semanal.Rows[i]["d1"].ToString()); if (d1 >= 14) { d1 = ren28; } else if (d1 == 07) { d1 = ren07; } else if (d1 == 03) { d1 = ren03; } else if (d1 == 01) { d1 = ren01; } dia = int.Parse(dsDatos1.Semanal.Rows[i]["Dia"].ToString()); if (dia <= 6) { dia = 5; } else if (dia > 6 && dia < 14) { dia = 11; } else if (dia > 13 && dia < 21) { dia = 17; } else if (dia > 20 && dia < 28) { dia = 23; } else if (dia > 27 && dia < 35) { dia = 29; } datos[d1 + 2, 35] = d2; datos[d1 + 2, dia] = double.Parse(dsDatos1.Semanal.Rows[i]["Resul"].ToString()); } renDatos = dsDatos1.Erre.Rows.Count; for (int i = 0; i < renDatos; i++) { d2 = d1 = int.Parse(dsDatos1.Erre.Rows[i]["d1"].ToString()); if (d1 >= 14) { d1 = ren28; } else if (d1 == 07) { d1 = ren07; } else if (d1 == 03) { d1 = ren03; } else if (d1 == 01) { d1 = ren01; } dia = int.Parse(dsDatos1.Erre.Rows[i]["Dia"].ToString()); if (dia > 6 && dia < 14) { dia = dia - 1; } else if (dia > 13 && dia < 21) { dia = dia - 2; } else if (dia > 20 && dia < 28) { dia = dia - 3; } else if (dia > 27 && dia < 35) { dia = dia - 4; } datos[d1 + 3, 35] = d2; datos[d1 + 3, dia] = double.Parse(dsDatos1.Erre.Rows[i]["Resul"].ToString()); } for (int i = 0; i < 34; i++) { suma = 0; for (int j = 0; j < 34; j++) { suma = suma + datos[i, j]; } if (datos[i, 35] >= 14) { Etiqueta = "Edad especificada"; } else if (datos[i, 35] == 7) { Etiqueta = "7 días"; } else if (datos[i, 35] == 3) { Etiqueta = "3 días"; } else if (datos[i, 35] == 1) { Etiqueta = "1 día"; } Titulo = "n"; // System.Convert.ToString(i + 1); if (suma > 0) { // if (i == (ren28 == 0 ? 90 : ren28) + 1 || i == ren07 + 1 || i == ren03 + 1 || i == ren01 + 1) // Titulo = "TOTAL"; if (i == (ren28 == 0 ? 90 : ren28) + 1 || i == ren07 + 1 || i == ren03 + 1 || i == ren01 + 1) { Titulo = "Media"; } if (i == (ren28 == 0 ? 90 : ren28) + 2 || i == ren07 + 2 || i == ren03 + 2 || i == ren01 + 2) { Titulo = "Media Semanal"; } if (i == (ren28 == 0 ? 90 : ren28) + 3 || i == ren07 + 3 || i == ren03 + 3 || i == ren01 + 3) { Titulo = "R"; } dsGraDis1.Gradis.AddGradisRow(i.ToString(), datos[i, 0], datos[i, 1], datos[i, 2], datos[i, 3], datos[i, 4], datos[i, 5], datos[i, 6], datos[i, 7], datos[i, 8], datos[i, 9], datos[i, 10], datos[i, 11], datos[i, 12], datos[i, 13], datos[i, 14], datos[i, 15], datos[i, 16], datos[i, 17], datos[i, 18], datos[i, 19], datos[i, 20], datos[i, 21], datos[i, 22], datos[i, 23], datos[i, 24], datos[i, 25], datos[i, 26], datos[i, 27], datos[i, 28], datos[i, 29], datos[i, 30], Etiqueta.Trim(), Titulo); if (i == ren28 + 1 && ren28 != 0) { for (int j = 0; j < 30; j++) { ua[j] = datos[i, j]; } } if (i == ren07 + 1 && ren07 != 0) { for (int j = 0; j < 30; j++) { va[j] = datos[i, j]; } } if (i == ren07 + 3 && ren07 != 0) { for (int j = 0; j < 30; j++) { za[j] = datos[i, j]; } } if (i == ren03 + 1 && ren03 != 0) { for (int j = 0; j < 30; j++) { wa[j] = datos[i, j]; } } if (i == ren01 + 1 && ren01 != 0) { for (int j = 0; j < 30; j++) { ya[j] = datos[i, j]; } } } } DateTime dias = dtpIni.Value; int dmes = 0; for (int i = 0; i < 35; i++) { if (dias.AddDays(i).DayOfWeek.ToString() != DayOfWeek.Sunday.ToString()) { dic[dmes++] = dias.AddDays(i).Day; } } dsGraDis1.Dias.AddDiasRow(dic[0], dic[1], dic[2], dic[3], dic[4], dic[5], dic[6], dic[7], dic[8], dic[9], dic[10], dic[11], dic[12], dic[13], dic[14], dic[15], dic[16], dic[17], dic[18], dic[19], dic[20], dic[21], dic[22], dic[23], dic[24], dic[25], dic[26], dic[27], dic[28], dic[29]); memGraphics.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); myPane = new GraphPane(new Rectangle(10, 10, 10, 10), "CARTA DE CONTROL Y DISTRIBUCIÓN DE FRECUENCIAS", "", ""); SetSize(); for (int j = 0; j < 30; j++) { xa[j] = j + 1; } CurveItem curve; curve = myPane.AddCurve("E. E:", xa, ua, Color.Black, SymbolType.Circle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Black); for (int j = 29; j >= 0; j--) { if (ua[j] == 0) { curve.Points.Remove(j); } } curve = myPane.AddCurve("7 días", xa, va, Color.Blue, SymbolType.Circle); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.White); for (int j = 29; j >= 0; j--) { if (va[j] == 0) { curve.Points.Remove(j); } } curve = myPane.AddCurve("3 días", xa, wa, Color.Brown, SymbolType.Square); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.Red); for (int j = 29; j >= 0; j--) { if (wa[j] == 0) { curve.Points.Remove(j); } } curve = myPane.AddCurve("1 día", xa, ya, Color.DarkRed, SymbolType.Square); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 8; for (int j = 29; j >= 0; j--) { if (ya[j] == 0) { curve.Points.Remove(j); } } curve = myPane.AddCurve("R", xa, za, Color.DarkMagenta, SymbolType.Star); curve.Line.Width = 1.0F; curve.Symbol.Fill = new Fill(Color.DarkMagenta); curve.Line.Style = System.Drawing.Drawing2D.DashStyle.DashDot; curve.IsY2Axis = true; for (int j = 29; j >= 0; j--) { if (za[j] == 0) { curve.Points.Remove(j); } } // curve.Line.IsSmooth = true; xaa[0] = 0; xaa[1] = 30; C200[0] = 200; C200[1] = 200; curve = myPane.AddCurve("C200", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 2.5F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; C200[0] = 230; C200[1] = 230; curve = myPane.AddCurve("C230", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; C200[0] = 260; C200[1] = 260; curve = myPane.AddCurve("C260", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 2.5F; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; C200[0] = 40; C200[1] = 40; curve = myPane.AddCurve("C040", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 1.0F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; curve.IsY2Axis = true; xaa[0] = 6.5; xaa[1] = 6.5; C200[0] = 100; C200[1] = 300; curve = myPane.AddCurve("C6.5", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 4.0F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; xaa[0] = 12.5; xaa[1] = 12.5; C200[0] = 100; C200[1] = 300; curve = myPane.AddCurve("C13.5", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 4.0F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; xaa[0] = 18.5; xaa[1] = 18.5; C200[0] = 100; C200[1] = 300; curve = myPane.AddCurve("C20.5", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 4.0F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; xaa[0] = 24.5; xaa[1] = 24.5; C200[0] = 100; C200[1] = 300; curve = myPane.AddCurve("C13.5", xaa, C200, Color.Black, SymbolType.Empty); curve.Line.Width = 4.0F; curve.Line.Style = System.Drawing.Drawing2D.DashStyle.Solid; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.FrameColor = Color.White; myPane.Y2Axis.IsShowGrid = true; myPane.Y2Axis.Step = 10; myPane.Y2Axis.Min = min; myPane.Y2Axis.Max = 200; myPane.Y2Axis.IsVisible = true; myPane.Y2Axis.ScaleFontSpec.Size = 6; myPane.XAxis.IsShowGrid = true; myPane.XAxis.IsTic = true; myPane.XAxis.ScaleFontSpec.Angle = 0; myPane.XAxis.Min = 0; myPane.XAxis.Max = 30; myPane.XAxis.IsVisible = false; myPane.YAxis.IsShowGrid = true; myPane.YAxis.ScaleFontSpec.Angle = 90; myPane.YAxis.Min = 100; myPane.YAxis.Max = 300; // myPane.YAxis.MaxAuto = true; myPane.Legend.IsVisible = false; myPane.PaneFill = new Fill(Color.White, Color.White, 0F); myPane.AxisChange(this.CreateGraphics()); pictureBox1.Image = Image.FromHbitmap(myPane.Image.GetHbitmap()); MemoryStream ms = new MemoryStream(); pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); byte[] arrImage = ms.GetBuffer(); ms.Close(); myPane.Image.Dispose(); pictureBox1.Image.Dispose(); dsGraDis1.Grafica.AddGraficaRow(arrImage); memGraphics1.CreateDoubleBuffer(this.CreateGraphics(), this.ClientRectangle.Width, this.ClientRectangle.Height); myPane1 = new GraphPane(new Rectangle(10, 10, 10, 10), " ", "", ""); SetSize1(); renDatos = dsDatos1.Barra.Rows.Count; double[] xxa = new double[renDatos]; double[] yya = new double[renDatos]; for (int i = 0; i < renDatos; i++) { xxa[i] = double.Parse(dsDatos1.Barra.Rows[i][0].ToString()); yya[i] = double.Parse(dsDatos1.Barra.Rows[i][1].ToString()); } CurveItem curve1; curve1 = myPane1.AddBar("Cantidad", yya, xxa, Color.Black); curve1.Bar.FrameWidth = 12.0F; curve1.Symbol.Fill = new Fill(Color.Black); myPane1.BarBase = BarBase.Y; myPane1.XAxis.IsShowGrid = true; myPane1.XAxis.ScaleFontSpec.Angle = 0; myPane1.XAxis.Min = 0; myPane1.XAxis.Max = 30; myPane1.XAxis.MaxAuto = true; myPane1.XAxis.ScaleFontSpec.Size = 30; myPane1.XAxis.IsVisible = false; myPane1.XAxis.IsShowGrid = true; myPane1.YAxis.IsShowGrid = true; myPane1.YAxis.ScaleFontSpec.Angle = 90; myPane1.YAxis.Min = 100; myPane1.YAxis.Max = 300; // myPane1.YAxis.MaxAuto = true; myPane1.YAxis.IsVisible = false; myPane1.Legend.IsVisible = false; // myPane.YAxis.ScaleFontSpec.Size = 10; myPane1.PaneFill = new Fill(Color.White, Color.White, 0F); myPane1.AxisChange(this.CreateGraphics()); pictureBox2.Image = Image.FromHbitmap(myPane1.Image.GetHbitmap()); pictureBox2.Image.RotateFlip(RotateFlipType.RotateNoneFlipX); MemoryStream ms1 = new MemoryStream(); pictureBox2.Image.Save(ms1, System.Drawing.Imaging.ImageFormat.Bmp); byte[] arrImage1 = ms1.GetBuffer(); ms1.Close(); myPane1.Image.Dispose(); pictureBox2.Image.Dispose(); dsGraDis1.Barras.AddBarrasRow(arrImage1); crvGraDis.Visible = true; cryInfGrDiCo1.SetParameterValue("@Tip", dsTipo1.Tables[0].Rows[cmbTipo.SelectedIndex][1].ToString()); cryInfGrDiCo1.SetParameterValue("@Rev", 0); cryInfGrDiCo1.SetParameterValue("@Fecha", dtpIni.Value.AddDays(20)); cryInfGrDiCo1.SetParameterValue("@Resistencias", txtResis1.Text.Trim() + " " + txtResis2.Text.Trim() + " " + txtResis3.Text.Trim() + " " + txtResis4.Text.Trim()); cryInfGrDiCo1.SetParameterValue("@Resis1", txtResis1.Text.Trim()); cryInfGrDiCo1.SetParameterValue("@Resis2", txtResis2.Text.Trim()); cryInfGrDiCo1.SetParameterValue("@Resis3", txtResis3.Text.Trim()); cryInfGrDiCo1.SetParameterValue("@Resis4", txtResis4.Text.Trim()); cryInfGrDiCo1.SetParameterValue("Inc15EE", txtLan15EE.Text); cryInfGrDiCo1.SetParameterValue("Inc1507", txtLan1507.Text); cryInfGrDiCo1.SetParameterValue("Inc1503", txtLan1503.Text); cryInfGrDiCo1.SetParameterValue("Inc1501", txtLan1501.Text); cryInfGrDiCo1.SetParameterValue("Inc20EE", txtLan20EE.Text); cryInfGrDiCo1.SetParameterValue("Inc2007", txtLan2007.Text); cryInfGrDiCo1.SetParameterValue("Inc2003", txtLan2003.Text); cryInfGrDiCo1.SetParameterValue("Inc2001", txtLan2001.Text); cryInfGrDiCo1.SetParameterValue("Inc25EE", txtLan25EE.Text); cryInfGrDiCo1.SetParameterValue("Inc2507", txtLan2507.Text); cryInfGrDiCo1.SetParameterValue("Inc2503", txtLan2503.Text); cryInfGrDiCo1.SetParameterValue("Inc2501", txtLan2501.Text); cryInfGrDiCo1.SetParameterValue("Inc30EE", txtLan30EE.Text); cryInfGrDiCo1.SetParameterValue("Inc3007", txtLan3007.Text); cryInfGrDiCo1.SetParameterValue("Inc3003", txtLan3003.Text); cryInfGrDiCo1.SetParameterValue("Inc3001", txtLan3001.Text); cryInfGrDiCo1.SetParameterValue("@Lab", chbLab.Checked); cryInfGrDiCo1.SetParameterValue("@Con", cmbConcretera.Text); cryInfGrDiCo1.SetParameterValue("@Pla", cmbPlanta.Text); cryInfGrDiCo1.SetParameterValue("@IdObra", txtIdobra.Text); crvGraDis.ReportSource = cryInfGrDiCo1; // crvGraDis.RefreshReport(); }
/// <summary> /// Place the previously saved states of the GraphPanes on the individual GraphPane /// <see cref="ZeeGraph.GraphPane.ZoomStack" /> collections. This provides for an /// option to undo the state change at a later time. Save a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> /// <returns>The <see cref="ZoomState" /> that corresponds to the /// <see paramref="primaryPane" />. /// </returns> private void ZoomStatePush(GraphPane primaryPane) { if (_isSynchronizeXAxes || _isSynchronizeYAxes) { for (int i = 0; i < _masterPane._paneList.Count; i++) { if (i < _zoomStateStack.Count) _masterPane._paneList[i].ZoomStack.Add(_zoomStateStack[i]); } } else if (_zoomState != null) primaryPane.ZoomStack.Add(_zoomState); ZoomStateClear(); }
public void PrintLines(double[] x, double[,] y, ZedGraphControl zedGraphControl1) { Color[] colors = new Color[10]; colors[0] = Color.Green; colors[1] = Color.Blue; colors[2] = Color.Red; colors[3] = Color.Black; colors[4] = Color.Orange; colors[5] = Color.Pink; colors[6] = Color.Silver; colors[7] = Color.Yellow; colors[8] = Color.Purple; colors[9] = Color.RoyalBlue; zedGraphControl1.GraphPane.CurveList.Clear(); GraphPane myPane = zedGraphControl1.GraphPane; PointPairList[] spl = new PointPairList[N + M + 1]; LineItem[] myCurve = new LineItem[N + M + 1]; double[] K1, K2, K3, K4; double h = 0.001; double hstat = 0.1; double sumdelta, delta; double t = 0; double[] Pk_tstring = new double[M + N + 1]; int delt = 0; for (int j = 0; j <= N + M; j++) { if (j == 0) { Pk_tstring[j] = 1; spl[j] = new PointPairList(); spl[j].Add(t, 1); } else { Pk_tstring[j] = 0; spl[j] = new PointPairList(); spl[j].Add(t, 0); } } double statsum = 0; do { K1 = f(Pk_tstring); K2 = f(VectAM(Pk_tstring, K1, h / 2)); K3 = f(VectAM(Pk_tstring, K2, h / 2)); K4 = f(VectAM(Pk_tstring, K3, h)); t += h; if (statsum + h < hstat) { statsum += h; } else { statsum = 0; } sumdelta = 0; for (int j = 0; j <= N + M; j++) { delta = h * (K1[j] + 2 * K2[j] + 2 * K3[j] + K4[j]) / 6; sumdelta += Math.Abs(delta); Pk_tstring[j] += delta; spl[j].Add(t, Pk_tstring[j]); } if (statsum == 0) { delt++; } }while ((t < 100) && (sumdelta > (h / 10))); for (int j = 0; j <= N + M; j++) { string name = "P[" + j + "]"; myCurve[j] = myPane.AddCurve(name, spl[j], colors[j % 10], SymbolType.None); myCurve[j].Line.Width = 1.5F; } zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); }
/// <summary> /// Save the current states of the GraphPanes to a separate collection. Save a single /// (<see paramref="primaryPane" />) GraphPane if the panes are not synchronized /// (see <see cref="IsSynchronizeXAxes" /> and <see cref="IsSynchronizeYAxes" />), /// or save a list of states for all GraphPanes if the panes are synchronized. /// </summary> /// <param name="primaryPane">The primary GraphPane on which zoom/pan/scroll operations /// are taking place</param> /// <param name="type">The <see cref="ZoomState.StateType" /> that describes the /// current operation</param> /// <returns>The <see cref="ZoomState" /> that corresponds to the /// <see paramref="primaryPane" />. /// </returns> private ZoomState ZoomStateSave(GraphPane primaryPane, ZoomState.StateType type) { ZoomStateClear(); if (_isSynchronizeXAxes || _isSynchronizeYAxes) { foreach (GraphPane pane in _masterPane._paneList) { ZoomState state = new ZoomState(pane, type); if (pane == primaryPane) _zoomState = state; _zoomStateStack.Add(state); } } else _zoomState = new ZoomState(primaryPane, type); return _zoomState; }
/****************************************************************/ private string ValueAxisScaleFormatHandler(GraphPane pane, Axis axis, double val, int index) { //return val.ToString("g"); return(val.ToString("g")); }
/// <summary> /// Y轴显示格式 /// </summary> /// <param name="pane"></param> /// <param name="axis"></param> /// <param name="val"></param> /// <param name="index"></param> /// <returns></returns> private string YAxis_ScaleFormatEvent(GraphPane pane, Axis axis, double val, int index) { //根据 val值 返回你需要的 string return(Comm.ConvertIntDateTime(val * 1000).ToString("yyyy/MM/dd HH:mm:ss")); }
private void CreateGraph(ZedGraphControl zgc) { this.Cursor = Cursors.WaitCursor; pointlist.Clear(); try { myPane = zgc.GraphPane; // Set the Titles if (grSettings.GraphType.Equals(GraphTypes.ParametricFamily) || grSettings.GraphType.Equals(GraphTypes.ParametricFunction)) { myPane.Title.Text = grSettings.GraphType + ": (" + grSettings.FunctionA + ", " + grSettings.FunctionB + ")"; } else { myPane.Title.Text = grSettings.GraphType + ": " + grSettings.FunctionA; } myPane.Chart.Fill.Type = FillType.Solid; myPane.Chart.Fill.Color = grSettings.Background; OppositeGraphColor = Color.FromArgb(255 - grSettings.Background.R, 255 - grSettings.Background.G, 255 - grSettings.Background.B); if (grSettings.GraphType.Equals(GraphTypes.Function)) { CreateGraphOfFunction(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.Derivative)) { CreateGraphOfDerivative(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.VectorField)) { CreateGraphOfVectorField(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.LevelCurves)) { CreateGraphOfLevelCurves(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.LevelCurves2)) { CreateGraphOfLevelCurves(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.ParametricFunction)) { CreateGraphOfParametricFunction(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.ParametricFamily)) { CreateGraphOfParametricFamily(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.Slope)) { CreateGraphOfSlope(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.Iteration)) { CreateGraphOfIteration(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.Cobweb)) { CreateGraphOfCobweb(zgc); } else if (grSettings.GraphType.Equals(GraphTypes.TwoDIteration)) { CreateGraphOf2DIteration(zgc); } // Tell ZedGraph to refigure the axes since the data have changed zgc.AxisChange(); if (grSettings.Grid) { myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; myPane.XAxis.Color = Color.FromArgb(255 - grSettings.Background.R, 255 - grSettings.Background.G, 255 - grSettings.Background.B); myPane.XAxis.MajorGrid.Color = Color.FromArgb(255 - grSettings.Background.R, 255 - grSettings.Background.G, 255 - grSettings.Background.B); myPane.YAxis.Color = Color.FromArgb(255 - grSettings.Background.R, 255 - grSettings.Background.G, 255 - grSettings.Background.B); myPane.YAxis.MajorGrid.Color = Color.FromArgb(255 - grSettings.Background.R, 255 - grSettings.Background.G, 255 - grSettings.Background.B); } else { myPane.XAxis.MajorGrid.IsVisible = false; myPane.YAxis.MajorGrid.IsVisible = false; } this.Cursor = Cursors.Default; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void CreateGraph_3panes(ZedGraphControl zgc) { // First, clear out any old GraphPane's from the MasterPane collection MasterPane master = zgc.MasterPane; master.PaneList.Clear(); // Display the MasterPane Title, and set the outer margin to 10 points master.Title.IsVisible = true; master.Title.Text = "Color Analysis"; master.Margin.All = 10; // Create some GraphPane's (normally you would add some curves too GraphPane rgbPane = new GraphPane(); GraphPane hPane = new GraphPane(); GraphPane siPane = new GraphPane(); // Add all the GraphPanes to the MasterPane master.Add(rgbPane); master.Add(hPane); master.Add(siPane); //rgbPane.XAxis.Title.Text = "Value"; rgbPane.XAxis.Scale.Min = 0; rgbPane.XAxis.Scale.Max = 255; rgbPane.XAxis.Scale.FontSpec.Size += 8; rgbPane.YAxis.Title.Text = "Frequency"; rgbPane.YAxis.Title.FontSpec.Size += 10; rgbPane.YAxis.Scale.FontSpec.Size += 8; rgbPane.Legend.FontSpec.Size += 10; hPane.XAxis.Scale.Min = 0; hPane.XAxis.Scale.Max = 360; hPane.XAxis.Scale.MajorStep = 60; hPane.XAxis.Scale.FontSpec.Size += 8; hPane.YAxis.Title.Text = "Frequency"; hPane.YAxis.Title.FontSpec.Size += 10; hPane.YAxis.Scale.FontSpec.Size += 8; hPane.Legend.FontSpec.Size += 10; siPane.XAxis.Scale.Min = 0; siPane.XAxis.Scale.Max = 100; siPane.XAxis.Scale.FontSpec.Size += 8; siPane.YAxis.Title.Text = "Frequency"; siPane.YAxis.Scale.FontSpec.Size += 10; siPane.YAxis.Title.FontSpec.Size += 8; siPane.Legend.FontSpec.Size += 10; LineItem myRCurve = rgbPane.AddCurve("Red", rList, Color.Red, SymbolType.Diamond); LineItem myGCurve = rgbPane.AddCurve("Green", gList, Color.Green, SymbolType.Diamond); LineItem myBCurve = rgbPane.AddCurve("Blue", bList, Color.Blue, SymbolType.Diamond); LineItem myHCurve = hPane.AddCurve("Hue", hList, Color.Cyan, SymbolType.Circle); LineItem mySCurve = siPane.AddCurve("Saturation", sList, Color.Magenta, SymbolType.Circle); LineItem myICurve = siPane.AddCurve("Intensity", iList, Color.YellowGreen, SymbolType.Circle); // Layout the GraphPanes using a default Pane Layout using (Graphics g = this.CreateGraphics()) { master.SetLayout(g, PaneLayout.SingleColumn); } }
public void MasterPaneAddGraph(GraphPane graphPane) { this.masterPane.Add(graphPane); }
private void SetGraph() { GraphPane pane1 = zedGraph_Light.GraphPane; GraphPane pane2 = zedGraph_Temperature.GraphPane; /// 设置标题 pane1.Title.Text = "光照强度"; pane1.XAxis.Title.Text = "时间/秒"; pane1.YAxis.Title.Text = "光强"; pane2.Title.Text = "温度"; pane2.XAxis.Title.Text = "时间/秒"; pane2.YAxis.Title.Text = "温度/°C"; /// 设置数据列表包含1200个点,每50毫秒更新一次,恰好检测1分钟 RollingPointPairList list1 = new RollingPointPairList(1200); RollingPointPairList list2 = new RollingPointPairList(1200); /// 根据数据列表添加折线 LineItem curve1 = pane1.AddCurve("光强", list1, System.Drawing.Color.YellowGreen, SymbolType.None); LineItem curve2 = pane2.AddCurve("温度", list2, System.Drawing.Color.Red, SymbolType.None); ///坐标轴属性 pane1.YAxis.IsVisible = true; pane1.YAxis.Scale.Min = -5.0; pane1.YAxis.Scale.Max = 5.0; pane1.YAxis.Scale.Align = AlignP.Inside; pane1.YAxis.Scale.MaxAuto = false; pane1.YAxis.Scale.MinAuto = false; pane2.YAxis.IsVisible = true; pane2.YAxis.Scale.Min = -5.0; pane2.YAxis.Scale.Max = 30.0; pane2.YAxis.Scale.Align = AlignP.Inside; pane2.YAxis.Scale.MaxAuto = false; pane2.YAxis.Scale.MinAuto = false; /// X 轴最小值 0 pane1.XAxis.Scale.Min = 0; pane1.XAxis.Scale.MaxGrace = 0.01; pane1.XAxis.Scale.MinGrace = 0.01; pane2.XAxis.Scale.Min = 0; pane2.XAxis.Scale.MaxGrace = 0.01; pane2.XAxis.Scale.MinGrace = 0.01; /// X轴最大30 pane1.XAxis.Scale.Max = 30; pane2.XAxis.Scale.Max = 30; /// X轴小步长1,也就是小间隔 pane1.XAxis.Scale.MinorStep = 1; pane2.XAxis.Scale.MinorStep = 1; /// X轴大步长为5,也就是显示文字的大间隔 pane1.XAxis.Scale.MajorStep = 5; pane2.XAxis.Scale.MajorStep = 5; ///保存开始时间 tickStart = Environment.TickCount; /// Scale the axes /// 改变轴的刻度 zedGraph_Light.AxisChange(); zedGraph_Temperature.AxisChange(); }
private string zedGraphControl1_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt) { PointValueEventPrice(curve, iPt); return(default(string)); }
string XAxis_ScaleFormatEvent(GraphPane pane, Axis axis, double val, int index) { return (string.Format("{0}:{1}", (int)(val / 60), (val % 60).ToString("00"))); }
public ZedGraphSilacProteinScan(ZedGraphControl zgcGraph, GraphPane panel, string title) : base(zgcGraph, panel, title) { this.RegressionLineColor = Color.Red; }
/// <summary> /// Handler for the "Undo All Zoom/Pan" context menu item. Restores the scale ranges to the values /// before all zoom and pan operations /// </summary> /// <remarks> /// This method differs from the <see cref="RestoreScale" /> method in that it sets the scales /// to their initial setting prior to any user actions. The <see cref="RestoreScale" /> method /// sets the scales to full auto mode (regardless of what the initial setting may have been). /// </remarks> /// <param name="primaryPane">The <see cref="GraphPane" /> object which is to be zoomed out</param> public void ZoomOutAll( GraphPane primaryPane ) { if ( primaryPane != null && !primaryPane.ZoomStack.IsEmpty ) { ZoomState.StateType type = primaryPane.ZoomStack.Top.Type; ZoomState oldState = new ZoomState( primaryPane, type ); //ZoomState newState = pane.ZoomStack.PopAll( pane ); ZoomState newState = null; if ( _isSynchronizeXAxes || _isSynchronizeYAxes ) { foreach ( GraphPane pane in _masterPane._paneList ) { ZoomState state = pane.ZoomStack.PopAll( pane ); if ( pane == primaryPane ) newState = state; } } else newState = primaryPane.ZoomStack.PopAll( primaryPane ); // Provide Callback to notify the user of zoom events if ( this.ZoomEvent != null ) this.ZoomEvent( this, oldState, newState ); Refresh(); } }
/// <summary> /// Go through the collection, and hide (filter out) any points that fall on the /// same pixel location as a previously included point. /// </summary> /// <remarks> /// This method does not delete any points, it just temporarily hides them until /// the next call to <see c_ref="FilterData" /> or <see c_ref="ClearFilter" />. /// You should call <see c_ref="FilterData" /> once your collection of points has /// been constructed. You may need to call <see c_ref="FilterData" /> again if /// you add points, or if the chart rect changes size (by resizing, printing, /// image save, etc.), or if the scale range changes. /// You must call <see c_ref="GraphPane.AxisChange()" /> before calling /// this method so that the <see c_ref="Chart.Rect">GraphPane.Chart.Rect</see> /// and the scale ranges are valid. This method is not valid for /// ordinal axes (but ordinal axes don't make sense for very large datasets /// anyway). /// </remarks> /// <param name="pane">The <see c_ref="GraphPane" /> into which the data /// will be plotted. </param> /// <param name="yAxis">The <see c_ref="Axis" /> class to be used in the Y direction /// for plotting these data. This can be a <see c_ref="YAxis" /> or a /// <see c_ref="Y2Axis" />, and can be a primary or secondary axis (if multiple Y or Y2 /// axes are being used). /// </param> /// <param name="xAxis">The <see c_ref="Axis" /> class to be used in the X direction /// for plotting these data. This can be an <see c_ref="XAxis" /> or a /// <see c_ref="X2Axis" />. /// </param> public void FilterData(GraphPane pane, Axis xAxis, Axis yAxis) { if (_visibleIndicies == null || _visibleIndicies.Length < base.Count) { _visibleIndicies = new int[base.Count]; } _filteredCount = 0; _isFiltered = true; int width = (int)pane.Chart.Rect.Width; int height = (int)pane.Chart.Rect.Height; if (width <= 0 || height <= 0) { throw new IndexOutOfRangeException("Error in FilterData: Chart rect not valid"); } bool[,] usedArray = new bool[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { usedArray[i, j] = false; } } xAxis.Scale.SetupScaleData(pane, xAxis); yAxis.Scale.SetupScaleData(pane, yAxis); int n = _filterMode < 0 ? 0 : _filterMode; int left = (int)pane.Chart.Rect.Left; int top = (int)pane.Chart.Rect.Top; for (int i = 0; i < base.Count; i++) { DataPoint dp = base[i]; int x = (int)(xAxis.Scale.Transform(dp.X) + 0.5) - left; int y = (int)(yAxis.Scale.Transform(dp.Y) + 0.5) - top; if (x >= 0 && x < width && y >= 0 && y < height) { bool used = false; if (n <= 0) { used = usedArray[x, y]; } else { for (int ix = x - n; ix <= x + n; ix++) { for (int iy = y - n; iy <= y + n; iy++) { used |= (ix >= 0 && ix < width && iy >= 0 && iy < height && usedArray[ix, iy]); } } } if (!used) { usedArray[x, y] = true; _visibleIndicies[_filteredCount] = i; _filteredCount++; } } } }
private void ApplyToAllPanes( GraphPane primaryPane ) { foreach ( GraphPane pane in _masterPane._paneList ) { if ( pane != primaryPane ) { if ( _isSynchronizeXAxes ) Synchronize( primaryPane.XAxis, pane.XAxis ); if ( _isSynchronizeYAxes ) Synchronize( primaryPane.YAxis, pane.YAxis ); } } }
//모드버스 40100,40101 addr read 후 그래프 출력 public void HRread() { try { int rate = Convert.ToInt32(textBox1.Text); while (threadrun) { if (listBox1.InvokeRequired) { listBox1.Invoke(new MethodInvoker(delegate() { int[] location = MBClient.ReadHoldingRegisters(100, 20); listBox1.Items.Clear(); foreach (int EA in location) { listBox1.Items.Add(EA); } })); } else { listBox1.Invoke(new MethodInvoker(delegate() { int[] location = MBClient.ReadHoldingRegisters(100, 20); listBox1.Items.Clear(); foreach (int EA in location) { listBox1.Items.Add(EA); } })); } if (chart1.InvokeRequired) { chart1.Invoke(new MethodInvoker(delegate() { int PTx, PTy; GraphPane gp = chart1.GraphPane; PointPairList list = new PointPairList(); for (int i = 0; i < 10; i++) { PTx = (int)listBox1.Items[0 + i]; PTy = (int)listBox1.Items[10 + i]; list.Add(PTx, PTy); } LineItem curve1 = gp.AddCurve("test", list, Color.Red, SymbolType.Circle); curve1.Symbol.Size = 2; curve1.Symbol.Fill.Type = FillType.Solid; curve1.Line.IsVisible = false; curve1.Label.IsVisible = false; chart1.AxisChange(); chart1.Invalidate(); chart1.Refresh(); })); } else { chart1.Invoke(new MethodInvoker(delegate() { int PTx, PTy; GraphPane gp = chart1.GraphPane; PointPairList list = new PointPairList(); for (int i = 0; i < 10; i++) { PTx = (int)listBox1.Items[0 + i]; PTy = (int)listBox1.Items[2 * i]; list.Add(PTx, PTy); } LineItem curve1 = gp.AddCurve("test", list, Color.Red, SymbolType.Circle); curve1.Symbol.Size = 2; curve1.Symbol.Fill.Type = FillType.Solid; curve1.Line.IsVisible = false; curve1.Label.IsVisible = false; chart1.AxisChange(); chart1.Invalidate(); chart1.Refresh(); })); } //주기 시간 설정 Thread.Sleep(rate); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Creates a new CurveItem using the PointPairList and add it the the given pane. /// </summary> /// <param name="pane">the GraphPane object to which to add the new curve</param> /// <param name="points">a PointPairList collection defining the points for this curve</param> /// <returns>the newly created CurveItem added to the given GraphPane</returns> /// <remarks>This method must be overriden by childs</remarks> public override CurveItem CreateInPane( GraphPane pane, PointPairList points ) { PieItem x = pane.AddPieSlice( this.Value, this.Color, this.Displacement, this.Label ); this.CopyTo( x ); return x; }
public void CreateChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Elevation above ground"; myPane.XAxis.Title.Text = "Distance (" + CurrentState.DistanceUnit + ")"; myPane.YAxis.Title.Text = "Elevation (" + CurrentState.AltUnit + ")"; LineItem myCurve; myCurve = myPane.AddCurve("Planned Path", list1, Color.Red, SymbolType.None); //myCurve = myPane.AddCurve("Google", list2, Color.Green, SymbolType.None); myCurve = myPane.AddCurve("DEM", list3, Color.Blue, SymbolType.None); foreach (PointPair pp in list1) { // Add a another text item to to point out a graph feature TextObj text = new TextObj((string)pp.Tag, pp.X, pp.Y); // rotate the text 90 degrees text.FontSpec.Angle = 90; text.FontSpec.FontColor = Color.White; // Align the text such that the Right-Center is at (700, 50) in user scale coordinates text.Location.AlignH = AlignH.Right; text.Location.AlignV = AlignV.Center; // Disable the border and background fill options for the text text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; myPane.GraphObjList.Add(text); } // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = distance * CurrentState.multiplierdist; // Make the Y axis scale red myPane.YAxis.Scale.FontSpec.FontColor = Color.Red; myPane.YAxis.Title.FontSpec.FontColor = Color.Red; // turn off the opposite tics so the Y tics don't show up on the Y2 axis myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; // Don't display the Y zero line myPane.YAxis.MajorGrid.IsZeroLine = true; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; // Manually set the axis range //myPane.YAxis.Scale.Min = -1; //myPane.YAxis.Scale.Max = 1; // Fill the axis background with a gradient //myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // Calculate the Axis Scale Ranges try { zg1.AxisChange(); } catch { } }
private void AddCurve( int pane, int curve ) { if ( pane > zedGraphControl1.MasterPane.PaneList.Count ) { throw ( new System.Exception( "You can only add a pane to the end of the list" ) ); } int i; if ( pane >= zedGraphControl1.MasterPane.PaneList.Count ) { GraphPane pane1 = new GraphPane(); zedGraphControl1.MasterPane.PaneList.Add( pane1 ); //Is this correct for the new layout? Graphics g = zedGraphControl1.CreateGraphics(); zedGraphControl1.MasterPane.DoLayout( g ); g.Dispose(); //New pane layout to refresh all the axes and filtered data //UpdateAxes(); //FilterAllCurves(); } //Create the data NoDupePointList ndp1 = new NoDupePointList(); for ( i = 0; i < NUMPOINTS; i++ ) { if ( ( curve & 1 ) == 0 ) ndp1.Add( i, -( NUMPOINTS / 2 ) + i ); else ndp1.Add( i, ( NUMPOINTS / 2 ) - i ); } //Create the curve zedGraphControl1.MasterPane.PaneList[pane].AddCurve( "ndp" + curve.ToString(), ndp1, Color.Red ); //New curve so update the axes and filtering for this pane UpdateAxes(); FilterCurves( pane ); }
public void CreateResultScatterplot(ZedGraphControl zgc, double[][] inputs, double[] expected, double[] output) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = columnNames[0]; myPane.YAxis.Title.Text = columnNames[1]; // Classification problem PointPairList list1 = new PointPairList(); // Z = 0, OK PointPairList list2 = new PointPairList(); // Z = 1, OK PointPairList list3 = new PointPairList(); // Z = 0, Error PointPairList list4 = new PointPairList(); // Z = 1, Error for (int i = 0; i < output.Length; i++) { if (output[i] == 0) { if (expected[i] == 0) { list1.Add(inputs[i][0], inputs[i][1]); } if (expected[i] == 1) { list3.Add(inputs[i][0], inputs[i][1]); } } else { if (expected[i] == 0) { list4.Add(inputs[i][0], inputs[i][1]); } if (expected[i] == 1) { list2.Add(inputs[i][0], inputs[i][1]); } } } // Add the curve LineItem myCurve = myPane.AddCurve("G1 Hits", list1, Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("G2 Hits", list2, Color.Green, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Green); myCurve = myPane.AddCurve("G1 Miss", list3, Color.Blue, SymbolType.Plus); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = true; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("G2 Miss", list4, Color.Green, SymbolType.Plus); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = true; myCurve.Symbol.Fill = new Fill(Color.Green); // Fill the background of the chart rect and pane //myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f); //myPane.Fill = new Fill(Color.White, Color.SlateGray, 45.0f); myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
/// <summary> /// Zoom a specified pane in or out according to the specified zoom fraction. /// </summary> /// <remarks> /// The zoom will occur on the <see cref="XAxis" />, <see cref="YAxis" />, and /// <see cref="Y2Axis" /> only if the corresponding flag, <see cref="IsEnableHZoom" /> or /// <see cref="IsEnableVZoom" />, is true. Note that if there are multiple Y or Y2 axes, all of /// them will be zoomed. /// </remarks> /// <param name="pane">The <see cref="GraphPane" /> instance to be zoomed.</param> /// <param name="zoomFraction">The fraction by which to zoom, less than 1 to zoom in, greater than /// 1 to zoom out. For example, 0.9 will zoom in such that the scale is 90% of what it was /// originally.</param> /// <param name="centerPt">The screen position about which the zoom will be centered. This /// value is only used if <see paramref="isZoomOnCenter" /> is true. /// </param> /// <param name="isZoomOnCenter">true to cause the zoom to be centered on the point /// <see paramref="centerPt" />, false to center on the <see cref="Chart.Rect" />. /// </param> /// <param name="isRefresh">true to force a refresh of the control, false to leave it unrefreshed</param> protected void ZoomPane(GraphPane pane, double zoomFraction, PointF centerPt, bool isZoomOnCenter, bool isRefresh) { double x; double x2; double[] y; double[] y2; pane.ReverseTransform(centerPt, out x, out x2, out y, out y2); if (_isEnableHZoom) { ZoomScale(pane.XAxis, zoomFraction, x, isZoomOnCenter); ZoomScale(pane.X2Axis, zoomFraction, x2, isZoomOnCenter); } if (_isEnableVZoom) { for (int i = 0; i < pane.YAxisList.Count; i++) ZoomScale(pane.YAxisList[i], zoomFraction, y[i], isZoomOnCenter); for (int i = 0; i < pane.Y2AxisList.Count; i++) ZoomScale(pane.Y2AxisList[i], zoomFraction, y2[i], isZoomOnCenter); } using (Graphics g = CreateGraphics()) { pane.AxisChange(g); //g.Dispose(); } SetScroll(hScrollBar1, pane.XAxis, _xScrollRange.Min, _xScrollRange.Max); SetScroll(vScrollBar1, pane.YAxis, _yScrollRangeList[0].Min, _yScrollRangeList[0].Max); if (isRefresh) Refresh(); }
/// <summary> /// Add the <see cref="ZedGraphWebGraphObj" /> objects defined in the webcontrol to /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects. /// </summary> /// <param name="g">The <see cref="Graphics" /> instance of interest.</param> /// <param name="pane">The <see cref="GraphPane" /> object to receive the /// <see cref="GraphObj" /> objects.</param> protected void AddWebGraphItems(IGraphics g, GraphPane pane) { try { ZedGraphWebGraphObj draw; for (int i = 0; i < GraphObjList.Count; i++) { draw = GraphObjList[i]; if (draw is ZedGraphWebTextObj) { var item = (ZedGraphWebTextObj) draw; var x = new TextObj(); item.CopyTo(x); pane.GraphObjList.Add(x); } else if (draw is ZedGraphWebArrowObj) { var item = (ZedGraphWebArrowObj) draw; var x = new ArrowObj(); item.CopyTo(x); pane.GraphObjList.Add(x); } else if (draw is ZedGraphWebImageObj) { var item = (ZedGraphWebImageObj) draw; var x = new ImageObj(); item.CopyTo(x); pane.GraphObjList.Add(x); } else if (draw is ZedGraphWebBoxObj) { var item = (ZedGraphWebBoxObj) draw; var x = new BoxObj(); item.CopyTo(x); pane.GraphObjList.Add(x); } else if (draw is ZedGraphWebEllipseObj) { var item = (ZedGraphWebEllipseObj) draw; var x = new EllipseObj(); item.CopyTo(x); pane.GraphObjList.Add(x); } } } catch (Exception ex) { Log.Debug("Exception thrown at AddWebGraphItems: " + ex.Message, ex); } }