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 (m)";
            myPane.YAxis.Title.Text = "Elevation (m)";

            LineItem myCurve;

            myCurve = myPane.AddCurve("Planner", list1, Color.Red, SymbolType.None);
            myCurve = myPane.AddCurve("GE", list2, Color.Green, 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;

            // 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 { }
        }
Beispiel #2
0
 /// <summary>
 /// Render text at the bottom of a bar
 /// </summary>
 /// <param name="gp"></param>
 /// <param name="d"></param>
 /// <param name="x"></param>
 protected override void RenderBarLabel(GraphPane gp, RequestDataResults d, float x)
 {
     var requestText = new TextObj(d.Request + "   -", x, 0).Style(Color.Black, 7);
     requestText.FontSpec.Angle = 25;
     requestText.Location.AlignH = AlignH.Right;
     gp.GraphObjList.Add(requestText);
 }
 protected override void RenderBarLabel(GraphPane gp, RequestDataResults d, float x)
 {
     var dateText = new TextObj(d.Date.ToShortDateString() + "   .", x, 0);
     dateText.FontSpec.Fill.IsVisible = false;
     dateText.FontSpec.Border.IsVisible = false;
     dateText.FontSpec.FontColor = Color.Black;
     dateText.FontSpec.Size = 7;
     dateText.FontSpec.Angle = 45;
     dateText.Location.AlignH = AlignH.Right;
     gp.GraphObjList.Add(dateText);
 }
        /// <summary>
        /// Wypełnienie grafu powiązań pracowników z lotami.
        /// Zostaną wzięci pod uwagę tylko ci pracownicy i tylko te loty,
        /// które sa zaznaczone na liście filtrów.
        /// </summary>
        private void refreshGraph()
        {
            GraphPane pane = this.zgc1.GraphPane;

            pane.CurveList.Clear();

            for (int flightNum = 0; flightNum < crewAssingment.FlightsCount; flightNum++)
            {
                if (flightsListView.Items[flightNum].Checked == false)
                {
                    continue;
                }

                ArrayList team = crewAssingment.getFlightAssingments(flightNum);
                for (int persNum = 0; persNum < crewListView.Items.Count; persNum++)
                {
                    if (crewListView.Items[persNum].Checked == false || (Int32)team[persNum] == 0)
                    {
                        continue;
                    }

                    showOnGraph(flightNum, persNum);
                }

                // podpis punktu
                ZedGraph.TextObj text = new ZedGraph.TextObj("Lot " + (flightNum + 1), 2 * flightNum + 1 - 0.7, 3,
                                                             ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                text.ZOrder = ZedGraph.ZOrder.A_InFront;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.IsBold           = true;
                text.FontSpec.Angle            = 60;
                pane.GraphObjList.Add(text);
            }

            for (int i = 0; i < personel.Count; i++)
            {
                ZedGraph.TextObj text = new ZedGraph.TextObj(personel[i].Imię, 1 + i, 10 + 0.3,
                                                             ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                text.ZOrder = ZedGraph.ZOrder.A_InFront;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.IsBold           = true;
                text.FontSpec.Angle            = 60;
                pane.GraphObjList.Add(text);
            }

            pane.XAxis.Scale.Max      = crewAssingment.FlightsCount * 2 + 4;
            pane.YAxis.Scale.MaxGrace = 0.2;
            zgc1.Refresh();
        }
        protected override void RenderLegend(GraphPane gp, IEnumerable<RequestDataResults> dataResults)
        {
            var hostName = new TextObj(dataResults.First().HostName, dataResults.Count() + 1, dataResults.Max(x => x.AverageResponseTime) * 1.1);
            hostName.FontSpec.Fill.IsVisible = false;
            hostName.FontSpec.Border.IsVisible = false;
            hostName.FontSpec.FontColor = Color.Black;
            hostName.FontSpec.Size = 7;
            gp.GraphObjList.Add(hostName);

            var date = new TextObj(DateTime.Now.ToString(), dataResults.Count() + 1, dataResults.Max(x => x.AverageResponseTime) * 1.05);
            date.FontSpec.Fill.IsVisible = false;
            date.FontSpec.Border.IsVisible = false;
            date.FontSpec.FontColor = Color.Black;
            date.FontSpec.Size = 7;
            gp.GraphObjList.Add(date);
        }
Beispiel #6
0
        public static void AddLabel(this GraphPane pane, double x, int n)
        {
            var yScale = pane.YAxis.Scale;
            double yMin = yScale.Min;
            double yMax = yScale.Max;

            var line = new LineObj(x, yMin, x, yMax) { IsClippedToChartRect = true };
            //line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            line.Line.Color = Color.DarkGreen;
            pane.GraphObjList.Add(line);

            if (n > 0) {
                var text = new TextObj(n.ToString(), x, yMax - 0.02 * (yMax - yMin)) { IsClippedToChartRect = true };
                text.FontSpec.Border.IsVisible = true;
                pane.GraphObjList.Add(text);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Render legend
        /// </summary>
        /// <param name="gp"></param>
        /// <param name="dataResults"></param>
        protected override void RenderLegend(GraphPane gp, IEnumerable<RequestDataResults> dataResults)
        {
            int fontSize = 6;
            int offset = 0;
            int unit = (int) gp.YAxis.Scale.Max/10;
            // Average time
            var avgLegendBox = new BoxObj(-4, unit, 1, unit)
            {
                Fill = new Fill(Color.FromArgb(75, Color.YellowGreen))
            };
            gp.GraphObjList.Add(avgLegendBox);

            var avgLegendText = new TextObj("125", -3.5, (double)unit / 2).Style(Color.Black, fontSize);
            gp.GraphObjList.Add(avgLegendText);

            var avgLegendLabel = new TextObj("Average time", -4, (double)unit / 2).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgLegendLabel);

            offset += unit*2;

            // Min/Max
            var minMaxLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            gp.GraphObjList.Add(minMaxLine);

            var minMaxLabel = new TextObj("Min/Max", -4, offset + unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(minMaxLabel);

            offset += 3*unit;

            // Min/Max excluding extreme deciles
            var minMaxExclLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            minMaxExclLine.Line.Width = 3;
            minMaxExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(minMaxExclLine);

            var avgExclLine = new LineObj(Color.Black, -3.8, offset + unit, -3.2, offset + unit);
            avgExclLine.Line.Width = 3;
            avgExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(avgExclLine);

            var avgExclLabel1 = new TextObj("Min/Max/Avg", -4, offset + 1.2 *unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel1);
            var avgExclLabel2 = new TextObj("excluding extremes", -4, offset + 0.8 * unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel2);
        }
        public RectangleF GetLabelBounds(TextObj textObj, GraphPane graphPane, Graphics graphics)
        {
            SizeF size;
            lock (_textBoxSizes)
            {
                var label = new Label {Text = textObj.Text, FontSize = textObj.FontSpec.Size};
                if (!_textBoxSizes.TryGetValue(label, out size))
                {
                    const float scaleFactor = 1.0f;

                    // This is a really expensive call, so we're caching its result across threads.
                    var coords = textObj.FontSpec.GetBox(
                        graphics, textObj.Text, 0, 0,
                        textObj.Location.AlignH, textObj.Location.AlignV, scaleFactor, new SizeF());

                    // Turn four points into a size.
                    var min = coords[0];
                    var max = min;
                    for (int i = 1; i < coords.Length; i++)
                    {
                        var point = coords[i];
                        if (min.X > point.X)
                            min.X = point.X;
                        if (min.Y > point.Y)
                            min.Y = point.Y;
                        if (max.X < point.X)
                            max.X = point.X;
                        if (max.Y < point.Y)
                            max.Y = point.Y;
                    }
                    size = new SizeF(max.X - min.X, max.Y - min.Y);

                    // Cache the result.
                    _textBoxSizes[label] = size;
                }
            }

            PointF pix = textObj.Location.Transform(graphPane);
            return new RectangleF(pix, size);
        }
Beispiel #9
0
        private void addPaneToMaster(MasterPane master, List <double> degree, List <string> labels, string titlePrefix)
        {
            GraphPane myPane = new GraphPane();

            myPane.Title.Text       = titlePrefix;
            myPane.XAxis.Title.Text = "site";
            myPane.YAxis.Title.Text = titlePrefix + "Visible neighbourhood";
            myPane.XAxis.Scale.Max  = 27;
            myPane.Border.IsVisible = false;
            LineItem myLine = myPane.AddCurve("", null, degree.ToArray(), Color.Red, SymbolType.Circle);

            myLine.Symbol.Fill.IsVisible = true;
            myLine.Symbol.Fill           = new Fill(Color.Red);
            for (int s = 0; s < myLine.Points.Count; s++)
            {
                ZedGraph.PointPair pt   = myLine.Points[s];
                ZedGraph.TextObj   text = new ZedGraph.TextObj(labels[s], pt.X, pt.Y,
                                                               ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                text.FontSpec.FontColor = Color.Black;
                text.ZOrder             = ZedGraph.ZOrder.A_InFront;
                // Hide the border and the fill
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.Size             = 15f;
                text.FontSpec.Angle            = 90;

                string lblString = "name";

                Link lblLink = new Link(lblString, "#", "");
                text.Link = lblLink;
                myPane.GraphObjList.Add(text);
            }

            myLine.Line.IsVisible = false;
            myLine.Symbol.Size    = 5f;
            master.Add(myPane);
        }
Beispiel #10
0
 private void AddHorizontalText(GraphPane gp, string label, double x, Color color)
 {
     TextObj text = new TextObj(label, x, 0.05);
     // use ChartFraction coordinates so the text is placed relative to the Chart.Rect
     text.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
     // rotate the text 90 degrees
     text.FontSpec.Angle = 0.0F;
     text.FontSpec.FontColor = color;
     text.FontSpec.IsBold = true;
     text.FontSpec.Size = 10;
     // 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;
     gp.GraphObjList.Add(text);
 }
Beispiel #11
0
        private bool ZG_MouseUpEvent(ZedGraphControl control, MouseEventArgs e)
        {
            if (!e.Button.Equals(MouseButtons.Left))
            {
                return(false);
            }

            // indicate to the mouse movement event that we finished with the measurer-beam
            m_MeasurerActivated = false;

            // calculate the distance
            var ds = 1.0;

            if ((m_Control.GraphPane.XAxis.Type == AxisType.Date) ||
                (m_Control.GraphPane.XAxis.Type == AxisType.DateAsOrdinal))
            {
                switch (m_Control.GraphPane.XAxis.Scale.MajorUnit)
                {
                case DateUnit.Year:
                    ds = 1.0 / 365.0;
                    break;

                case DateUnit.Day:
                    ds = 1.0;
                    break;

                case DateUnit.Hour:
                    ds = 24.0;
                    break;

                case DateUnit.Minute:
                    ds = 24.0 * 60.0;
                    break;

                case DateUnit.Second:
                    ds = 24.0 * 60.0 * 60.0;
                    break;

                case DateUnit.Millisecond:
                    ds = 24.0 * 60.0 * 60.0 * 1000.0;
                    break;
                }
            }
            double dx       = (m_MeasurerBeam.Points[1].X - m_MeasurerBeam.Points[0].X) * ds;
            double dy       = m_MeasurerBeam.Points[1].Y - m_MeasurerBeam.Points[0].Y;
            double distance = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));

            // if this is only a point and not an actual measurer beam - remove it
            // otherwise, add it to our "watch-list"
            if (distance == 0.0)
            {
                m_Control.GraphPane.CurveList.Remove(m_MeasurerBeam);
            }
            else
            {
                // calculate the position for the text
                double cx = (m_MeasurerBeam.Points[1].X + m_MeasurerBeam.Points[0].X) / 2;
                double cy = (m_MeasurerBeam.Points[1].Y + m_MeasurerBeam.Points[0].Y) / 2;

                // calculate the angle for the text (must be done in screen coordinates)
                PointF p1 = control.GraphPane.GeneralTransform(m_MeasurerBeam.Points[0].X,
                                                               m_MeasurerBeam.Points[0].Y, Coord);
                PointF p2 = control.GraphPane.GeneralTransform(m_MeasurerBeam.Points[1].X,
                                                               m_MeasurerBeam.Points[1].Y, Coord);

                // add text to describe the distance (if one dimension is much bigger than the other
                // AND axes type are different - create a text only for the bigger dimension)
                var text = new TextObj($"{distance:N3}", cx, cy,
                                       Coord, AlignH.Center, AlignV.Bottom);
                if (!m_Control.GraphPane.YAxis.Type.Equals(m_Control.GraphPane.XAxis.Type))
                {
                    double dpx = Math.Abs(p2.X - p1.X);
                    double dpy = Math.Abs(p2.Y - p1.Y);
                    if (dpx > 20.0 * dpy)
                    {
                        text.Text =
                            $"{Math.Abs(dx):N3} [ {m_Control.GraphPane.XAxis.Scale.MajorUnit}s ]";
                    }
                    else if (dpy > 20.0 * dpx)
                    {
                        text.Text = $"{Math.Abs(dy):N3} [ {m_Control.GraphPane.YAxis.Type} ]";
                    }
                }
                text.FontSpec.Angle = 0.0f;
                // Convert.ToSingle(-Math.Atan((p2.Y - p1.Y) / (p2.X - p1.X)) * 180.0 / Math.PI);
                text.FontSpec.FontColor        = m_FontColor;
                text.FontSpec.Size             = m_FontSize;
                text.FontSpec.Border.IsVisible = false;
                m_Control.GraphPane.GraphObjList.Add(text);

                // add tooltip to describe the distance (and add a point in the middle)
                var dXdYstr =
                    $"Distance: {distance:N3}\ndy: {Math.Abs(dy):N3} [{m_Control.GraphPane.YAxis.Type}]\n" +
                    $"dx: {Math.Abs(dx):N3} [{m_Control.GraphPane.XAxis.Scale.MajorUnit}]";

                m_MeasurerBeam.AddPoint(cx, cy);
                for (int i = 0; i < 3; i++)
                {
                    m_MeasurerBeam.Points[i].Tag = dXdYstr;
                }

                // add curve and its text to the "watch-list"
                m_MeasurerBeamTextList.Add(text);
                m_MeasurerBeamList.Add(m_MeasurerBeam);
            }

            // force a redraw
            control.Refresh();

            // tell the ZedGraphControl not to do anything else with this event
            return(true);
        }
        private void DrawLineTempGraph(int n, double data)
        {
            double amountTime;
            double.TryParse(n.ToString(), out amountTime);

            if (zgcTemperature.GraphPane.CurveList.Count <= 0)
                return;

            LineItem curve = zgcTemperature.GraphPane.CurveList[0] as LineItem;

            if (curve == null)
                return;

            IPointListEdit list = curve.Points as IPointListEdit;

            if (list == null)
                return;

            list.Add(amountTime, data);

            curve.Line.Width = lineWidth;
            curve.Symbol.Fill.Type = FillType.Solid;
            curve.Symbol.Size = pointWidth;

            double time = (Environment.TickCount - tickStart) / 1000.0;

            // Keep the X scale at a rolling 30 second interval, with one
            // major step between the max X value an the end of the axis
            Scale scale = zgcTemperature.GraphPane.XAxis.Scale;
            if (time > scale.Max - scale.MajorStep)
            {
                scale.Max = time + scale.MajorStep;
                scale.Min = scale.Max - 30.0;
            }

            int step = 0;

            if (n < 20)
                step = 1;
            else
                step = (int)(n / 20);

            const double offset = 0.05;

            // Draw Text Value
            for (int i = n - 1; i < n; i += step)
            {
                PointPair pt = curve.Points[i];

                TextObj text = new TextObj(pt.Y.ToString("f2"), pt.X, pt.Y + offset, CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
                text.ZOrder = ZOrder.A_InFront;

                text.FontSpec.Size = 10;
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible = false;
                text.FontSpec.Angle = 45;

                text.IsClippedToChartRect = true;

                tempPane.GraphObjList.Add(text);
            }

            //// Draw a box item to highlight a value range
            //BoxObj box = new BoxObj(0, 35, time*2, 10, Color.Empty, Color.FromArgb(150, Color.LightGreen));
            //box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);
            //// Use the BehindGrid zorder to draw the highlight beneath the grid lines
            //box.ZOrder = ZOrder.F_BehindGrid;
            //tempPane.GraphObjList.Add(box);

            zgcTemperature.AxisChange();
            zgcTemperature.Invalidate();
        }
Beispiel #13
0
        private void Form1_Load( object sender, EventArgs e )
        {
            // Get a reference to the GraphPane instance in the ZedGraphControl
            GraphPane myPane = zg1.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text = "Demonstration of Dual Y Graph";
            myPane.XAxis.Title.Text = "Time, Days";
            myPane.YAxis.Title.Text = "Parameter A";
            myPane.Y2Axis.Title.Text = "Parameter B";

            // Make up some data points based on the Sine function
            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            for ( double i = -2; i < 2; i+=0.1 )
            {
                double x = (double)i * 5.0;
                //double y = Math.Sin( (double)i * Math.PI / 15.0 ) * 16.0;

                double y = ((2 / (1 + Math.Exp(  x))) - 1);
                double y2 = y * 13.5;
                list.Add( x, y );
                list2.Add( x, y2 );
            }

            // Generate a red curve with diamond symbols, and "Alpha" in the legend
            LineItem myCurve = myPane.AddCurve( "Alpha",
                list, Color.Red, SymbolType.Diamond );
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill( Color.White );

            // Generate a blue curve with circle symbols, and "Beta" in the legend
            myCurve = myPane.AddCurve( "Beta",
                list2, Color.Blue, SymbolType.Circle );
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill( Color.White );
            // Associate this curve with the Y2 axis
            myCurve.IsY2Axis = true;

            // 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;
            // Manually set the axis range
            myPane.YAxis.Scale.Min = -30;
            myPane.YAxis.Scale.Max = 30;

            // 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;

            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill( Color.White, Color.LightGray, 45.0f );

            // Add a text box with instructions
            TextObj text = new TextObj(
                "Zoom: left mouse & drag\nPan: middle mouse & drag\nContext Menu: right mouse",
                0.05f, 0.95f, CoordType.ChartFraction, AlignH.Left, AlignV.Bottom );
            text.FontSpec.StringAlignment = StringAlignment.Near;
            myPane.GraphObjList.Add( text );

            // Enable scrollbars if needed
            zg1.IsShowHScrollBar = true;
            zg1.IsShowVScrollBar = true;
            zg1.IsAutoScrollRange = true;
            zg1.IsScrollY2 = true;

            // OPTIONAL: Show tooltips when the mouse hovers over a point
            zg1.IsShowPointValues = true;
            zg1.PointValueEvent += new ZedGraphControl.PointValueHandler( MyPointValueHandler );

            // OPTIONAL: Add a custom context menu item
            zg1.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(
                            MyContextMenuBuilder );

            // OPTIONAL: Handle the Zoom Event
            zg1.ZoomEvent += new ZedGraphControl.ZoomEventHandler( MyZoomEvent );

            // Size the control to fit the window
            SetSize();

            // Tell ZedGraph to calculate the axis ranges
            // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets
            // up the proper scrolling parameters
            zg1.AxisChange();
            // Make sure the Graph gets redrawn
            zg1.Invalidate();
        }
Beispiel #14
0
 /// <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( Graphics g, GraphPane pane )
 {
     try
     {
         ZedGraphWebGraphObj draw;
         for ( int i = 0; i < GraphObjList.Count; i++ )
         {
             draw = GraphObjList[i];
             if ( draw is ZedGraphWebTextObj )
             {
                 ZedGraphWebTextObj item = (ZedGraphWebTextObj)draw;
                 TextObj x = new TextObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebArrowObj )
             {
                 ZedGraphWebArrowObj item = (ZedGraphWebArrowObj)draw;
                 ArrowObj x = new ArrowObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebImageObj )
             {
                 ZedGraphWebImageObj item = (ZedGraphWebImageObj)draw;
                 ImageObj x = new ImageObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebBoxObj )
             {
                 ZedGraphWebBoxObj item = (ZedGraphWebBoxObj)draw;
                 BoxObj x = new BoxObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
             else if ( draw is ZedGraphWebEllipseObj )
             {
                 ZedGraphWebEllipseObj item = (ZedGraphWebEllipseObj)draw;
                 EllipseObj x = new EllipseObj();
                 item.CopyTo( x );
                 pane.GraphObjList.Add( x );
             }
         }
     }
     catch ( Exception )
     {
     }
 }
Beispiel #15
0
 /// <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 );
 }
Beispiel #16
0
 /// <summary>
 /// Create a new <see cref="GasGaugeRegion"/>
 /// </summary>
 /// <param name="label">The value associated with this <see cref="GasGaugeRegion"/> instance.</param>
 /// <param name="color">The display color for this <see cref="GasGaugeRegion"/> instance.</param>
 /// <param name="minVal">The minimum value of this <see cref="GasGaugeNeedle"/>.</param>
 /// <param name="maxVal">The maximum value of this <see cref="GasGaugeNeedle"/>.</param>
 public GasGaugeRegion(string label, double minVal, double maxVal, Color color)
     : base(label)
 {
     MinValue = minVal;
     MaxValue = maxVal;
     RegionColor = color;
     StartAngle = 0f;
     SweepAngle = 0f;
     _border = new Border(Default.BorderColor, Default.BorderWidth);
     _labelDetail = new TextObj();
     _labelDetail.FontSpec.Size = Default.FontSize;
     _slicePath = null;
 }
Beispiel #17
0
	//private bool CreateStatisticTable(StatisticInfo[] infos, int statisticTypeIndex, object[] statistic)
	//{
	//    string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };

	//    TableHeaderRow headerRow = new TableHeaderRow();
	//    TableHeaderCell headerCell = new TableHeaderCell();
	//    headerCell.Text = StatisticTypeNames[statisticTypeIndex];
	//    headerRow.Cells.Add(headerCell);

	//    headerCell = new TableHeaderCell();
	//    headerCell.Text = StringDef.Count;
	//    headerRow.Cells.Add(headerCell);

	//    TableStatistic.Rows.Add(headerRow);

	//    for (int i = 0; i < infos.Length; i++)
	//    {
	//        StatisticInfo info = infos[i];
	//        TableRow row = new TableRow();

	//        TableCell cell = new TableCell();
	//        for (int j = 0; j < statistic.Length; j++)
	//        {
	//            if (statistic[j].Id == info.Type)
	//            {
	//                cell.Text = statistic[j].Name;
	//                row.Cells.Add(cell);
	//                break;
	//            }
	//        }

	//        cell = new TableCell();
	//        cell.Text = info.Count.ToString();
	//        row.Cells.Add(cell);

	//        TableStatistic.Rows.Add(row);
	//    }

	//    return true;
	//}

	protected void ZedGraphWebStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
	{
		if (_server != null)
		{
			GraphPane graphPane = masterPane[0];

			string[] StatisticTypeNames = new string[] { StringDef.Level, StringDef.RoleClass, StringDef.Sex, StringDef.Map };
			string staticType = StatisticTypes[_statisticType];
			string staticTypeName = StatisticTypeNames[_statisticType];
			SqlCommand cmd = new SqlCommand("SELECT " + staticType + ",COUNT(*) FROM rolesfirst " + _whereStatement + " GROUP BY " + staticType);
            if (!_server.IsConnected)
            {
                //LabelMessage.Visible = true;
                //LabelMessage.Text = StringDef.NoConnectionAlert;
                return;
            }
			SqlResult result = WebUtil.QueryGameServerDb(CurrentUser.Id,_server, cmd);

			if (result != null && result.Success)
			{
				//整理数据
				SqlDataType[] dataTypes = new SqlDataType[] { SqlDataType.Int32, SqlDataType.Int32 };
				result.SetFieldType(dataTypes);

				object[] statistic = null;
				switch (_statisticType)
				{
					case 0:
						{
							statistic = new object[FS2GameDataManager.MaxLevel];
							for (int level = 1; level <= FS2GameDataManager.MaxLevel; level++)
							{
								statistic[level - 1] = level;
							}
						}
						break;
					case 1:
						{
							statistic = new object[FS2GameDataManager.RoleClasses.Length];
							for (int i = 0; i < FS2GameDataManager.RoleClasses.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleClasses[i];
							}
						}
						break;
					case 2:
						{
							statistic = new object[FS2GameDataManager.RoleSexes.Length];
							for (int i = 0; i < FS2GameDataManager.RoleSexes.Length; i++)
							{
								statistic[i] = FS2GameDataManager.RoleSexes[i];
							}
						}
						break;
					case 3:
						statistic = new object[] { 0, 1, 2, 3, 4 };
						break;
				}
				
				StatisticInfo[] infos = new StatisticInfo[statistic.Length];
				for (int i = 0; i < infos.Length; i++)
				{
					infos[i] = new StatisticInfo(int.Parse(statistic[i].ToString()), 0);
				}

				object[] record = null;
				while ((record = result.ReadRecord()) != null)
				{
					int type = (int)record[0];
					int count = (int)record[1];

					for (int i = 0; i < infos.Length; i++)
					{
						if (infos[i].Type == type)
						{
							infos[i].Count = count;
						}
					}
				}

				////构造数据表格
				//bool success = CreateStatisticTable(infos, _statisticType, statistic);
				//if (success)
				//{
				//    TableStatistic.Visible = true;
				//}

				graphPane.Title.Text = staticTypeName;
				graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);

				graphPane.Legend.IsVisible = false;

				string[] textLabels = new string[statistic.Length];
				for (int i = 0; i < statistic.Length; i++)
				{
					textLabels[i] = statistic[i].ToString();
				}

				graphPane.XAxis.Title.Text = staticTypeName;
				graphPane.XAxis.MajorGrid.Color = WebConfig.GraphXAxisGridColor;

				if (_statisticType > 0)
				{
					graphPane.XAxis.MajorTic.IsBetweenLabels = true;
					graphPane.XAxis.Type = AxisType.Text;
					graphPane.XAxis.Scale.TextLabels = textLabels;
				}

				graphPane.YAxis.Title.Text = StringDef.Count;
				graphPane.YAxis.Scale.Min = 0;
				graphPane.YAxis.MajorGrid.IsVisible = true;
				graphPane.YAxis.MajorGrid.DashOff = 0;
				graphPane.YAxis.MajorGrid.Color = Color.Gray;
				graphPane.YAxis.MinorGrid.IsVisible = true;
				graphPane.YAxis.MinorGrid.Color = Color.LightGray;
				graphPane.YAxis.MinorGrid.DashOff = 0;

				if (_chartType == ChartType.Bar)
				{
					graphPane.BarSettings.Type = BarType.Stack;

					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制柱子
					BarItem barItem = graphPane.AddBar(StringDef.Count, types, counts, WebConfig.GraphColors[0]);
					barItem.Bar.Fill = new Fill(WebConfig.GraphColors[0]);
				}
				else if (_chartType == ChartType.Line)
				{
					double[] counts = new double[infos.Length];
					double[] types = new double[infos.Length];

					for (int i = 0; i < infos.Length; i++)
					{
						StatisticInfo info = infos[i] as StatisticInfo;
						counts[i] = info.Count;
						types[i] = info.Type;

						//添加数值标签
						string lab = info.Count.ToString();
						TextObj text = new TextObj(lab, i + 1, (float)(info.Count)); ;
						text.Location.CoordinateFrame = CoordType.AxisXYScale;
						text.FontSpec.Border.IsVisible = false;
						text.FontSpec.Fill.IsVisible = false;
						if (_statisticType == 0)
						{
							text.Location.AlignH = AlignH.Left;
							text.Location.AlignV = AlignV.Center;
							text.FontSpec.Angle = 90f;
						}
						else
						{
							text.Location.AlignH = AlignH.Center;
							text.Location.AlignV = AlignV.Bottom;
						}
						graphPane.GraphObjList.Add(text);
					}

					//绘制线条
					LineItem lineItem = graphPane.AddCurve("xxx", types, counts, WebConfig.GraphColors[1], SymbolType.None);
				}

				graphPane.AxisChange(g);
			}
		}
	}
Beispiel #18
0
 /// <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);
 }
Beispiel #19
0
        /// <summary>
        /// 
        /// </summary>

        protected void PlotStrategyTradepoints(application.Strategy.Data.TradePoints tradePoints, baseClass.controls.graphPanel toPanel)
        {
            ClearStrategyTradepoints(toPanel);
            Charts.DrawCurve[] curveList = myCurveList.CurveInPane(toPanel.Name);
            if (curveList.Length == 0) return;
            CurveItem curveItem = curveList[0].Curve;

            TradePointInfo tradePointInfo;
            for (int idx = 0; idx < tradePoints.Count; idx++)
            {
                tradePointInfo = (TradePointInfo)tradePoints[idx];
                if (!tradePointInfo.isValid) continue;

                TextObj obj = new TextObj();
                obj.FontSpec.Size = Settings.sysTradePointMarkerFontSize;
                obj.FontSpec.IsBold = true;
                obj.FontSpec.Border.IsVisible = true;
                obj.FontSpec.Fill.IsVisible = true;
                obj.FontSpec.Fill.Color = Settings.sysTradePointMarkerColorBG;
                switch (toPanel.myGraphObj.myViewportState.myAxisType)
                {
                    case Charts.AxisType.DateAsOrdinal :
                        obj.Location.X = tradePointInfo.DataIdx+1; 
                        break;
                    default:
                        obj.Location.X = curveItem.Points[tradePointInfo.DataIdx].X;
                        break;
                }
                obj.Location.Y = curveItem.Points[tradePointInfo.DataIdx].Y;
                obj.Location.CoordinateFrame = CoordType.AxisXYScale;
                obj.Location.AlignH = AlignH.Center;
                switch (tradePointInfo.TradeAction)
                {
                    case AppTypes.TradeActions.Buy:
                    case AppTypes.TradeActions.Accumulate:
                        obj.Text = Settings.sysTradePointMarkeBUY;
                        obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorBUY;
                        break;
                    case AppTypes.TradeActions.Sell:
                    case AppTypes.TradeActions.ClearAll:
                        obj.Text = Settings.sysTradePointMarkerSELL;
                        obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorSELL;
                        break;
                    default:
                        obj.Text = Settings.sysTradePointMarkerOTHER;
                        obj.FontSpec.FontColor = Settings.sysTradePointMarkerColorOTHER;
                        break;
                }
                toPanel.myGraphObj.myGraphPane.GraphObjList.Add(obj);
            }
            toPanel.myGraphObj.UpdateChart();
        }
Beispiel #20
0
        private void InitializeGraph()
        {
            this.myPane = this.ZGraph.GraphPane;
            // Set the titles and axis labels
            this.myPane.Title.Text = "Ping results";
            this.myPane.XAxis.Title.Text = "Counter";
            this.myPane.YAxis.Title.Text = "Time, Milliseconds";

            // Show the x axis grid
            this.myPane.XAxis.MajorGrid.IsVisible = true;

            // Make the Y axis scale red
            this.myPane.YAxis.Scale.FontSpec.FontColor = Color.Blue;
            this.myPane.YAxis.Title.FontSpec.FontColor = Color.Blue;
            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            this.myPane.YAxis.MajorTic.IsOpposite = false;
            this.myPane.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            this.myPane.YAxis.MajorGrid.IsZeroLine = false;
            // Align the Y axis labels so they are flush to the axis
            this.myPane.YAxis.Scale.Align = AlignP.Inside;

            // Fill the axis background with a gradient
            this.myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f);

            // Add a text box with instructions
            TextObj text = new TextObj(
                "Zoom: left mouse & drag\nPan: middle mouse & drag\nContext Menu: right mouse",
                0.02f, 0.15f, CoordType.ChartFraction, AlignH.Left, AlignV.Bottom)
                               {
                                   FontSpec =
                                       {
                                           Size = 8,
                                           StringAlignment = StringAlignment.Near
                                       }
                               };
            this.myPane.GraphObjList.Add(text);

            // Enable scrollbars if needed
            this.ZGraph.IsShowHScrollBar = true;
            this.ZGraph.IsShowVScrollBar = true;

            // OPTIONAL: Show tooltips when the mouse hovers over a point
            this.ZGraph.IsShowPointValues = true;
            this.ZGraph.PointValueEvent += this.MyPointValueHandler;

            // OPTIONAL: Add a custom context menu item
            //this.ZGraph.ContextMenuBuilder += new ZedGraphControl.ContextMenuBuilderEventHandler(this.MyContextMenuBuilder);

            // Size the control to fit the window
            this.SetSize();
        }
Beispiel #21
0
        /// <summary>
        /// Create the heat map or single scan graph.
        /// </summary>
        private void CreateGraph()
        {
            if (_msDataFileScanHelper.MsDataSpectra == null)
                return;

            GraphPane.CurveList.Clear();
            GraphPane.GraphObjList.Clear();

            bool hasDriftDimension = _msDataFileScanHelper.MsDataSpectra.Length > 1;
            bool useHeatMap = hasDriftDimension && !Settings.Default.SumScansFullScan;

            filterBtn.Visible = spectrumBtn.Visible = hasDriftDimension;
            graphControl.IsEnableVPan = graphControl.IsEnableVZoom = useHeatMap;
            GraphPane.Legend.IsVisible = useHeatMap;

            if (hasDriftDimension)
            {
                // Is there actually any drift time filtering available?
                double minDriftTime, maxDriftTime;
                _msDataFileScanHelper.GetDriftRange(out minDriftTime, out maxDriftTime, ChromSource.unknown); // Get range of drift times for all products and precursors
                if ((minDriftTime == double.MinValue) && (maxDriftTime == double.MaxValue))
                {
                    filterBtn.Visible = false;
                    filterBtn.Checked = false;
                }
            }

            if (useHeatMap)
            {
                ZoomYAxis(); // Call this again now that cues are there to indicate need for drift scale
                CreateDriftTimeHeatmap();
            }
            else
            {
                CreateSingleScan();
            }

            // Add extraction boxes.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                    continue;
                var color1 = Blend(transition.Color, Color.White, 0.60);
                var color2 = Blend(transition.Color, Color.White, 0.95);
                var extractionBox = new BoxObj(
                    transition.ProductMz - transition.ExtractionWidth.Value / 2,
                    0.0,
                    transition.ExtractionWidth.Value,
                    1.0,
                    Color.Transparent,
                    transition.Color,
                    Color.White)
                {
                    Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                    ZOrder = ZOrder.F_BehindGrid,
                    Fill = new Fill(color1, color2, 90),
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(extractionBox);
            }

            // Add labels.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                    continue;
                var label = new TextObj(transition.Name, transition.ProductMz, 0.02, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Top)
                {
                    ZOrder = ZOrder.D_BehindAxis,
                    IsClippedToChartRect = true,
                    Tag = i
                };
                label.FontSpec.Border.IsVisible = false;
                label.FontSpec.FontColor = Blend(transition.Color, Color.Black, 0.30);
                label.FontSpec.IsBold = true;
                label.FontSpec.Fill = new Fill(Color.FromArgb(180, Color.White));
                GraphPane.GraphObjList.Add(label);
            }

            double retentionTime = _msDataFileScanHelper.MsDataSpectra[0].RetentionTime ?? _msDataFileScanHelper.ScanProvider.Times[_msDataFileScanHelper.ScanIndex];
            GraphPane.Title.Text = string.Format(Resources.GraphFullScan_CreateGraph__0_____1_F2__min_, _msDataFileScanHelper.FileName, retentionTime);

            FireSelectedScanChanged(retentionTime);
        }
Beispiel #22
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="ggr">The <see cref="GasGaugeRegion"/> object from which to copy</param>
 public GasGaugeRegion(GasGaugeRegion ggr)
     : base(ggr)
 {
     _minValue = ggr._minValue;
     _maxValue = ggr._maxValue;
     _color = ggr._color;
     _startAngle = ggr._startAngle;
     _sweepAngle = ggr._sweepAngle;
     _border = ggr._border.Clone();
     _labelDetail = ggr._labelDetail.Clone();
 }
Beispiel #23
0
        /// <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++;
                }
            }
        }
Beispiel #24
0
        public void initGui()
        {
            //the GraphPane
            profileLine = new PointPairList();
            userClickrList = new PointPairList();

            grpCurve = profileGrp.GraphPane.AddCurve("", profileLine, Color.FromArgb(0,0,0,0), SymbolType.XCross);
            grpCurve.Symbol.Border.Color = Color.Black;
            grpCurve.Line.Fill = new Fill(Color.FromArgb(100, 227, 185, 113));

            profileGrp.GraphPane.Y2Axis.MajorGrid.IsZeroLine = false;
            userClickCurve = profileGrp.GraphPane.AddCurve("", userClickrList, Color.Blue, SymbolType.None);

            profileGrp.GraphPane.Legend.IsVisible = false;
            profileGrp.GraphPane.Title.Text = "Profiel Titel";
            profileGrp.GraphPane.XAxis.Title.Text = "Afstand (m)";
            profileGrp.GraphPane.YAxis.Title.Text = "Hoogte (m)";

            hlabel = new TextObj() { ZOrder = ZOrder.A_InFront };
            profileGrp.GraphPane.GraphObjList.Add(hlabel);

            symbolBtn.SelectedIndex = 0;
        }
