• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ZedGraph.ValueHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ZedGraph.ValueHandler的典型用法代码示例。如果您正苦于以下问题:C# ValueHandler类的具体用法?C# ValueHandler怎么用?C# ValueHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ValueHandler类属于ZedGraph命名空间,在下文中一共展示了ValueHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BuildLowPointsArray

        /// <summary>
        /// Build an array of <see cref="PointF"/> values (pixel coordinates) that represents
        /// the low values for the current curve.
        /// </summary>
        /// <remarks>Note that this drawing routine ignores <see cref="PointPairBase.Missing"/>
        /// values, but it does not "break" the line to indicate values are missing.
        /// </remarks>
        /// <param name="pane">A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.</param>
        /// <param name="curve">A <see cref="LineItem"/> representing this
        /// curve.</param>
        /// <param name="arrPoints">An array of <see cref="PointF"/> values in pixel
        /// coordinates representing the current curve.</param>
        /// <param name="count">The number of points contained in the "arrPoints"
        /// parameter.</param>
        /// <returns>true for a successful points array build, false for data problems</returns>
        public bool BuildLowPointsArray( GraphPane pane, CurveItem curve,
						out PointF[] arrPoints, out int count )
        {
            arrPoints = null;
            count = 0;
            IPointList points = curve.Points;

            if ( this.IsVisible && !this.Color.IsEmpty && points != null )
            {
                int index = 0;
                float curX, curY,
                        lastX = 0,
                        lastY = 0;
                double x, y, hiVal;
                ValueHandler valueHandler = new ValueHandler( pane, false );

                // Step type plots get twice as many points.  Always add three points so there is
                // room to close out the curve for area fills.
                arrPoints = new PointF[( _stepType == ZedGraph.StepType.NonStep ? 1 : 2 ) *
                    ( pane.LineType == LineType.Stack ? 2 : 1 ) *
                    points.Count + 1];

                // Loop backwards over all points in the curve
                // In this case an array of points was already built forward by BuildPointsArray().
                // This time we build backwards to complete a loop around the area between two curves.
                for ( int i = points.Count - 1; i >= 0; i-- )
                {
                    // Make sure the current point is valid
                    if ( !points[i].IsInvalid )
                    {
                        // Get the user scale values for the current point
                        valueHandler.GetValues( curve, i, out x, out y, out hiVal );

                        if ( x == PointPair.Missing || y == PointPair.Missing )
                            continue;

                        // Transform the user scale values to pixel locations
                        Axis xAxis = curve.GetXAxis( pane );
                        curX = xAxis.Scale.Transform( curve.IsOverrideOrdinal, i, x );
                        Axis yAxis = curve.GetYAxis( pane );
                        curY = yAxis.Scale.Transform( curve.IsOverrideOrdinal, i, y );

                        // Add the pixel value pair into the points array
                        // Two points are added for step type curves
                        // ignore step-type setting for smooth curves
                        if ( _isSmooth || index == 0 || this.StepType == StepType.NonStep )
                        {
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }
                        else if ( this.StepType == StepType.ForwardStep )
                        {
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = lastY;
                            index++;
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }
                        else if ( this.StepType == StepType.RearwardStep )
                        {
                            arrPoints[index].X = lastX;
                            arrPoints[index].Y = curY;
                            index++;
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }

                        lastX = curX;
                        lastY = curY;
                        index++;

                    }

                }

                // Make sure there is at least one valid point
                if ( index == 0 )
                    return false;

                // Add an extra point at the end, since the smoothing algorithm requires it
                arrPoints[index] = arrPoints[index - 1];
                index++;

                count = index;
//.........这里部分代码省略.........
开发者ID:cliffton2008,项目名称:JNMAutoTrader_Capital,代码行数:101,代码来源:Line.cs


示例2: BuildPointsArray

        /// <summary>
        /// Build an array of <see cref="PointF"/> values (pixel coordinates) that represents
        /// the current curve.  Note that this drawing routine ignores <see cref="PointPairBase.Missing"/>
        /// values, but it does not "break" the line to indicate values are missing.
        /// </summary>
        /// <param name="pane">A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.</param>
        /// <param name="curve">A <see cref="LineItem"/> representing this
        /// curve.</param>
        /// <param name="arrPoints">An array of <see cref="PointF"/> values in pixel
        /// coordinates representing the current curve.</param>
        /// <param name="count">The number of points contained in the "arrPoints"
        /// parameter.</param>
        /// <returns>true for a successful points array build, false for data problems</returns>
        public bool BuildPointsArray( GraphPane pane, CurveItem curve,
			out PointF[] arrPoints, out int count )
        {
            arrPoints = null;
            count = 0;
            IPointList points = curve.Points;

            if ( this.IsVisible && !this.Color.IsEmpty && points != null )
            {
                int index = 0;
                float curX, curY,
                            lastX = 0,
                            lastY = 0;
                double x, y, lowVal;
                ValueHandler valueHandler = new ValueHandler( pane, false );

                // Step type plots get twice as many points.  Always add three points so there is
                // room to close out the curve for area fills.
                arrPoints = new PointF[( _stepType == ZedGraph.StepType.NonStep ? 1 : 2 ) *
                                            points.Count + 1];

                // Loop over all points in the curve
                for ( int i = 0; i < points.Count; i++ )
                {
                    // make sure that the current point is valid
                    if ( !points[i].IsInvalid )
                    {
                        // Get the user scale values for the current point
                        // use the valueHandler only for stacked types
                        if ( pane.LineType == LineType.Stack )
                        {
                            valueHandler.GetValues( curve, i, out x, out lowVal, out y );
                        }
                        // otherwise, just access the values directly.  Avoiding the valueHandler for
                        // non-stacked types is an optimization to minimize overhead in case there are
                        // a large number of points.
                        else
                        {
                            x = points[i].X;
                            y = points[i].Y;
                        }

                        if ( x == PointPair.Missing || y == PointPair.Missing )
                            continue;

                        // Transform the user scale values to pixel locations
                        Axis xAxis = curve.GetXAxis( pane );
                        curX = xAxis.Scale.Transform( curve.IsOverrideOrdinal, i, x );
                        Axis yAxis = curve.GetYAxis( pane );
                        curY = yAxis.Scale.Transform( curve.IsOverrideOrdinal, i, y );

                        if ( curX < -1000000 || curY < -1000000 || curX > 1000000 || curY > 1000000 )
                            continue;

                        // Add the pixel value pair into the points array
                        // Two points are added for step type curves
                        // ignore step-type setting for smooth curves
                        if ( _isSmooth || index == 0 || this.StepType == StepType.NonStep )
                        {
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }
                        else if ( this.StepType == StepType.ForwardStep )
                        {
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = lastY;
                            index++;
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }
                        else if ( this.StepType == StepType.RearwardStep )
                        {
                            arrPoints[index].X = lastX;
                            arrPoints[index].Y = curY;
                            index++;
                            arrPoints[index].X = curX;
                            arrPoints[index].Y = curY;
                        }

                        lastX = curX;
                        lastY = curY;
                        index++;

                    }

                }
//.........这里部分代码省略.........
开发者ID:cliffton2008,项目名称:JNMAutoTrader_Capital,代码行数:101,代码来源:Line.cs


示例3: CreateBarLabels

        // Call this method after calling AxisChange()
        private void CreateBarLabels( GraphPane pane )
        {
            // Make the gap between the bars and the labels = 2% of the axis range
            float labelOffset = (float)( pane.YAxis.Scale.Max - pane.YAxis.Scale.Min ) * 0.02f;

            foreach ( CurveItem curve in pane.CurveList )
            {
                BarItem bar = curve as BarItem;

                if ( bar != null )
                {
                    IPointList points = curve.Points;

                    for ( int i = 0; i < points.Count; i++ )
                    {
                        ValueHandler valueHandler		=
                            new ValueHandler( pane, true );

                        int curveIndex					=
                            pane.CurveList.IndexOf( curve );

                        double labelXCoordintate			=
                            valueHandler.BarCenterValue( bar,
                            bar.GetBarWidth( pane ), i, points[ i ].X,
                            curveIndex );

                        float labelYCoordinate				=
                            ( float ) points[ i ].Y + labelOffset;

                        string barLabelText				=
                            ( points[ i ].Y / 1000 ).ToString( "N2" );

                        TextObj label					=
                            new TextObj( barLabelText, ( float ) labelXCoordintate,
                            labelYCoordinate );

                        label.Location.CoordinateFrame	= CoordType.AxisXYScale;
                        label.FontSpec.Size				= 10;
                        label.FontSpec.FontColor		= Color.Black;
                        label.FontSpec.Angle = 90;
                        label.Location.AlignH			= AlignH.Left;
                        label.Location.AlignV			= AlignV.Center;
                        label.FontSpec.Border.IsVisible	= false;
                        label.FontSpec.Fill.IsVisible	= false;

                        pane.GraphObjList.Add( label );
                    }
                }
            }
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:51,代码来源:Form1.cs


示例4: Draw

        /// <summary>
        /// Draw this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
        /// device as a symbol at each defined point.  The routine
        /// only draws the symbols; the lines are draw by the
        /// <see cref="Line.DrawCurve"/> method.  This method
        /// is normally only called by the Draw method of the
        /// <see cref="CurveItem"/> 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="curve">A <see cref="LineItem"/> representing this
        /// curve.</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="isSelected">Indicates that the <see cref="Symbol" /> should be drawn
        /// with attributes from the <see cref="Selection" /> class.
        /// </param>
        public void Draw( Graphics g, GraphPane pane, LineItem curve, float scaleFactor,
			bool isSelected )
        {
            Symbol source = this;
            if ( isSelected )
                source = Selection.Symbol;

            int tmpX, tmpY;

            int minX = (int)pane.Chart.Rect.Left;
            int maxX = (int)pane.Chart.Rect.Right;
            int minY = (int)pane.Chart.Rect.Top;
            int maxY = (int)pane.Chart.Rect.Bottom;

            // (Dale-a-b) we'll set an element to true when it has been drawn
            bool[,] isPixelDrawn = new bool[maxX + 1, maxY + 1];

            double curX, curY, lowVal;
            IPointList points = curve.Points;

            if ( points != null && ( _border.IsVisible || _fill.IsVisible ) )
            {
                SmoothingMode sModeSave = g.SmoothingMode;
                if ( _isAntiAlias )
                    g.SmoothingMode = SmoothingMode.HighQuality;

                // For the sake of speed, go ahead and create a solid brush and a pen
                // If it's a gradient fill, it will be created on the fly for each symbol
                //SolidBrush	brush = new SolidBrush( this.fill.Color );

                using ( Pen pen = source._border.GetPen( pane, scaleFactor ) )
                using ( GraphicsPath path = MakePath( g, scaleFactor ) )
                {
                    RectangleF rect = path.GetBounds();

                    using ( Brush brush = source.Fill.MakeBrush( rect ) )
                    {
                        ValueHandler valueHandler = new ValueHandler( pane, false );
                        Scale xScale = curve.GetXAxis( pane ).Scale;
                        Scale yScale = curve.GetYAxis( pane ).Scale;

                        bool xIsLog = xScale.IsLog;
                        bool yIsLog = yScale.IsLog;
                        bool xIsOrdinal = xScale.IsAnyOrdinal;

                        double xMin = xScale.Min;
                        double xMax = xScale.Max;

                        // Loop over each defined point
                        for ( int i = 0; i < points.Count; i++ )
                        {
                            // Get the user scale values for the current point
                            // use the valueHandler only for stacked types
                            if ( pane.LineType == LineType.Stack )
                            {
                                valueHandler.GetValues( curve, i, out curX, out lowVal, out curY );
                            }
                            // otherwise, just access the values directly.  Avoiding the valueHandler for
                            // non-stacked types is an optimization to minimize overhead in case there are
                            // a large number of points.
                            else
                            {
                                curX = points[i].X;
                                if ( curve is StickItem )
                                    curY = points[i].Z;
                                else
                                    curY = points[i].Y;
                            }

                            // Any value set to double max is invalid and should be skipped
                            // This is used for calculated values that are out of range, divide
                            //   by zero, etc.
                            // Also, any value <= zero on a log scale is invalid
//.........这里部分代码省略.........
开发者ID:viwhi1,项目名称:TDMaker,代码行数:101,代码来源:Symbol.cs


示例5: Draw

		/// <summary>
		/// Draw all the <see cref="ErrorBar"/>'s to the specified <see cref="Graphics"/>
		/// device as a an error bar at each defined point.
		/// </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="curve">A <see cref="CurveItem"/> object representing the
		/// <see cref="Bar"/>'s to be drawn.</param>
		/// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
		/// axis for the <see cref="Bar"/></param>
		/// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
		/// axis for the <see cref="Bar"/></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 Draw( Graphics g, GraphPane pane, ErrorBarItem curve,
							Axis baseAxis, Axis valueAxis, float scaleFactor )
		{
			ValueHandler valueHandler = new ValueHandler( pane, false );

			float	pixBase, pixValue, pixLowValue;
			double	scaleBase, scaleValue, scaleLowValue;
		
			if ( curve.Points != null && this.IsVisible )
			{
				using ( Pen pen = !curve.IsSelected ? new Pen( _color, _penWidth ) :
						new Pen( Selection.Border.Color, Selection.Border.Width ) )
				{
					// Loop over each defined point							
					for ( int i = 0; i < curve.Points.Count; i++ )
					{
						valueHandler.GetValues( curve, i, out scaleBase,
									out scaleLowValue, out scaleValue );

						// Any value set to double max is invalid and should be skipped
						// This is used for calculated values that are out of range, divide
						//   by zero, etc.
						// Also, any value <= zero on a log scale is invalid

						if ( !curve.Points[i].IsInvalid3D &&
								( scaleBase > 0 || !baseAxis._scale.IsLog ) &&
								( ( scaleValue > 0 && scaleLowValue > 0 ) || !valueAxis._scale.IsLog ) )
						{
							pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleBase );
							pixValue = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleValue );
							pixLowValue = valueAxis.Scale.Transform( curve.IsOverrideOrdinal, i, scaleLowValue );

							//if ( this.fill.IsGradientValueType )
							//	brush = fill.MakeBrush( _rect, _points[i] );

							this.Draw( g, pane, baseAxis is XAxis || baseAxis is X2Axis, pixBase, pixValue,
											pixLowValue, scaleFactor, pen, curve.IsSelected,
											curve.Points[i] );
						}
					}
				}
			}
		}
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:67,代码来源:ErrorBar.cs


示例6: GetCoords

		/// <summary>
		/// Determine the coords for the rectangle associated with a specified point for 
		/// this <see cref="CurveItem" />
		/// </summary>
		/// <param name="pane">The <see cref="GraphPane" /> to which this curve belongs</param>
		/// <param name="i">The index of the point of interest</param>
		/// <param name="coords">A list of coordinates that represents the "rect" for
		/// this point (used in an html AREA tag)</param>
		/// <returns>true if it's a valid point, false otherwise</returns>
		public override bool GetCoords(GraphPane pane, int i, out string coords)
		{
			coords = string.Empty;

			if (i < 0 || i >= _points.Count)
				return false;

			Axis valueAxis = ValueAxis(pane);
			Axis baseAxis = BaseAxis(pane);

			// pixBase = pixel value for the bar center on the base axis
			// pixHiVal = pixel value for the bar top on the value axis
			// pixLowVal = pixel value for the bar bottom on the value axis
			float pixBase, pixHiVal, pixLowVal;

			float clusterWidth = pane.BarSettings.GetClusterWidth();
			float barWidth = GetBarWidth(pane);
			float clusterGap = pane._barSettings.MinClusterGap*barWidth;
			float barGap = barWidth*pane._barSettings.MinBarGap;

			// curBase = the scale value on the base axis of the current bar
			// curHiVal = the scale value on the value axis of the current bar
			// curLowVal = the scale value of the bottom of the bar
			double curBase, curLowVal, curHiVal;
			ValueHandler valueHandler = new ValueHandler(pane, false);
			valueHandler.GetValues(this, i, out curBase, out curLowVal, out curHiVal);

			// Any value set to double max is invalid and should be skipped
			// This is used for calculated values that are out of range, divide
			//   by zero, etc.
			// Also, any value <= zero on a log scale is invalid

			if (!_points[i].IsInvalid3D) {
				// calculate a pixel value for the top of the bar on value axis
				pixLowVal = valueAxis.Scale.Transform(_isOverrideOrdinal, i, curLowVal);
				pixHiVal = valueAxis.Scale.Transform(_isOverrideOrdinal, i, curHiVal);
				// calculate a pixel value for the center of the bar on the base axis
				pixBase = baseAxis.Scale.Transform(_isOverrideOrdinal, i, curBase);

				// Calculate the pixel location for the side of the bar (on the base axis)
				float pixSide = pixBase - clusterWidth/2.0F + clusterGap/2.0F +
				                pane.CurveList.GetBarItemPos(pane, this)*(barWidth + barGap);

				// Draw the bar
				if (baseAxis is XAxis || baseAxis is X2Axis)
					coords = string.Format("{0:f0},{1:f0},{2:f0},{3:f0}",
					                       pixSide, pixLowVal,
					                       pixSide + barWidth, pixHiVal);
				else
					coords = string.Format("{0:f0},{1:f0},{2:f0},{3:f0}",
					                       pixLowVal, pixSide,
					                       pixHiVal, pixSide + barWidth);

				return true;
			}

			return false;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:67,代码来源:BarItem.cs


示例7: DrawSingleBar

        protected override void DrawSingleBar(Graphics g, GraphPane pane, CurveItem curve,
            int index, int pos, Axis baseAxis, Axis valueAxis, float barWidth, float scaleFactor)
        {
            base.DrawSingleBar(g, pane, curve, index, pos, baseAxis, valueAxis, barWidth, scaleFactor);
            PointPair pointPair = curve.Points[index];
            ErrorTag errorTag = pointPair.Tag as ErrorTag;
            if (pointPair.IsInvalid || errorTag == null)
            {
                return;
            }

            double curBase, curLowVal, curHiVal;
            ValueHandler valueHandler = new ValueHandler(pane, false);
            valueHandler.GetValues(curve, index, out curBase, out curLowVal, out curHiVal);

            float pixBase = baseAxis.Scale.Transform(curve.IsOverrideOrdinal, index, curBase);
            double lowError = curHiVal - errorTag.Error;
            float pixLowError = valueAxis.Scale.Transform(lowError);
            float pixHiError = valueAxis.Scale.Transform(lowError + errorTag.Error*2);

            float clusterWidth = pane.BarSettings.GetClusterWidth();
            //float barWidth = curve.GetBarWidth( pane );
            float clusterGap = pane.BarSettings.MinClusterGap * barWidth;
            float barGap = barWidth * pane.BarSettings.MinBarGap;

            // Calculate the pixel location for the side of the bar (on the base axis)
            float pixSide = pixBase - clusterWidth / 2.0F + clusterGap / 2.0F +
                            pos * (barWidth + barGap);

            // Draw the bar
            if (pane.BarSettings.Base == BarBase.X)
            {
                if (barWidth >= 3 && errorTag.Error > 0)
                {
                    // Draw whiskers
                    float pixMidX = (float)Math.Round(pixSide + barWidth / 2);

                    // Line
                    g.DrawLine(ErrorPen, pixMidX, pixHiError, pixMidX, pixLowError);
                    if (barWidth >= PIX_TERM_WIDTH)
                    {
                        // Ends
                        float pixLeft = pixMidX - (float) Math.Round(PIX_TERM_WIDTH/2);
                        float pixRight = pixLeft + PIX_TERM_WIDTH - 1;
                        g.DrawLine(ErrorPen, pixLeft, pixHiError, pixRight, pixHiError);
                        g.DrawLine(ErrorPen, pixLeft, pixLowError, pixRight, pixLowError);
                    }
                }
            }
            else
            {
                if (barWidth >= 3 && errorTag.Error > 0)
                {
                    // Draw whiskers
                    float pixMidY = (float)Math.Round(pixSide + barWidth / 2) + 1;

                    // Line
                    g.DrawLine(ErrorPen, pixLowError, pixMidY, pixHiError, pixMidY);
                    if (barWidth >= PIX_TERM_WIDTH)
                    {
                        // Ends
                        float pixTop = pixMidY - (float) Math.Round(PIX_TERM_WIDTH/2);
                        float pixBottom = pixTop + PIX_TERM_WIDTH - 1;
                        g.DrawLine(ErrorPen, pixHiError, pixTop, pixHiError, pixBottom);
                        g.DrawLine(ErrorPen, pixLowError, pixTop, pixLowError, pixBottom);
                    }
                }
            }
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:69,代码来源:MeanErrorBarItem.cs


示例8: GetCoords

		/// <summary>
		/// Determine the coords for the rectangle associated with a specified point for 
		/// this <see cref="CurveItem" />
		/// </summary>
		/// <param name="pane">The <see cref="GraphPane" /> to which this curve belongs</param>
		/// <param name="i">The index of the point of interest</param>
		/// <param name="coords">A list of coordinates that represents the "rect" for
		/// this point (used in an html AREA tag)</param>
		/// <returns>true if it's a valid point, false otherwise</returns>
		public override bool GetCoords(GraphPane pane, int i, out string coords)
		{
			coords = string.Empty;

			if (i < 0 || i >= _points.Count)
				return false;

			PointPair pt = _points[i];
			if (pt.IsInvalid)
				return false;

			double x, y, z;
			ValueHandler valueHandler = new ValueHandler(pane, false);
			valueHandler.GetValues(this, i, out x, out z, out y);

			Axis yAxis = GetYAxis(pane);
			Axis xAxis = GetXAxis(pane);

			PointF pixPt = new PointF(xAxis.Scale.Transform(_isOverrideOrdinal, i, x),
			                          yAxis.Scale.Transform(_isOverrideOrdinal, i, y));

			if (!pane.Chart.Rect.Contains(pixPt))
				return false;

			float halfSize = _symbol.Size*pane.CalcScaleFactor();

			coords = string.Format("{0:f0},{1:f0},{2:f0},{3:f0}",
			                       pixPt.X - halfSize, pixPt.Y - halfSize,
			                       pixPt.X + halfSize, pixPt.Y + halfSize);

			return true;
		}
开发者ID:stewmc,项目名称:vixen,代码行数:41,代码来源:LineItem.cs


示例9: CreateBarLabels

        /// <summary>
        /// Create a TextLabel for each bar in the GraphPane.
        /// Call this method only after calling AxisChange()
        /// </summary>
        /// <remarks>
        /// This method will go through the bars, create a label that corresponds to the bar value,
        /// and place it on the graph depending on user preferences.  This works for horizontal or
        /// vertical bars in clusters or stacks.</remarks>
        /// <param name="pane">The GraphPane in which to place the text labels.</param>
        /// <param name="isBarCenter">true to center the labels inside the bars, false to
        /// place the labels just above the top of the bar.</param>
        /// <param name="valueFormat">The double.ToString string format to use for creating
        /// the labels
        /// </param>
        private void CreateBarLabels( GraphPane pane, bool isBarCenter, string valueFormat )
        {
            bool isVertical = pane.BarSettings.Base == BarBase.X;

            // Make the gap between the bars and the labels = 2% of the axis range
            float labelOffset;
            if ( isVertical )
                labelOffset = (float) ( pane.YAxis.Scale.Max - pane.YAxis.Scale.Min ) * 0.02f;
            else
                labelOffset = (float) ( pane.XAxis.Scale.Max - pane.XAxis.Scale.Min ) * 0.02f;

            // keep a count of the number of BarItems
            int curveIndex = 0;

            // Get a valuehandler to do some calculations for us
            ValueHandler valueHandler = new ValueHandler( pane, true );

            // Loop through each curve in the list
            foreach ( CurveItem curve in pane.CurveList )
            {
                // work with BarItems only
                BarItem bar = curve as BarItem;
                if ( bar != null )
                {
                    IPointList points = curve.Points;

                    // Loop through each point in the BarItem
                    for ( int i=0; i<points.Count; i++ )
                    {
                        // Get the high, low and base values for the current bar
                        // note that this method will automatically calculate the "effective"
                        // values if the bar is stacked
                        double baseVal, lowVal, hiVal;
                        valueHandler.GetValues( curve, i, out baseVal, out lowVal, out hiVal );

                        // Get the value that corresponds to the center of the bar base
                        // This method figures out how the bars are positioned within a cluster
                        float centerVal = (float) valueHandler.BarCenterValue( bar,
                            bar.GetBarWidth( pane ), i, baseVal, curveIndex );

                        // Create a text label -- note that we have to go back to the original point
                        // data for this, since hiVal and lowVal could be "effective" values from a bar stack
                        string barLabelText	= ( isVertical ? points[i].Y : points[i].X ).ToString( valueFormat );

                        // Calculate the position of the label -- this is either the X or the Y coordinate
                        // depending on whether they are horizontal or vertical bars, respectively
                        float position;
                        if ( isBarCenter )
                            position = (float) (hiVal + lowVal) / 2.0f;
                        else
                            position = (float) hiVal + labelOffset;

                        // Create the new TextObj
                        TextObj label;
                        if ( isVertical )
                            label = new TextObj( barLabelText, centerVal, position );
                        else
                            label = new TextObj( barLabelText, position, centerVal );

                        // Configure the TextObj
                        label.Location.CoordinateFrame	= CoordType.AxisXYScale;
                        label.FontSpec.Size					= 12;
                        label.FontSpec.FontColor			= Color.Black;
                        label.FontSpec.Angle					= isVertical ? 90 : 0;
                        label.Location.AlignH				= isBarCenter ? AlignH.Center : AlignH.Left;
                        label.Location.AlignV				= AlignV.Center;
                        label.FontSpec.Border.IsVisible	= false;
                        label.FontSpec.Fill.IsVisible		= false;

                        // Add the TextObj to the GraphPane
                        pane.GraphObjList.Add( label );
                    }
                }
                curveIndex++;
            }
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:90,代码来源:HorizontalBarsWithLabels.cs


示例10: GetPoints

        private IPointList GetPoints(CurveItem curve, GraphPane pane)
        {
            IPointList points = curve.Points;
            ValueHandler valueHandler = new ValueHandler( pane, false );

            if (pane.LineType == LineType.Stack)
            {
                // Loop over each point in the curve
                for (int i = 0; i < points.Count; i++)
                {
                    double x, y, unused;
                    if (!valueHandler.GetValues(curve, i, out x, out unused, out y))
                    {
                        x = PointPair.Missing;
                        y = PointPair.Missing;
                    }
                    points[i].X = x;
                    points[i].Y = y;
                }
            }
            return points;
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:22,代码来源:Line.cs


示例11: HorizontalBarDemo

        public HorizontalBarDemo()
            : base("A sideways bar demo.\n" +
								"This demo also shows how to add labels to the bars, in this " +
								"case showing the value of each bar",
								"HorizontalBar Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text = "Horizontal Bar Graph";
            myPane.XAxis.Title.Text = "Performance Factor";
            myPane.YAxis.Title.Text = "Grouping";

            // Enter some random data values
            double[] y = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, -35, 80, 35, 35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            // Generate a bar with "Curve 1" in the legend
            BarItem myCurve = myPane.AddBar( "Curve 1", y, null, Color.Red );
            // Fill the bar with a red-white-red gradient
            myCurve.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red, 90F );

            // Generate a bar with "Curve 2" in the legend
            myCurve = myPane.AddBar( "Curve 2", y2, null, Color.Blue );
            // Fill the bar with a blue-white-blue gradient for a 3d look
            myCurve.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue, 90F );

            // Generate a bar with "Curve 3" in the legend
            myCurve = myPane.AddBar( "Curve 3", y3, null, Color.Green );
            // Fill the bar with a Green-white-Green gradient for a 3d look
            myCurve.Bar.Fill = new Fill( Color.White, Color.Green, 90F );

            // Draw the X tics between the labels instead of at the labels
            myPane.YAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis to an ordinal type
            myPane.YAxis.Type = AxisType.Ordinal;
            // draw the X axis zero line
            myPane.XAxis.MajorGrid.IsZeroLine = true;

            //This is the part that makes the bars horizontal
            myPane.BarSettings.Base = BarBase.Y;

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill( Color.White,
                Color.FromArgb( 255, 255, 166), 45.0F );

            base.ZedGraphControl.AxisChange();

            // The ValueHandler is a helper that does some position calculations for us.
            ValueHandler valueHandler = new ValueHandler( myPane, true );

            // Display a value for the maximum of each bar cluster
            // Shift the text items by 5 user scale units above the bars
            const float shift = 3;

            int ord = 0;
            foreach ( CurveItem curve in myPane.CurveList )
            {
                BarItem bar = curve as BarItem;

                if ( bar != null )
                {
                    IPointList points = curve.Points;

                    for ( int i=0; i<points.Count; i++ )
                    {
                        double xVal = points[i].X;
                        // Calculate the Y value at the center of each bar
                        double yVal = valueHandler.BarCenterValue( curve, curve.GetBarWidth( myPane ),
                                    i, points[i].Y, ord );

                        // format the label string to have 1 decimal place
                        string lab = xVal.ToString( "F0" );

                        // create the text item (assumes the x axis is ordinal or text)
                        // for negative bars, the label appears just above the zero value
                        TextObj text = new TextObj( lab, (float) xVal + ( xVal > 0 ? shift : -shift ),
                                                        (float) yVal );

                        // tell Zedgraph to use user scale units for locating the TextObj
                        text.Location.CoordinateFrame = CoordType.AxisXYScale;
                        text.FontSpec.Size = 10;
                        // AlignH the left-center of the text to the specified point
                        text.Location.AlignH =  xVal > 0 ? AlignH.Left : AlignH.Right;
                        text.Location.AlignV = AlignV.Center;
                        text.FontSpec.Border.IsVisible = false;
                        // rotate the text 90 degrees
                        text.FontSpec.Angle = 0;
                        text.FontSpec.Fill.IsVisible = false;
                        // add the TextObj to the list
                        myPane.GraphObjList.Add( text );
                    }
                }

                ord++;
            }
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:99,代码来源:HorizontalBarDemo.cs


示例12: Form1_Load


//.........这里部分代码省略.........
            trackBar1.Value = 50;

            #endif

            #if false	// Basic horizontal bar test

            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            PointPairList list = new PointPairList();

            for ( int i=0; i<5; i++ )
            {
                double y = (double) i;
                //double x = new XDate( 2001, 1, i*3 );
                double x = Math.Sin( i / 8.0 ) * 100000 + 100001;
                list.Add( x, y );
                //double z = Math.Abs( Math.Cos( i / 8.0 ) ) * y;
            }

            PointPairList list2 = new PointPairList( list );
            PointPairList list3 = new PointPairList( list );
            BarItem myCurve = myPane.AddBar( "curve 1", list, Color.Blue );
            BarItem myCurve2 = myPane.AddBar( "curve 2", list2, Color.Red );
            BarItem myCurve3 = myPane.AddBar( "curve 3", list3, Color.Green );

            //myPane.XAxis.IsSkipLastLabel = false;
            //myPane.XAxis.IsPreventLabelOverlap = false;
            //myPane.XAxis.ScaleFormat = "dd/MM HH:mm";
            //myPane.XAxis.Type = AxisType.Date;
            myPane.BarType = BarType.PercentStack;
            myPane.BarBase = BarBase.Y;
            myPane.AxisChange( this.CreateGraphics() );

            ValueHandler valueHandler = new ValueHandler(myPane, true);
            const float shift = 0;
            int iOrd = 0;
            foreach (CurveItem oCurveItem in myPane.CurveList)
            {
                BarItem oBarItem = oCurveItem as BarItem;
                if (oBarItem != null)
                {
                    PointPairList oPointPairList = oCurveItem.Points as PointPairList;
                    for (int i=0; i<oPointPairList.Count; i++)
                    {
                        double xVal = oPointPairList[i].X;
                        string sLabel = string.Concat(xVal.ToString("F0"), "%");

                        double yVal = valueHandler.BarCenterValue(oCurveItem, oCurveItem.GetBarWidth(myPane), i, oPointPairList[i].Y, iOrd);
                        double x1, x2, y;
                        valueHandler.GetValues( oCurveItem, i, out y, out x1, out x2 );

                        xVal = ( x1 + x2 ) / 2.0;

                        TextItem oTextItem = new TextItem(sLabel, (float) xVal + (xVal > 0 ? shift : -shift ), (float) yVal);
                        oTextItem.Location.CoordinateFrame = CoordType.AxisXYScale;
                        oTextItem.Location.AlignH =  AlignH.Center;
                        oTextItem.Location.AlignV = AlignV.Center;
                        oTextItem.FontSpec.Border.IsVisible = true;
                        oTextItem.FontSpec.Angle = 0;
                        oTextItem.FontSpec.Fill.IsVisible = false;
                        myPane.GraphItemList.Add(oTextItem);
                    }
                }

                iOrd++;
            }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:67,代码来源:Form1.cs


示例13: CreateStackBarLabels

        // Call this method only after calling AxisChange()
        private void CreateStackBarLabels( GraphPane graphPane )
        {
            float labelOffset = (float)( 0.02 * ( graphPane.XAxis.Scale.Max - graphPane.XAxis.Scale.Min ) );
            ValueHandler valueHandler = new ValueHandler( graphPane, true );
            int barIndex = -1;

            foreach ( CurveItem curve in graphPane.CurveList )
            {
                if ( curve is BarItem )
                {
                    BarItem bar = curve as BarItem;
                    barIndex++;
                    float barWidth = bar.GetBarWidth( graphPane );

                    IPointList points = bar.Points;

                    for ( int i = 0; i < points.Count; i++ )
                    {
                        double labelYCoordinate = valueHandler.BarCenterValue( bar, barWidth, i, points[i].Y, barIndex );

                        double baseVal, lowVal, hiVal;

                        valueHandler.GetValues( bar, i, out baseVal, out lowVal, out hiVal );

                        float labelXCoordinate = (float)( lowVal + hiVal ) / 2.0f;

                        string barLabelText = ( points[i].X ).ToString( "N2" );

                        TextObj label = new TextObj( barLabelText, (float)labelXCoordinate, (float)labelYCoordinate );

                        label.Location.CoordinateFrame = CoordType.AxisXYScale;
                        label.FontSpec.Size = 10;
                        label.FontSpec.FontColor = Color.Black;
                        label.Location.AlignH = AlignH.Left;
                        label.Location.AlignV = AlignV.Center;
                        label.FontSpec.Border.IsVisible = false;
                        label.FontSpec.Fill.IsVisible = false;

                        graphPane.GraphObjList.Add( label );
                    }
                }
            }
        }
开发者ID:Jungwon,项目名称:ZedGraph,代码行数:44,代码来源:Form1.cs


示例14: DrawCurve

        /// <summary>
        /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
        /// device.  The format (stair-step or line) of the curve is
        /// defined by the <see cref="StepType"/> property.  The routine
        /// only draws the line segments; the symbols are drawn by the
        /// <see cref="Symbol.Draw"/> method.  This method
        /// is normally only called  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ZedGraph.XDate类代码示例发布时间:2022-05-26
下一篇:
C# ZedGraph.TextObj类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap