/// <summary> /// The Copy Constructor /// </summary> /// <param name="ggn">The <see cref="GasGaugeNeedle"/> object from which to copy</param> public GasGaugeNeedle( GasGaugeNeedle ggn ) : base(ggn) { NeedleValue = ggn.NeedleValue; NeedleColor = ggn.NeedleColor; NeedleWidth = ggn.NeedleWidth; SweepAngle = ggn.SweepAngle; _border = ggn.Border.Clone(); _labelDetail = ggn.LabelDetail.Clone(); _labelDetail.FontSpec.Size = ggn.LabelDetail.FontSpec.Size; }
/// <summary> /// Constructor for deserializing objects /// </summary> /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data /// </param> protected GasGaugeNeedle( SerializationInfo info, StreamingContext context ) : base(info, context) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32( "schema2" ); _labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) ); _fill = (Fill)info.GetValue( "fill", typeof( Fill ) ); _border = (Border)info.GetValue( "border", typeof( Border ) ); _needleValue = info.GetDouble( "needleValue" ); _boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) ); _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) ); _sweepAngle = (float)info.GetDouble( "sweepAngle" ); _color = (Color)info.GetValue( "color", typeof( Color ) ); }
/// <summary> /// Constructor for deserializing objects /// </summary> /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data /// </param> protected PieItem( SerializationInfo info, StreamingContext context ) : base(info, context) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32( "schema2" ); _displacement = info.GetDouble( "displacement" ); _labelDetail = (TextObj)info.GetValue( "labelDetail", typeof( TextObj ) ); _fill = (Fill)info.GetValue( "fill", typeof( Fill ) ); _border = (Border)info.GetValue( "border", typeof( Border ) ); _pieValue = info.GetDouble( "pieValue" ); _labelType = (PieLabelType)info.GetValue( "labelType", typeof( PieLabelType ) ); _intersectionPoint = (PointF)info.GetValue( "intersectionPoint", typeof( PointF ) ); _boundingRectangle = (RectangleF)info.GetValue( "boundingRectangle", typeof( RectangleF ) ); _pivotPoint = (PointF)info.GetValue( "pivotPoint", typeof( PointF ) ); _endPoint = (PointF)info.GetValue( "endPoint", typeof( PointF ) ); // _slicePath = (GraphicsPath)info.GetValue( "slicePath", typeof( GraphicsPath ) ); _startAngle = (float)info.GetDouble( "startAngle" ); _sweepAngle = (float)info.GetDouble( "sweepAngle" ); _midAngle = (float)info.GetDouble( "midAngle" ); _labelStr = info.GetString( "labelStr" ); _valueDecimalDigits = info.GetInt32( "valueDecimalDigits" ); _percentDecimalDigits = info.GetInt32( "percentDecimalDigits" ); }
/// <summary> /// Create a new <see cref="GasGaugeNeedle"/> /// </summary> /// <param name="label">The value associated with this <see cref="GasGaugeNeedle"/> /// instance.</param> /// <param name="color">The display color for this <see cref="GasGaugeNeedle"/> /// instance.</param> /// <param name="val">The value of this <see cref="GasGaugeNeedle"/>.</param> public GasGaugeNeedle( string label, double val, Color color ) : base(label) { NeedleValue = val; NeedleColor = color; NeedleWidth = Default.NeedleWidth; SweepAngle = 0f; _border = new Border( Default.BorderColor, Default.BorderWidth ); _labelDetail = new TextObj(); _labelDetail.FontSpec.Size = Default.FontSize; _slicePath = null; }
/// <summary> /// Create a new <see cref="PieItem"/>. /// </summary> /// <param name="pieValue">The value associated with this <see cref="PieItem"/> instance.</param> /// <param name="color">The display color for this <see cref="PieItem"/> instance.</param> /// <param name="displacement">The amount this <see cref="PieItem"/> instance will be /// displaced from the center point.</param> /// <param name="label">Text label for this <see cref="PieItem"/> instance.</param> public PieItem( double pieValue, Color color, double displacement, string label ) : base(label) { _pieValue = pieValue; _fill = new Fill( color.IsEmpty ? _rotator.NextColor : color ); _displacement = displacement; _border = new Border( Default.BorderColor, Default.BorderWidth ); _labelDetail = new TextObj(); _labelDetail.FontSpec.Size = Default.FontSize; _labelType = Default.LabelType; _valueDecimalDigits = Default.ValueDecimalDigits; _percentDecimalDigits = Default.PercentDecimalDigits; _slicePath = null; }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param> public PieItem( PieItem rhs ) : base(rhs) { _pieValue = rhs._pieValue; _fill = rhs._fill.Clone(); this.Border = rhs._border.Clone(); _displacement = rhs._displacement; _labelDetail = rhs._labelDetail.Clone(); _labelType = rhs._labelType; _valueDecimalDigits = rhs._valueDecimalDigits; _percentDecimalDigits = rhs._percentDecimalDigits; }
/// <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( Graphics 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 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; pane.GraphObjList.Add( text ); // Add an arrow pointer for the above text item ArrowObj 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 BoxObj 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" 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; pane.GraphObjList.Add( myText ); pane.AxisChange( g ); }
/// <summary> /// Add the <see cref="ZeeGraphWebGraphObj" /> 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( Graphics g, GraphPane pane ) { try { ZeeGraphWebGraphObj draw; for ( int i = 0; i < GraphObjList.Count; i++ ) { draw = GraphObjList[i]; if ( draw is ZeeGraphWebTextObj ) { ZeeGraphWebTextObj item = (ZeeGraphWebTextObj)draw; TextObj x = new TextObj(); item.CopyTo( x ); pane.GraphObjList.Add( x ); } else if ( draw is ZeeGraphWebArrowObj ) { ZeeGraphWebArrowObj item = (ZeeGraphWebArrowObj)draw; ArrowObj x = new ArrowObj(); item.CopyTo( x ); pane.GraphObjList.Add( x ); } else if ( draw is ZeeGraphWebImageObj ) { ZeeGraphWebImageObj item = (ZeeGraphWebImageObj)draw; ImageObj x = new ImageObj(); item.CopyTo( x ); pane.GraphObjList.Add( x ); } else if ( draw is ZeeGraphWebBoxObj ) { ZeeGraphWebBoxObj item = (ZeeGraphWebBoxObj)draw; BoxObj x = new BoxObj(); item.CopyTo( x ); pane.GraphObjList.Add( x ); } else if ( draw is ZeeGraphWebEllipseObj ) { ZeeGraphWebEllipseObj item = (ZeeGraphWebEllipseObj)draw; EllipseObj x = new EllipseObj(); item.CopyTo( x ); pane.GraphObjList.Add( x ); } } } catch ( Exception ) { } }
/// <summary> /// Create a <see cref="TextObj" /> for each bar in the <see cref="GraphPane" />. /// </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, but only for <see cref="BarItem" /> types. This method /// does not apply to <see cref="ErrorBarItem" /> or <see cref="HiLowBarItem" /> objects. /// Call this method only after calling <see cref="GraphPane.AxisChange()" />. /// </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> /// <param name="fontColor">The color in which to draw the labels</param> /// <param name="fontFamily">The string name of the font family to use for the labels</param> /// <param name="fontSize">The floating point size of the font, in scaled points</param> /// <param name="isBold">true for a bold font type, false otherwise</param> /// <param name="isItalic">true for an italic font type, false otherwise</param> /// <param name="isUnderline">true for an underline font type, false otherwise</param> public static void CreateBarLabels( GraphPane pane, bool isBarCenter, string valueFormat, string fontFamily, float fontSize, Color fontColor, bool isBold, bool isItalic, bool isUnderline ) { bool isVertical = pane.BarSettings.Base == BarBase.X; // 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; // ADD JKB 9/21/07 // The labelOffset should depend on whether the curve is YAxis or Y2Axis. // JHC - Generalize to any value axis // Make the gap between the bars and the labels = 1.5% of the axis range float labelOffset; Scale scale = curve.ValueAxis( pane ).Scale; labelOffset = (float)( scale._max - scale._min ) * 0.015f; // 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 if ( hiVal >= 0 ) position = (float)hiVal + labelOffset; 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 ); label.FontSpec.Family = fontFamily; // Configure the TextObj // CHANGE JKB 9/21/07 // CoordinateFrame should depend on whether curve is YAxis or Y2Axis. label.Location.CoordinateFrame = (isVertical && curve.IsY2Axis) ? CoordType.AxisXY2Scale : CoordType.AxisXYScale; label.FontSpec.Size = fontSize; label.FontSpec.FontColor = fontColor; label.FontSpec.IsItalic = isItalic; label.FontSpec.IsBold = isBold; label.FontSpec.IsUnderline = isUnderline; label.FontSpec.Angle = isVertical ? 90 : 0; label.Location.AlignH = isBarCenter ? AlignH.Center : ( hiVal >= 0 ? AlignH.Left : AlignH.Right ); 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++; } } }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="TextObj"/> object from which to copy</param> public TextObj(TextObj rhs) : base(rhs) { _text = rhs.Text; _fontSpec = new FontSpec(rhs.FontSpec); }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see cref="TextObj"/> object from which to copy</param> public TextObj( TextObj rhs ) : base(rhs) { _text = rhs.Text; _fontSpec = new FontSpec( rhs.FontSpec ); }