Beispiel #25
0
        /// <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 GasGaugeRegion(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));
            _color = (Color) info.GetValue("color", typeof (Color));
            _minValue = info.GetDouble("minValue");
            _maxValue = info.GetDouble("maxValue");
            _startAngle = (float) info.GetDouble("startAngle");
            _sweepAngle = (float) info.GetDouble("sweepAngle");
            _boundingRectangle = (RectangleF) info.GetValue("boundingRectangle", typeof (RectangleF));
            _slicePath = (GraphicsPath) info.GetValue("slicePath", typeof (GraphicsPath));
        }
        public static void DisplayInPicture(List<CorePointData> lstCorePt, ZedGraphControl zedGraphControlCore, bool IsClosed)
        {
            GraphPane myPane = zedGraphControlCore.GraphPane;

            //清除原来的图形
            myPane.CurveList.Clear();
            myPane.GraphObjList.Clear();

            //设置网格线可见
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            //设置网格线颜色
            myPane.XAxis.MajorGrid.Color = Color.Chocolate;
            myPane.YAxis.MajorGrid.Color = Color.Chocolate;

            //设置网格线形式
            myPane.XAxis.MajorGrid.DashOff = 1;
            myPane.YAxis.MajorGrid.DashOff = 1;
            myPane.XAxis.MajorGrid.DashOn = 4;
            myPane.YAxis.MajorGrid.DashOn = 4;

            //设置显示坐标
            myPane.XAxis.Scale.IsUseTenPower = false;
            myPane.YAxis.Scale.IsUseTenPower = false;
            myPane.XAxis.Scale.MagAuto = true;
            myPane.YAxis.Scale.MagAuto = true;

            myPane.Title.Text = "重心包线";
            myPane.XAxis.Title.Text = "长度(毫米)";
            myPane.YAxis.Title.Text = "重量(千克)";

            PointPairList listCur = new PointPairList();

            double x = 0, y = 0;
            string strTitle = string.Empty;
            string strValue = string.Empty;
            if (lstCorePt != null && lstCorePt.Count > 0)
            {
                for (int j = 0; j < lstCorePt.Count; j++)
                {
                    x = Math.Round(lstCorePt[j].pointXValue, picDigit);
                    y = Math.Round(lstCorePt[j].pointYValue, picDigit);
                    listCur.Add(x, y);

                    //显示名称
                    strTitle = lstCorePt[j].pointName;
                    // 创建一个阴影区域,看起来有渐变
                    TextObj text = new TextObj(strTitle, x, y,
                        CoordType.AxisXYScale, AlignH.Right, AlignV.Center);
                    //是否有背景
                    text.FontSpec.Fill.IsVisible = false;
                    //是否有边框
                    text.FontSpec.Border.IsVisible = false;
                    //文字是否粗体
                    text.FontSpec.IsBold = true;
                    //文字是否斜体
                    text.FontSpec.IsItalic = false;
                    //填充
                    myPane.GraphObjList.Add(text);
                }

                //是否成环形图形
                if (IsClosed)
                {
                    listCur.Add(Math.Round(lstCorePt[0].pointXValue, picDigit), Math.Round(lstCorePt[0].pointYValue, picDigit));
                }
                LineItem myCurveCur = myPane.AddCurve(string.Empty, listCur, Color.Blue, SymbolType.Default);
                myCurveCur.Symbol.Size = 6;
                myCurveCur.Symbol.Fill = new Fill(Color.Blue, Color.Blue);
                myCurveCur.Symbol.Border.IsVisible = true;
                myCurveCur.Line.IsVisible = true;
            }
            zedGraphControlCore.AxisChange();
            zedGraphControlCore.Refresh();
        }
Beispiel #27
0
        public override void Draw(Graphics g)
        {
            GraphObjList.Clear();

            if (_graphData != null)
            {
                // Force Axes to recalculate to ensure proper layout of labels
                AxisChange(g);

                // Reposition the regression label.
                RectangleF rectChart = Chart.Rect;
                PointF ptTop = rectChart.Location;

                // Setup axes scales to enable the ReverseTransform method
                XAxis.Scale.SetupScaleData(this, XAxis);
                YAxis.Scale.SetupScaleData(this, YAxis);

                float yNext = ptTop.Y;
                double left = XAxis.Scale.ReverseTransform(ptTop.X + 8);
                FontSpec fontSpec = GraphSummary.CreateFontSpec(COLOR_LINE_REGRESSION);
                if (_labelRegression != null)
                {
                    // Add regression text
                    double top = YAxis.Scale.ReverseTransform(yNext);
                    TextObj text = new TextObj(_labelRegression, left, top,
                                               CoordType.AxisXYScale, AlignH.Left, AlignV.Top)
                    {
                        IsClippedToChartRect = true,
                        ZOrder = ZOrder.E_BehindCurves,
                        FontSpec = fontSpec,
                    };
                    //                text.FontSpec.Size = 12;
                    GraphObjList.Add(text);
                }

                if (_labelRegressionCurrent != null)
                {
                    // Add text for current regression
                    SizeF sizeLabel = fontSpec.MeasureString(g, _labelRegression, CalcScaleFactor());
                    yNext += sizeLabel.Height + 3;
                    double top = YAxis.Scale.ReverseTransform(yNext);
                    TextObj text = new TextObj(_labelRegressionCurrent, left, top,
                                               CoordType.AxisXYScale, AlignH.Left, AlignV.Top)
                    {
                        IsClippedToChartRect = true,
                        ZOrder = ZOrder.E_BehindCurves,
                        FontSpec = GraphSummary.CreateFontSpec(COLOR_LINE_REGRESSION_CURRENT),
                    };
            //                    text.FontSpec.Size = 12;
                    GraphObjList.Add(text);
                }
            }

            base.Draw(g);
        }
Beispiel #28
0
		/// <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++;
				}
			}
		}
Beispiel #29
0
        void GenerateGraphData()
        {
            PointPairList stab = new PointPairList();
            stab.Add(0, MainV2.comPort.MAV.param["IM_STAB_COL_1"].Value);
            stab.Add(40, MainV2.comPort.MAV.param["IM_STAB_COL_2"].Value);
            stab.Add(60, MainV2.comPort.MAV.param["IM_STAB_COL_3"].Value);
            stab.Add(100, MainV2.comPort.MAV.param["IM_STAB_COL_4"].Value);

            PointPairList acro = new PointPairList();

            double _acro_col_expo = MainV2.comPort.MAV.param["IM_ACRO_COL_EXP"].Value;

            // 100 point curve
            for (int a = 0; a <= 100; a++)
            {
                double col_in = (a-50.0)/50.0;
                double col_in3 = col_in*col_in*col_in;
                double col_out = (_acro_col_expo*col_in3) + ((1 - _acro_col_expo)*col_in);
                double acro_col_out = 500 + col_out*500;

                acro.Add(a, acro_col_out);
            }

            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();

            var myCurve = zedGraphControl1.GraphPane.AddCurve("Stabalize Collective", stab, Color.DodgerBlue, SymbolType.Circle);

            foreach (PointPair pp in stab)
            {
                // Add a another text item to to point out a graph feature
                TextObj text = new TextObj(pp.X.ToString(), pp.X, pp.Y);
                // rotate the text 90 degrees
                text.FontSpec.Angle = 0;
                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;
                zedGraphControl1.GraphPane.GraphObjList.Add(text);
            }

            zedGraphControl1.GraphPane.AddCurve("Acro Collective", acro, Color.Yellow, SymbolType.None);

            double posx = map(MainV2.comPort.MAV.cs.ch6out, MainV2.comPort.MAV.param["H_COL_MIN"].Value,
                MainV2.comPort.MAV.param["H_COL_MAX"].Value, 0, 100);

            // set current marker
            var m_cursorLine = new LineObj(Color.Black, posx, 0, posx, 1);

            m_cursorLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction; // This do the trick !
            m_cursorLine.IsClippedToChartRect = true;
            m_cursorLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            m_cursorLine.Line.Width = 2f;
            m_cursorLine.Line.Color = Color.Red;
            m_cursorLine.ZOrder = ZOrder.E_BehindCurves;
            zedGraphControl1.GraphPane.GraphObjList.Add(m_cursorLine);

            try
            {
                //zedGraphControl1.AxisChange();
            }
            catch
            {
            }
            // Force a redraw
            zedGraphControl1.Invalidate();
        }
Beispiel #30
0
        /// <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 );
        }
Beispiel #31
0
 /// <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;
 }
Beispiel #32
0
        private static void AddLine(GraphPane g, double val, Color color, string label = null)
        {
            var line = new LineObj(0, val, 1, val);
            line.IsClippedToChartRect = true;
            line.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            line.Line.Color = color;
            line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            g.GraphObjList.Add(line);

            if (!string.IsNullOrWhiteSpace(label))
            {
                var text = new TextObj(label, 0.01, val);
                text.IsClippedToChartRect = true;
                text.Location.CoordinateFrame = CoordType.XChartFractionYScale;
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Bottom;
                text.FontSpec.FontColor = color;
                text.FontSpec.Fill.IsVisible = false;
                text.FontSpec.Size = 18.0f;
                text.FontSpec.Border.IsVisible = false;
                g.GraphObjList.Add(text);
            }
        }
Beispiel #33
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="PieItem"/> object from which to copy</param>
 public PieItem( PieItem rhs )
     : base(rhs)
 {
     _pieValue = rhs._pieValue;
     _fill = rhs._fill.Clone();
     this.Border = rhs._border.Clone();
     _displacement = rhs._displacement;
     _labelDetail = rhs._labelDetail.Clone();
     _labelType = rhs._labelType;
     _valueDecimalDigits = rhs._valueDecimalDigits;
     _percentDecimalDigits = rhs._percentDecimalDigits;
 }
Beispiel #34
0
        void DrawErrors()
        {
            bool top = false;
            int a = 0;

            foreach (var item in logdata)
            {
                if (item.msgtype == "ERR")
                {
                    if (!DFLog.logformat.ContainsKey("ERR"))
                        return;

                    int index = FindInArray(DFLog.logformat["ERR"].FieldNames, "Subsys") + 1;
                    if (index == -1)
                    {
                        continue;
                    }

                    int index2 = FindInArray(DFLog.logformat["ERR"].FieldNames, "ECode") + 1;
                    if (index2 == -1)
                    {
                        continue;
                    }

                    string mode = "Err: " + ((DFLog.error_subsystem)int.Parse(item.items[index].ToString())) + "-" + item.items[index2].ToString().Trim();
                    if (top)
                    {
                        var temp = new TextObj(mode, a, zg1.GraphPane.YAxis.Scale.Max, CoordType.AxisXYScale, AlignH.Left, AlignV.Top);
                        temp.FontSpec.Fill.Color = Color.Red;
                        zg1.GraphPane.GraphObjList.Add(temp);
                    }
                    else
                    {
                        var temp = new TextObj(mode, a, zg1.GraphPane.YAxis.Scale.Max, CoordType.AxisXYScale, AlignH.Left, AlignV.Bottom);
                        temp.FontSpec.Fill.Color = Color.Red;
                        zg1.GraphPane.GraphObjList.Add(temp);
                    }
                    top = !top;
                }
                a++;
            }
        }
Beispiel #35
0
        /// <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" );
        }