示例#1
0
 private void drawGraph()
 {
     Dictionary<double, double> coordinats = new Dictionary<double, double>();
     for (double x = xMin; x <= xMax; x += top)
     {
         if (x!=0)
         coordinats.Add(x, a/x);
     }
     GraphPane myPane = new GraphPane();
     zedGraphControl1.GraphPane = myPane;
     myPane.XAxis.Title.Text = "Координата X";
     myPane.YAxis.Title.Text = "Координата Y";
       //  myPane.Fill = new Fill(Color.White, Color.LightSkyBlue, 45.0f);
     myPane.Chart.Fill.Type = FillType.None;
     myPane.Legend.Position = LegendPos.Float;
     myPane.Legend.IsHStack = false;
     if (comboBox1.GetItemText(comboBox1.SelectedIndex) == "1")
     {
         myPane.AddBar("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor);
     }
     else
     {
         LineItem myCurve = myPane.AddCurve("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor, SymbolType.None);
         myCurve.Line.Width = penWeight;
         myCurve.Symbol.Fill = new Fill(Color.White);
     }
     zedGraphControl1.AxisChange();
     zedGraphControl1.Refresh();
     zedGraphControl1.Visible = true;
 }
示例#2
0
        public static void AddDataToBar(this ZedGraphControl zgc, PointPairList list, String title, Color color, bool update)
        {
            GraphPane myPane = zgc.GraphPane;

            BarItem barItem = myPane.AddBar(title, list, color);

            if (update)
            {
                UpdateGraph(zgc);
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        public void Draw(ZedGraph.GraphPane pane, object dataSource)
        {
            if (this.GraphPaneConfig == null)
            {
                return;
            }

            if (this.DataSource == null)
            {
                return;
            }

            this.GraphPaneConfig.ConfigGraphPane(pane);
            foreach (CurveConfigBase cfg in this.GraphPaneConfig.CurveConfigBaseCollection)
            {
                CurveDataCollection cds = cfg.Create(dataSource);
                foreach (CurveData cd in cds)
                {
                    switch (this.GraphPaneConfig.CurItemType)
                    {
                    case CurveItemType.Line:
                        if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Date)
                        {
                            ZedGraph.LineItem curve = pane.AddCurve(cd.Name, cd.PointList, cd.Color);
                            curve.Symbol.Fill = new ZedGraph.Fill(Color.White);
                        }
                        else if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Text)
                        {
                            LineItem curve = pane.AddCurve(cd.Name, null, cd.YValues, cd.Color);
                            pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                            curve.Symbol.Fill           = new Fill(Color.White);
                        }
                        break;

                    case CurveItemType.Bar:
                        pane.AddBar(cd.Name, null, cd.YValues, cd.Color);
                        pane.XAxis.Scale.TextLabels = cd.XAxisLabels;
                        break;

                    case CurveItemType.Pie:
                        pane.AddPieSlices(cd.YValues, cd.XAxisLabels);
                        break;
                    }
                }
            }
        }
示例#4
0
        public void HorizStkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "	Horizontal Stack	Bar Graph Test", "Label", "My Y Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty", "Wildcat" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10, 20 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, -35, 30 };
            double[] y3 = { 80, 0, 65, -15, 54, 67, 18, 50 };

            //	Generate three	bars	with	appropriate entries in	the legend
            BarItem myCurve = testee.AddBar( "Curve 1", y, null, Color.Red );
            BarItem myCurve1 = testee.AddBar( "Curve 2", y2, null, Color.Blue );
            BarItem myCurve2 = testee.AddBar( "Curve 3", y3, null, Color.Green );
            //	Draw the Y tics	between the labels instead of	at the labels
            testee.YAxis.MajorTic.IsBetweenLabels = true;
            testee.BarSettings.Type = BarType.Stack;

            //	Set the YAxis	labels
            testee.YAxis.Scale.TextLabels = labels;
            testee.YAxis.Scale.FontSpec.Size = 9F;
            //show	the zero	line
            testee.XAxis.MajorGrid.IsZeroLine = true;
            //show	XAxis the grid lines
            testee.XAxis.MajorGrid.IsVisible = true;
            //	Set the YAxis	to Text	type
            testee.YAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.Y;

            testee.YAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.WindowState = FormWindowState.Maximized;
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a horizontal stack bar graph having three bars per y-Axis point visible?  <Next Step: Re-orient the bar fill>" ) );

            myCurve.Bar.Fill = new Fill( Color.White, Color.Red, 90 );
            myCurve1.Bar.Fill = new Fill( Color.White, Color.Blue, 90 );
            myCurve2.Bar.Fill = new Fill( Color.White, Color.Green, 90 );
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the orientation of the fill shift from vertical to horizontal?" ) );
        }
示例#5
0
        public void PctStkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Percent Stack Bar Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            BarItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            BarItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            BarItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.PercentStack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn off	pen width scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Fill one bar segment with a Textured Brush>" ) );

            Bitmap bm = new Bitmap( @"C:\WINDOWS\FeatherTexture.bmp" );
            TextureBrush brush = new TextureBrush( bm );

            myCurve.Bar.Fill = new Fill( brush );
            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was the red segment replaced with one having a bitmap fill?<Next: Disappearing segments" ) );

            for ( int iCurve = 0; iCurve < 2; iCurve++ )
            {
                PointPairList ppList = testee.CurveList[iCurve].Points as PointPairList;

                for ( int i = 0; i < testee.CurveList[iCurve].Points.Count; i++ )
                {
                    PointPair pt = ppList[i];
                    pt.Y = 0;
                    ppList[i] = pt;

                    form2.Refresh();

                    //	delay
                    TestUtils.DelaySeconds( 500 );
                }
            }
            TestUtils.DelaySeconds( 1000 );
            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the segments disappear uniformly while the total height stayed at +/-100%?" ) );
        }
示例#6
0
文件: Form1.cs 项目: Jungwon/ZedGraph
        private void Form1_Load(object sender, EventArgs e)
        {
            CreateGraph_BasicDate();

            Trace.Listeners.Add(new TextWriterTraceListener( @"myTrace.txt" ) );
            Trace.AutoFlush = true;

            memGraphics.CreateDoubleBuffer(this.CreateGraphics(),
                this.ClientRectangle.Width, this.ClientRectangle.Height);

            #if false	// Multi Y Axis demo
            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "Demonstration of Multi Y Graph",
                "Time, s",
                "Velocity, m/s" );

            // Set the titles and axis labels
            myPane.Y2Axis.Title.Text = "Acceleration, m/s2";

            // Make up some data _points based on the Sine function
            PointPairList vList = new PointPairList();
            PointPairList aList = new PointPairList();
            PointPairList dList = new PointPairList();
            PointPairList eList = new PointPairList();

            for ( int i=0; i<30; i++ )
            {
                double time = (double) i;
                double acceleration = 2.0;
                double velocity = acceleration * time;
                double distance = acceleration * time * time / 2.0;
                double energy = 100.0 * velocity * velocity / 2.0;
                aList.Add( time, acceleration );
                vList.Add( time, velocity );
                eList.Add( time, energy );
                dList.Add( time, distance );
            }

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

            // Generate a blue curve with circle symbols, and "Acceleration" in the _legend
            myCurve = myPane.AddCurve( "Acceleration",
                aList, 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;

            // Generate a green curve with square symbols, and "Distance" in the _legend
            myCurve = myPane.AddCurve( "Distance",
                dList, Color.Green, SymbolType.Square );
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill( Color.White );
            // Associate this curve with the second Y axis
            myCurve.YAxisIndex = 1;

            // Generate a Black curve with triangle symbols, and "Energy" in the _legend
            myCurve = myPane.AddCurve( "Energy",
                eList, Color.Black, SymbolType.Triangle );
            // Fill the symbols with white
            myCurve.Symbol.Fill = new Fill( Color.White );
            // Associate this curve with the Y2 axis
            myCurve.IsY2Axis = true;
            // Associate this curve with the second Y2 axis
            myCurve.YAxisIndex = 1;

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

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

            // Enable the Y2 axis display
            myPane.Y2Axis.IsVisible = true;
            // Make the Y2 axis scale blue
            myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Blue;
            myPane.Y2Axis.Title.FontSpec.FontColor = Color.Blue;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            myPane.Y2Axis.MajorTic.IsOpposite = false;
            myPane.Y2Axis.MinorTic.IsOpposite = false;
            // Display the Y2 axis grid lines
            myPane.Y2Axis.MajorGrid.IsVisible = true;
            // Align the Y2 axis labels so they are flush to the axis
            myPane.Y2Axis.Scale.Align = AlignP.Inside;
            myPane.Y2Axis.Scale.Min = 1.5;
            myPane.Y2Axis.Scale.Max = 3;

            myPane.YAxis.IsVisible = true;
            //myPane.YAxis.IsTic = false;
            myPane.YAxis.MinorTic.IsOutside = false;
            myPane.YAxis.MajorTic.IsCrossOutside = false;
            myPane.YAxis.MinorTic.IsCrossOutside = false;
            myPane.YAxis.MajorTic.IsInside = false;
            myPane.YAxis.MinorTic.IsInside = false;
            myPane.YAxis.MajorTic.IsOpposite = false;
            myPane.YAxis.MinorTic.IsOpposite = false;

            // Create a second Y Axis, green
            YAxis yAxis3b = new YAxis( "Test Axis" );
            myPane.YAxisList.Add( yAxis3b );
            yAxis3b.Scale.FontSpec.FontColor = Color.Brown;
            yAxis3b.Title.FontSpec.FontColor = Color.Brown;
            yAxis3b.Color = Color.Brown;
            yAxis3b.MajorTic.IsOutside = false;
            yAxis3b.MinorTic.IsOutside = false;
            yAxis3b.MajorTic.IsOpposite = false;
            yAxis3b.MinorTic.IsOpposite = false;
            //yAxis3b.IsScaleLabelsInside = true;
            yAxis3b.Title.IsTitleAtCross = false;
            yAxis3b.MajorTic.IsInside = false;
            yAxis3b.MinorTic.IsInside = false;
            yAxis3b.MajorTic.IsOpposite = false;
            yAxis3b.MinorTic.IsOpposite = false;

            // Create a second Y Axis, green
            YAxis yAxis3c = new YAxis( "Test 2 Axis" );
            myPane.YAxisList.Add( yAxis3c );
            yAxis3c.Scale.FontSpec.FontColor = Color.Brown;
            yAxis3c.Title.FontSpec.FontColor = Color.Brown;
            yAxis3c.Color = Color.Brown;
            yAxis3c.MajorTic.IsOutside = false;
            yAxis3c.MinorTic.IsOutside = false;
            yAxis3c.MajorTic.IsOpposite = false;
            yAxis3c.MinorTic.IsOpposite = false;
            //yAxis3c.IsScaleLabelsInside = true;
            yAxis3c.Title.IsTitleAtCross = false;
            yAxis3c.MajorTic.IsInside = false;
            yAxis3c.MinorTic.IsInside = false;
            yAxis3c.MajorTic.IsOpposite = false;
            yAxis3c.MinorTic.IsOpposite = false;

            // Create a second Y Axis, green
            YAxis yAxis3 = new YAxis( "Distance, m" );
            myPane.YAxisList.Add( yAxis3 );
            yAxis3.Scale.FontSpec.FontColor = Color.Green;
            yAxis3.Title.FontSpec.FontColor = Color.Green;
            yAxis3.Color = Color.Green;
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            yAxis3.MajorTic.IsInside = false;
            yAxis3.MinorTic.IsInside = false;
            yAxis3.MajorTic.IsOpposite = false;
            yAxis3.MinorTic.IsOpposite = false;
            // Align the Y2 axis labels so they are flush to the axis
            yAxis3.Scale.Align = AlignP.Inside;
            //yAxis3.AxisGap = 0;

            Y2Axis yAxis4 = new Y2Axis( "Energy" );
            yAxis4.IsVisible = true;
            myPane.Y2AxisList.Add( yAxis4 );
            // turn off the opposite tics so the Y2 tics don't show up on the Y axis
            yAxis4.MajorTic.IsInside = false;
            yAxis4.MinorTic.IsInside = false;
            yAxis4.MajorTic.IsOpposite = false;
            yAxis4.MinorTic.IsOpposite = false;
            // Align the Y2 axis labels so they are flush to the axis
            yAxis4.Scale.Align = AlignP.Inside;
            yAxis4.Type = AxisType.Log;
            yAxis4.Scale.Min = 100;

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

            #if false	// SampleMultiPointList Demo
            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "Demo for SampleMultiPointList",
                "Time",
                "Distance Traveled" );
            SetSize();

            SampleMultiPointList myList = new SampleMultiPointList();
            myList.YData = PerfDataType.Distance;

            // note how it does not matter that we created the second list before actually
            // adding the data -- this is because the cloned list shares data with the
            // original
            SampleMultiPointList myList2 = new SampleMultiPointList( myList );
            myList2.YData = PerfDataType.Velocity;

            for ( int i=0; i<20; i++ )
            {
                double time = (double) i;
                double acceleration = 1.0;
                double velocity = acceleration * time;
                double distance = acceleration * time * time / 2.0;
                PerformanceData perfData = new PerformanceData( time, distance, velocity, acceleration );
                myList.Add( perfData );
            }

            myPane.AddCurve( "Distance", myList, Color.Blue );
            myPane.AddCurve( "Velocity", myList2, Color.Red );

            #endif

            #if false	// GradientByZ

            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "Wacky Widget Company\nProduction Report",
                "Time, Days\n(Since Plant Construction Startup)",
                "Widget Production\n(units/hour)" );
            SetSize();

            string[] ystr = { "one", "two", "three", "four", "five" };

            double[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            double[] y = { .1, .2, .3, .4, .5, .4, .3, .2, .1, .2 };
            //double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            double[] z = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 };
            PointPairList list = new PointPairList( x, y, z );

            Color[] colors = { Color.Red, Color.Green, Color.Blue,
                                Color.Yellow, Color.Orange };
            Fill fill = new Fill( colors );
            fill.Type = FillType.GradientByZ;
            fill.RangeMin = 1;
            fill.RangeMax = 5;

            BarItem myBar = myPane.AddBar( "My Bar", list, Color.Tomato );
            myBar.Bar.Fill = fill;
            myPane.XAxis.Type = AxisType.Ordinal;
            //myPane.YAxis.Type = AxisType.Text;
            //myPane.YAxis.TextLabels = ystr;
            //myPane.ClusterScaleWidth = 1;

            //myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// GradientByZ dual bars
            myPane = new GraphPane( new RectangleF(0,0,300,400), "Title", "X Label", "Y Label" );

            double[] xx = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            double[] yy = { 1, 2, 3, 4, 5, 4, 3, 2, 1, 2 };
            double[] yy2 = { 4, 5, 7, 8, 1, 3, 5, 2, 4, 9 };
            double[] zz = { 1, 2, 3, 4, 5, 5, 4, 3, 2, 1 };
            double[] zz2 = { 5, 1, 4, 2, 3, 4, 2, 1, 5, 5 };
            PointPairList list = new PointPairList( xx, yy, zz );
            PointPairList list2 = new PointPairList( xx, yy2, zz2 );

            Color[] colors = { Color.Red, Color.Green, Color.Blue,
                                 Color.Yellow, Color.Orange };
            Fill fill = new Fill( colors );
            fill.Type = FillType.GradientByZ;
            fill.RangeMin = 1;
            fill.RangeMax = 5;

            BarItem myBar = myPane.AddBar( "My Bar", list, Color.Tomato );
            myBar.Bar.Fill = fill;
            BarItem myBar2 = myPane.AddBar( "My Bar 2", list2, Color.Tomato );
            myBar2.Bar.Fill = fill;
            myPane.XAxis.Type = AxisType.Ordinal;
            myPane.MinBarGap = 0.1f;
            //myPane.MinClusterGap = 0;
            myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// stacked bars

            Random rand = new Random();

            myPane = new GraphPane();
            //			myPane.Title.Text = "My Title";
            //			myPane.XAxis.Title.Text = "X Axis";
            //			myPane.YAxis.Title.Text = "Y Axis";

            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();
            PointPairList list4 = new PointPairList();

            for ( int i=1; i<5; i++ )
            {
                double y = (double) i;
                double x1 = 100.0 + rand.NextDouble() * 100.0;
                double x2 = 100.0 + rand.NextDouble() * 100.0;
                double x3 = 100.0 + rand.NextDouble() * 100.0;
                double x4 = 100.0 + rand.NextDouble() * 100.0;

                list1.Add( x1, y );
                list2.Add( x2, y );
                list3.Add( x3, y );
                list4.Add( x4, y );
            }

            BarItem bar1 = myPane.AddBar( "Bar 1", list1, Color.Red );
            BarItem bar2 = myPane.AddBar( "Bar 2", list2, Color.Blue );
            BarItem bar3 = myPane.AddBar( "Bar 3", list3, Color.Green );
            BarItem bar4 = myPane.AddBar( "Bar 4", list4, Color.Beige );

            myPane.BarBase = BarBase.Y;
            myPane.BarType = BarType.Stack;

            myPane.AxisChange( this.CreateGraphics() );

            this.CreateStackBarLabels( myPane );
            #endif

            #if false	// Bars and Dates

            //			Color color = Color.FromArgb( 123, 45, 67, 89 );
            //			HSBColor hsbColor = new HSBColor( color );
            //			Color color2 = hsbColor;

            Random rand = new Random();

            myPane = new GraphPane();
            myPane.Title.Text = "My Title";
            myPane.XAxis.Title.Text = "X Axis";
            myPane.YAxis.Title.Text = "Y Axis";
            //myPane.XAxis.Type = AxisType.Ordinal;
            //myPane.XAxis.Type = AxisType.Date;
            //myPane.ClusterScaleWidth = 0.75 / 1440.0;
            //myPane.XAxis.MinorStep = 1;
            //myPane.XAxis.MinorUnit = DateUnit.Minute;

            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();

            for ( int i=1; i<10; i++ )
            {
                //double x = new XDate( 1995, 5, 10, 12, i+1, 0 );
                double x = (double) i;
                double y1 = rand.NextDouble() * 100.0;
                double y2 = rand.NextDouble() * 100.0;

                list1.Add( x-0.25, y1, 0 );
                list2.Add( x+0.17, y2, 0 );
            }

            //myPane.AddCurve( "junk", list1, Color.Green );

            HiLowBarItem bar1 = myPane.AddHiLowBar( "Bar 1", list1, Color.Red );
            //bar1.Bar.Border.IsVisible = false;
            bar1.Bar.Size = 15;
            //bar1.Bar.Fill = new Fill( Color.Red );
            HiLowBarItem bar2 = myPane.AddHiLowBar( "Bar 2", list2, Color.Blue );
            //bar2.Bar.Border.IsVisible = false;
            //bar2.Bar.Fill = new Fill( Color.Blue );
            bar2.Bar.Size = 10;

            MasterPane mPane = new MasterPane();
            mPane.Add( myPane );

            myPane.AxisChange( this.CreateGraphics() );

            //this.CreateBarLabels(mPane);
            #endif

            #if false	// bar test with no gap
            myPane = new GraphPane( new Rectangle( 40, 40, 600, 300 ),
                "Score Report", "", "" );
            // Make up some random data points
            string[] labels = { "" };
            double[] y = { 800, 900 };
            double[] y2 = { 500 };

            // Generate a red bar with "Curve 1" in the legend
            BarItem myBar = myPane.AddBar( null, y, null, Color.RoyalBlue );

            // Generate a blue bar with "Curve 2" in the legend
            myBar = myPane.AddBar( null, y2, null, Color.Red );

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

            // Set the XAxis labels
            myPane.YAxis.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.YAxis.Type = AxisType.Text;
            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill( Color.White,
                Color.FromArgb( 255, 255, 166), 90F );
            myPane.PaneFill = new Fill( Color.FromArgb( 250, 250, 255) );

            myPane.BarBase = BarBase.Y;

            myPane.MinBarGap = 0;
            myPane.MinClusterGap = 1;

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            myPane.AxisChange( CreateGraphics() );
            #endif

            #if false	// Standard Sample Graph
            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "Wacky Widget Company\nProduction Report",
                "Time, Days\n(Since Plant Construction Startup)",
                "Widget Production\n(units/hour)" );
            SetSize();

            // Set the titles and axis labels
            myPane.Title.Text = "Wacky Widget Company\nProduction Report";
            myPane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            myPane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            // Use green, with circle symbols
            curve = myPane.AddCurve( "Larry", x, y, Color.Green, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50), 90F );
            // Make it a smooth line
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            // Use a red color with triangle symbols
            curve = myPane.AddCurve( "Moe", x3, y3, Color.FromArgb( 200, 55, 135), SymbolType.Triangle );
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 160, 230, 145, 205), 90F );
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4 = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 };
            BarItem bar = myPane.AddBar( "Wheezy", x4, y4, Color.SteelBlue );
            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill( Color.RosyBrown, Color.White, Color.RosyBrown );

            // Fourth curve is a bar
            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 };
            bar = myPane.AddBar( "Curly", x2, y2, Color.RoyalBlue );
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill( Color.RoyalBlue, Color.White, Color.RoyalBlue );

            // Fill the pane background with a gradient
            myPane.PaneFill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill( Color.FromArgb( 255, 255, 245),
                Color.FromArgb( 255, 255, 190), 90F );

            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            myPane.ClusterScaleWidth = 100;
            // Bars are stacked
            myPane.BarType = BarType.Stack;

            // Enable the X and Y axis grids
            myPane.XAxis.IsShowGrid = true;
            myPane.YAxis.IsShowGrid = true;

            // Manually set the scale maximums according to user preference
            myPane.XAxis.Max = 1200;
            myPane.YAxis.Max = 120;

            // Add a text item to decorate the graph
            TextItem text = new TextItem("First Prod\n21-Oct-93", 175F, 80.0F );
            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.FontSpec.StringAlignment = StringAlignment.Near;
            myPane.GraphItemList.Add( text );

            // Add an arrow pointer for the above text item
            ArrowItem arrow = new ArrowItem( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            myPane.GraphItemList.Add( arrow );

            // Add a another text item to to point out a graph feature
            text = new TextItem("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;
            myPane.GraphItemList.Add( text );

            // Add an arrow pointer for the above text item
            arrow = new ArrowItem( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.PenWidth = 2.0F;
            myPane.GraphItemList.Add( arrow );

            // Add a text "Confidential" stamp to the graph
            text = new TextItem("Confidential", 0.85F, -0.03F );
            // use AxisFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.AxisFraction;
            // 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;
            myPane.GraphItemList.Add( text );

            // Add a BoxItem to show a colored band behind the graph data
            BoxItem box = new BoxItem( new RectangleF( 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.E_BehindAxis;
            myPane.GraphItemList.Add( box );

            // Add some text inside the above box to indicate "Peak Range"
            TextItem myText = new TextItem( "Peak Range", 1170, 105 );
            myText.Location.CoordinateFrame = CoordType.AxisXYScale;
            myText.Location.AlignH = AlignH.Right;
            myText.Location.AlignV = AlignV.Center;
            myText.FontSpec.IsItalic = true;
            myText.FontSpec.IsBold = false;
            myText.FontSpec.Fill.IsVisible = false;
            myText.FontSpec.Border.IsVisible = false;
            myPane.GraphItemList.Add( myText );

            // Calculate the Axis Scale Ranges
            Graphics g = this.CreateGraphics();
            myPane.AxisChange( g );
            g.Dispose();
            #endif

            #if false	// MasterPane
            master = new MasterPane( "ZedGraph MasterPane Example", new Rectangle( 10, 10, 10, 10 ) );

            master.PaneFill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );
            //master.IsShowTitle = true;

            //master.MarginAll = 10;
            //master.InnerPaneGap = 10;
            //master.Legend.IsVisible = true;
            //master.Legend.Position = LegendPos.TopCenter;

            /*
            TextItem text = new TextItem( "Priority", 0.88F, 0.12F );
            text.Location.CoordinateFrame = CoordType.PaneFraction;

            text.FontSpec.Angle = 15.0F;
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color = Color.Red;
            text.FontSpec.Fill.IsVisible = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            master.GraphItemList.Add( text );

            text = new TextItem("DRAFT", 0.5F, 0.5F );
            text.Location.CoordinateFrame = CoordType.PaneFraction;

            text.FontSpec.Angle = 30.0F;
            text.FontSpec.FontColor = Color.FromArgb( 70, 255, 100, 100 );
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 100;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;

            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Center;
            text.ZOrder = ZOrder.A_InFront;

            master.GraphItemList.Add( text );
            */
            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for ( int j=0; j<6; j++ )
            {
                // Create a new graph with topLeft at (40,40) and size 600x400
                GraphPane myPaneT = new GraphPane( new Rectangle( 40, 40, 600, 400 ),
                    "Case #" + (j+1).ToString(),
                    "Time, Days",
                    "Rate, m/s" );

                myPaneT.PaneFill = new Fill( Color.White, Color.LightYellow, 45.0F );
                myPaneT.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                double x, y;
                PointPairList list = new PointPairList();
                for ( int i=0; i<36; i++ )
                {
                    x = (double) i + 5;
                    y = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 + (double) j ) );
                    list.Add( x, y );
                }

                LineItem myCurve = myPaneT.AddCurve( "Type " + j.ToString(),
                    list, rotator.NextColor, rotator.NextSymbol );
                myCurve.Symbol.Fill = new Fill( Color.White );

                master.Add( myPaneT );
            }

            myPane = master[0];

            Graphics g = this.CreateGraphics();

            //master.AutoPaneLayout( g, PaneLayout.ExplicitRow32 );
            //master.AutoPaneLayout( g, 2, 4 );
            master.AutoPaneLayout( g, false, new int[] { 1, 3, 2 }, new float[] { 2, 1, 3 } );
            master.AxisChange( g );

            g.Dispose();
            #endif

            #if false	// MasterPane - Single Pane
            master = new MasterPane( "ZedGraph MasterPane Single Pane Example", new Rectangle( 10, 10, 10, 10 ) );

            master.Fill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );

            // Create a new graph with topLeft at (40,40) and size 600x400
            GraphPane myPaneT = new GraphPane( new Rectangle( 40, 40, 600, 400 ),
                "Case 1",
                "Time, Days",
                "Rate, m/s" );

            myPaneT.Fill = new Fill( Color.White, Color.LightYellow, 45.0F );
            myPaneT.BaseDimension = 6.0F;

            // Make up some data arrays based on the Sine function
            double x, y;
            PointPairList list = new PointPairList();
            for ( int i=0; i<36; i++ )
            {
                x = (double) i + 5;
                y = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 ) );
                list.Add( x, y );
            }

            LineItem myCurve = myPaneT.AddCurve( "Type 1",
                list, Color.Blue, SymbolType.Circle );
            myCurve.Symbol.Fill = new Fill( Color.White );

            master.Add( myPaneT );

            Graphics g = this.CreateGraphics();

            master.Title.IsVisible = false;
            master.Margin.All = 0;
            //master.AutoPaneLayout( g, PaneLayout.ExplicitRow32 );
            //master.AutoPaneLayout( g, 2, 4 );
            master.AutoPaneLayout( g );
            //master.AutoPaneLayout( g, false, new int[] { 1, 3, 2 }, new float[] { 2, 1, 3 } );
            master.AxisChange( g );

            g.Dispose();
            #endif

            #if false	// Pie
            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "2004 ZedGraph Sales by Region\n($M)",
                "",
                "" );

            myPane.FontSpec.IsItalic = true;
            myPane.FontSpec.Size = 24f;
            myPane.FontSpec.Family = "Times";
            myPane.PaneFill = new Fill( Color.White, Color.Goldenrod, 45.0f );
            myPane.Chart.Fill.Type = FillType.None;
            myPane.Legend.Position = LegendPos.Float ;
            myPane.Legend.Location = new Location( 0.95f, 0.15f, CoordType.PaneFraction,
                                AlignH.Right, AlignV.Top );
            myPane.Legend.FontSpec.Size = 10f;
            myPane.Legend.IsHStack = false;

            PieItem segment1 = myPane.AddPieSlice( 20, Color.Navy, Color.White, 45f, 0, "North" );
            PieItem segment3 = myPane.AddPieSlice( 30, Color.Purple, Color.White, 45f, .0, "East" );
            PieItem segment4 = myPane.AddPieSlice( 10.21, Color.LimeGreen, Color.White, 45f, 0, "West" );
            PieItem segment2 = myPane.AddPieSlice( 40, Color.SandyBrown, Color.White, 45f, 0.2, "South" );
            PieItem segment6 = myPane.AddPieSlice( 250, Color.Red, Color.White, 45f, 0, "Europe" );
            PieItem segment7 = myPane.AddPieSlice( 50, Color.Blue, Color.White, 45f, 0.2, "Pac Rim" );
            PieItem segment8 = myPane.AddPieSlice( 400, Color.Green, Color.White, 45f, 0, "South America" );
            PieItem segment9 = myPane.AddPieSlice( 50, Color.Yellow, Color.White, 45f, 0.2, "Africa" );

            segment2.LabelDetail.FontSpec.FontColor = Color.Red ;

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

            TextItem text = new TextItem( "Total 2004 Sales\n" + "$" + total.ToString () + "M",
                                0.18F, 0.40F, CoordType.PaneFraction );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Border.IsVisible = false ;
            text.FontSpec.Fill = new Fill( Color.White, Color.FromArgb( 255, 100, 100 ), 45F );
            text.FontSpec.StringAlignment = StringAlignment.Center ;
            myPane.GraphItemList.Add( text );

            TextItem text2 = new TextItem( text );
            text2.FontSpec.Fill = new Fill( Color.Black );
            text2.Location.X += 0.008f;
            text2.Location.Y += 0.01f;
            myPane.GraphItemList.Add( text2 );

            myPane.AxisChange( this.CreateGraphics() );
            #endif

            #if false	// simple pie
            myPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                "People Signed Up",
                "",
                "" );
            // Create some pie slices
            PieItem segment1 = myPane.AddPieSlice(8, Color.Green, .3, "Signed Up");
            PieItem segment2 = myPane.AddPieSlice(5,Color.Red, 0.0, "Still Needed");

            //segment1.FontSpec = new FontSpec("GenericSansSerif", 35, Color.Black, true, false, false);
            // Sum up the values
            CurveList curves = myPane.CurveList;
            double total = 0;
            for (int x = 0; x < curves.Count; x++)
                total += ((PieItem)curves[x]).Value;

            myPane.PaneBorder.IsVisible = false;
            myPane.Legend.Border.IsVisible = false;
            myPane.Legend.Position = LegendPos.TopCenter;

            //			ArrowItem arrow = new ArrowItem( (float) new XDate(2007,1,1), 0, (float) new XDate(2007,1,1), 50 );

            #endif

            #if false	// Commerical Sales Graph
            myPane = new GraphPane( new RectangleF(0,0,10,10),
                        "Sales Growth Compared to\nActual Sales by Store Size - Rank Order Low to High",
                        "", "" );
            myPane.MarginAll = 20;
            myPane.FontSpec.Size = 10;
            myPane.Legend.Position = LegendPos.BottomCenter;
            myPane.Legend.FontSpec.Size = 7;

            Random rand = new Random();
            double y1 = 184;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList trendList = new PointPairList();
            PointPairList projList = new PointPairList();
            string[] labels = new string[26];

            for ( int i=0; i<26; i++ )
            {
                double h1 = rand.NextDouble() * 10 - 2;
                double h2 = rand.NextDouble() * 10 - 2;
                double h3 = rand.NextDouble() * 8;
                double y2 = y1 + ( rand.NextDouble() * 2 - 1 );

                trendList.Add( i + 1.0 - 0.2, y1 );
                trendList.Add( i + 1.0 + 0.2, y2 );
                list1.Add( (double) i, y1+h1, y1 );
                list2.Add( (double) i, y2+h2, y2 );
                projList.Add( (double) i + 1.0 - 0.35, y1 + h3 );
                projList.Add( (double) i + 1.0 + 0.35, y1 + h3 );
                projList.Add( PointPair.Missing, PointPair.Missing );

                labels[i] = "Store " + (i+1).ToString();

                y1 += rand.NextDouble() * 4.0;
            }

            PointPairList minTargList = new PointPairList();
            minTargList.Add( 0.7, 218 );
            minTargList.Add( 26.3, 218 );
            PointPairList prefTargList = new PointPairList();
            prefTargList.Add( 0.7, 228 );
            prefTargList.Add( 26.3, 228 );

            LineItem minCurve = myPane.AddCurve("Minimum Target", minTargList, Color.Green, SymbolType.None );
            minCurve.Line.Width = 3.0f;
            minCurve.IsOverrideOrdinal = true;
            LineItem prefCurve = myPane.AddCurve("Preferred Target", prefTargList, Color.Blue, SymbolType.None );
            prefCurve.Line.Width = 3.0f;
            prefCurve.IsOverrideOrdinal = true;

            LineItem projCurve = myPane.AddCurve( "Projected Sales", projList, Color.Orange, SymbolType.None );
            projCurve.IsOverrideOrdinal = true;
            projCurve.Line.Width = 3.0f;

            LineItem myCurve = myPane.AddCurve( "Trendline", trendList,
                            Color.FromArgb( 50, 50, 50 ), SymbolType.None );
            myCurve.Line.Width = 2.5f;
            myCurve.Line.IsSmooth = true;
            myCurve.Line.SmoothTension = 0.3f;
            myCurve.IsOverrideOrdinal = true;

            BarItem myBar = myPane.AddBar( "Store Growth", list1, Color.Black );
            //myBar.Bar.Fill = new Fill( Color.Black );
            BarItem myBar2 = myPane.AddBar( "Average Growth", list2, Color.LightGray );
            //myBar2.Bar.Fill = new Fill( Color.LightGray );

            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.TextLabels = labels;
            myPane.XAxis.Scale.FontSpec.Angle = -90;
            myPane.XAxis.Scale.FontSpec.Size = 8;
            myPane.XAxis.Scale.FontSpec.IsBold = true;
            myPane.XAxis.IsTicsBetweenLabels = true;
            myPane.XAxis.IsInsideTic = false;
            myPane.XAxis.IsOppositeTic = false;
            myPane.XAxis.IsMinorInsideTic = false;
            myPane.XAxis.IsMinorOppositeTic = false;

            myPane.YAxis.Scale.FontSpec.Size = 8;
            myPane.YAxis.Scale.FontSpec.IsBold = true;
            myPane.YAxis.IsShowGrid = true;
            myPane.YAxis.GridDashOn = 1.0f;
            myPane.YAxis.GridDashOff = 0.0f;

            myPane.BarType = BarType.ClusterHiLow;

            myPane.AxisChange( this.CreateGraphics() );
            myPane.YAxis.MinorStep = myPane.YAxis.Step;

            #endif

            #if false	// Basic curve test - Images as symbols
            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            PointPairList list = new PointPairList();

            for ( int i=0; i<10; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( x / 8.0 );
                list.Add( x, y );
            }

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            Bitmap bm = new Bitmap( @"c:\windows\winnt256.bmp" );
            Image image = Image.FromHbitmap( bm.GetHbitmap() );

            myCurve.Line.IsVisible = false;
            myCurve.Symbol.Type = SymbolType.Square;
            myCurve.Symbol.Size = 16;
            myCurve.Symbol.Border.IsVisible = false;
            myCurve.Symbol.Fill = new Fill( image, WrapMode.Clamp );

            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 359;
            trackBar1.Value = 0;

            #endif

            #if false	// Stick Item Test
            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            PointPairList list = new PointPairList();
            for ( int i=0; i<100; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( i / 8.0 );
                double z = Math.Abs(Math.Cos( i / 8.0 )) * y;
                list.Add( x, y, z );
            }

            StickItem myCurve = myPane.AddStick( "curve", list, Color.Blue );
            myCurve.Line.Width = 2.0f;
            myPane.XAxis.IsShowGrid = true;
            myPane.XAxis.Max = 100;

            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 359;
            trackBar1.Value = 0;

            #endif

            #if false	// Basic curve test - Dual Y axes

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

            myPane.Y2Axis.Title.Text = "My Y2 Axis";

            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();

            for ( int i=0; i<100; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( i / 8.0 ) * 100000 + 150000;
                double y2 = Math.Sin( i / 3.0 ) * 300 - 400;
                list.Add( x, y );
                list2.Add( x, y2 );
                //double z = Math.Abs( Math.Cos( i / 8.0 ) ) * y;
            }

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            LineItem myCurve2 = myPane.AddCurve( "curve2", list2, Color.Red, SymbolType.Diamond );
            myCurve2.IsY2Axis = true;

            myPane.Y2Axis.IsVisible = true;

            AlignYZeroLines( myPane, 12 );
            myPane.YAxis.IsMinorOppositeTic = false;
            myPane.Y2Axis.IsMinorOppositeTic = false;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test - Multi-Y axes

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

            myPane.AddYAxis( "Another Y Axis" );
            myPane.AddY2Axis( "Another Y2 Axis" );
            myPane.Y2Axis.Title.Text = "My Y2 Axis";
            myPane.Y2AxisList[0].IsVisible = true;
            myPane.Y2AxisList[1].IsVisible = true;

            PointPairList list = new PointPairList();

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

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            myCurve.YAxisIndex = 1;

            myPane.XAxis.IsSkipLastLabel = false;
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test - Date Axis w/ Time Span

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

            PointPairList list = new PointPairList();

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

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            myPane.XAxis.IsSkipLastLabel = false;
            //myPane.XAxis.IsPreventLabelOverlap = false;
            myPane.XAxis.ScaleFormat = "[d].[h]:[m]:[s]";
            myPane.XAxis.Type = AxisType.Date;
            myPane.AxisChange( this.CreateGraphics() );

            myPane.YAxis.ScaleFormat = "0.0'%'";
            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            myPane.PaneFill = new Fill( Color.FromArgb( 100, Color.Blue ), Color.FromArgb( 100, Color.White ), 45.0f );

            #endif

            #if false	// Basic curve test - DateAsOrdinal

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

            PointPairList list = new PointPairList();

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

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            myPane.XAxis.IsSkipLastLabel = false;
            myPane.XAxis.IsPreventLabelOverlap = false;
            myPane.XAxis.ScaleFormat = ZedGraph.Axis.Default.FormatDayDay;
            myPane.XAxis.Type = AxisType.DateAsOrdinal;
            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test - Linear Axis

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

            PointPairList list = new PointPairList();

            for ( int i=0; i<20; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( x / 8.0 );
                double z = Math.Abs(Math.Cos( i / 8.0 )) * y;

                list.Add( x, y, z );
            }

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );

            //myPane.XAxis.Min = 1;
            //myPane.XAxis.Max = 100;
            //myPane.XAxis.IsReverse = true;
            //myPane.XAxis.Type = AxisType.Log;

            //RectangleF rect = new RectangleF( 3, 0.7, 8, 0.2 );
            myPane.AxisChange( this.CreateGraphics() );

            BoxItem m_selectionBox = new BoxItem(); // rect );
            m_selectionBox.Border.Color = Color.Orange;
            m_selectionBox.Border.IsVisible = true;
            m_selectionBox.Fill.Color = Color.LightYellow;
            m_selectionBox.Fill.Type = FillType.Solid;
            m_selectionBox.Fill.RangeMin = 1.0;
            m_selectionBox.Fill.RangeMax = 1.0;
            m_selectionBox.Fill.IsVisible = true;

            m_selectionBox.Location = new Location(
                (float)3,
                (float)myPane.YAxis.Max,
                (float)(8 - 3),
                (float)myPane.YAxis.Max - (float)myPane.YAxis.Min,
                CoordType.AxisXYScale,
                AlignH.Left,
                AlignV.Top);

            m_selectionBox.IsClippedToChartRect = true;
            m_selectionBox.ZOrder = ZOrder.E_BehindAxis;
            m_selectionBox.IsVisible = true;

            myPane.GraphItemList.Add( m_selectionBox );

            #endif

            #if false	// Box and Whisker diagram

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

            // Throw some data points on the chart for good looks
            PointPairList list = new PointPairList();
            for ( int i=0; i<20; i++ )
            {
                double x = (double) i * 5;
                double y = Math.Sin( x / 8.0 );
                list.Add( x, y );
            }
            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            myCurve.Line.IsVisible = false;

            // Horizontal box and whisker chart
            // yval is the vertical position of the box & whisker
            double yval = 0.3;
            // pct5 = 5th percentile value
            double pct5 = 5;
            // pct25 = 25th percentile value
            double pct25 = 40;
            // median = median value
            double median = 55;
            // pct75 = 75th percentile value
            double pct75 = 80;
            // pct95 = 95th percentile value
            double pct95 = 95;

            // Draw the box
            PointPairList list2 = new PointPairList();
            list2.Add( pct25, yval, median );
            list2.Add( median, yval, pct75 );
            HiLowBarItem myBar = myPane.AddHiLowBar( "box", list2, Color.Black );
            // set the size of the box (in points, scaled to graph size)
            myBar.Bar.Size = 20;
            myBar.Bar.Fill.IsVisible = false;
            myPane.BarBase = BarBase.Y;

            // Draw the whiskers
            double[] xwhisk = { pct5, pct25, PointPair.Missing, pct75, pct95 };
            double[] ywhisk = { yval, yval, yval, yval, yval };
            PointPairList list3 = new PointPairList();
            list3.Add( xwhisk, ywhisk );
            LineItem mywhisk = myPane.AddCurve( "whisker", list3, Color.Black, SymbolType.None );

            myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// Basic curve test - Linear Axis with Many Points

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

            PointPairList list = new PointPairList();

            for ( int i=0; i<100000; i++ )
            {
                double x = (double) i;
                double y = Math.Sin( x / 8.0 );
                double z = Math.Abs(Math.Cos( i / 8.0 )) * y;

                list.Add( x, y, z );
            }

            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.HDash );
            myCurve.Symbol.IsVisible = false;
            //myPane.XAxis.Min = 1;
            //myPane.XAxis.Max = 100;
            //myPane.XAxis.IsReverse = true;
            //myPane.XAxis.Type = AxisType.Log;

            //RectangleF rect = new RectangleF( 3, 0.7, 8, 0.2 );
            Graphics g = this.CreateGraphics();
            myPane.AxisChange( g );
            SetSize();

            int startTick = Environment.TickCount;

            myPane.Draw( g );

            int endTick = Environment.TickCount;

            MessageBox.Show( "ticks = " + ( endTick - startTick ).ToString() );
            #endif

            #if false	// Gantt Chart
            myPane = new GraphPane();

            myPane.Title.Text = "Gantt Chart";
            myPane.XAxis.Title.Text = "Date";
            myPane.YAxis.Title.Text = "Project";

            myPane.XAxis.Type = AxisType.Date;
            myPane.YAxis.Type = AxisType.Text;
            myPane.BarBase = BarBase.Y;

            string[] labels = { "Project 1", "Project 2" };
            myPane.YAxis.TextLabels = labels;
            myPane.YAxis.IsTicsBetweenLabels = true;

            // First, define all the bars that you want to be red
            PointPairList ppl = new PointPairList();
            XDate start = new XDate( 2005, 10, 31 );
            XDate end = new XDate( 2005, 11, 15 );
            // x is start of bar, y is project number, z is end of bar
            // Define this first one using start/end variables for illustration
            ppl.Add( start, 1.0, end );
            // add another red bar, assigned to project 2
            // Didn't use start/end variables here, but it's the same concept
            ppl.Add( new XDate( 2005, 12, 16 ), 2.0, new XDate( 2005, 12, 31 ) );
            HiLowBarItem myBar = myPane.AddHiLowBar( "job 1", ppl, Color.Red );
            // This tells the bar that we want to manually define the Y position
            // Y is AxisType.Text, which is ordinal, so a Y value of 1.0 goes with the first label,
            // 2.0 with the second, etc.
            myBar.IsOverrideOrdinal = true;
            myBar.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red, 90.0f );
            // This size is the width of the bar
            myBar.Bar.Size = 20f;

            // Now, define all the bars that you want to be Green
            ppl = new PointPairList();
            ppl.Add( new XDate( 2005, 11,16 ), 2.0, new XDate( 2005, 11, 26 ) );
            myBar = myPane.AddHiLowBar( "job 2", ppl, Color.Green );
            myBar.IsOverrideOrdinal = true;
            myBar.Bar.Fill = new Fill( Color.Green, Color.White, Color.Green, 90.0f );
            myBar.Bar.Size = 20f;

            // Define all the bars that you want to be blue
            ppl = new PointPairList();
            ppl.Add( new XDate( 2005, 11, 27 ), 1.0, new XDate( 2005, 12, 15 ) );
            myBar = myPane.AddHiLowBar( "job 3", ppl, Color.Blue );
            myBar.IsOverrideOrdinal = true;
            myBar.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue, 90.0f );
            myBar.Bar.Size = 20f;
            #endif

            #if false		// DeSerialize
                DeSerialize( out myPane, @"c:\temp\myZedGraphFile" );

                trackBar1.Minimum = 0;
                trackBar1.Maximum = 100;
                trackBar1.Value = 50;

                myPane.AxisChange( this.CreateGraphics() );
            #endif

            #if false			// spline test

            myPane = new GraphPane();
            PointPairList ppl = new PointPairList();

            ppl.Add( 0, 713 );
            ppl.Add( 7360, 333 );
            ppl.Add( 10333.333, 45.333336 );
            ppl.Add( 11666.667, 5 );
            ppl.Add( 12483.333, 45.333336 );
            ppl.Add( 13600, 110 );
            ppl.Add( 15800, 184.66667 );
            ppl.Add( 18644.998, 186.33368 );
            ppl.Add( 18770.002, 186.66664 );
            ppl.Add( 18896.666, 187.08336 );
            ppl.Add( 18993.334, 187.50002 );
            ppl.Add( 19098.332, 188.08334 );
            ppl.Add( 19285.002, 189.41634 );
            ppl.Add( 19443.332, 190.83334 );
            ppl.Add( 19633.334, 193.16634 );
            ppl.Add( 19823.336, 196.49983 );
            ppl.Add( 19940.002, 199.16669 );
            ppl.Add( 20143.303, 204.66566 );
            ppl.Add( 20350, 210.91667 );
            ppl.Add( 36000, 713 );

            LineItem curve = myPane.AddCurve( "test", ppl, Color.Green, SymbolType.Default );
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.4F;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;
            #endif

            #if false	// hilowbar test

            myPane = new GraphPane();

            myPane.Title.Text = "Bar Type Sample";
            myPane.XAxis.Title.Text = "Text Axis";
            myPane.YAxis.Title.Text = "Some Data Value";
            myPane.XAxis.Type = AxisType.Text;
            myPane.ClusterScaleWidth = 1.0;
            //myPane.BarType = BarType.Overlay;

            myPane.FontSpec.Size = 18;
            myPane.YAxis.TitleFontSpec.Size = 16;
            myPane.XAxis.TitleFontSpec.Size = 16;

            string[] labels = { "North", "South", "East", "West", "Up", "Down" };
            myPane.XAxis.TextLabels = labels;
            //Random rand = new Random();

            double[] xArray = { 3, 5, 9, 11, 16, 18 };
            double[] xArray2 = { 10, 12, 13, 15, 17, 19 };
            double[] yArray = { 10, 45, 78, 34, 15, 26 };
            double[] yArray2 = { 54, 34, 64, 24, 44, 74 };
            PointPairList list1 = new PointPairList( xArray, yArray );
            PointPairList list2 = new PointPairList( xArray2, yArray2 );
            /*
            for ( int i = 0; i < 6; i++ )
            {
                double x = xArray[i];
                double y1 = rand.NextDouble() * 1.0 + .00001;
                double y2 = rand.NextDouble() * 1.0 + .00001;

                list1.Add( x, y1 );
                list2.Add( x, y2 );
            }
            */
            HiLowBarItem bar1 = myPane.AddHiLowBar( "First", list1, Color.Blue );
            HiLowBarItem bar2 = myPane.AddHiLowBar( "Second", list2, Color.Red );
            //myPane.YAxis.Type = AxisType.Log;
            //myPane.BarType = BarType.ClusterHiLow;
            //myPane.XAxis.Scale.ScaleFormatEvent += new Scale.ScaleFormatHandler( CustomFormatter );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// Basic bar test - Linear

            myPane = new GraphPane();

            myPane.Title.Text = "BarItem Sample (BarType.ClusterHiLow)";
            myPane.XAxis.Title.Text = "Text Axis";
            myPane.YAxis.Title.Text = "Some Data Value";
            myPane.XAxis.Type = AxisType.Text;
            myPane.ClusterScaleWidth = 2.0;
            myPane.BarType = BarType.ClusterHiLow;

            myPane.FontSpec.Size = 18;
            myPane.YAxis.TitleFontSpec.Size = 16;
            myPane.XAxis.TitleFontSpec.Size = 16;

            string[] labels = { "North", "South", "East", "West", "Up", "Down" };
            myPane.XAxis.TextLabels = labels;
            //Random rand = new Random();

            //double[] xArray = { 3, 5, 9, 11, 16, 18 };
            double[] xArray = { 1, 1.8, 3.2, 4, 5, 6 };
            double[] xArray2 = { 10, 12, 13, 15, 17, 19 };
            double[] yArray = { 10, 75, 25, 16, 15, 26 };
            double[] yArray2 = { 54, 62, 44, 24, 44, 74 };
            double[] ylArray2 = { 34, 42, 15, 0, 5, 20 };
            double[] yArray3 = { 54, 62, 44, 24, 34, 74 };
            double[] ylArray3 = { 44, 42, 14, 14, 14, 34 };
            PointPairList list1 = new PointPairList( xArray, yArray, ylArray2 );
            PointPairList list2 = new PointPairList( xArray, yArray2, ylArray2 );
            PointPairList list3 = new PointPairList( xArray, yArray3, ylArray3 );
            /*
            for ( int i = 0; i < 6; i++ )
            {
                double x = xArray[i];
                double y1 = rand.NextDouble() * 1.0 + .00001;
                double y2 = rand.NextDouble() * 1.0 + .00001;

                list1.Add( x, y1 );
                list2.Add( x, y2 );
            }
            */
            //ErrorBarItem bar1 = myPane.AddErrorBar( "First", list3, Color.Blue );
            //bar1.ErrorBar.Symbol.Size = 12;
            //bar1.ErrorBar.PenWidth = 2;
            //HiLowBarItem bar1 = myPane.AddHiLowBar( "First", list3, Color.Blue );
            //bar1.Bar.Size = 20;
            BarItem bar1 = myPane.AddBar( "First", list1, Color.Blue );
            BarItem bar2 = myPane.AddBar( "Second", list2, Color.Red );
            //myPane.YAxis.Type = AxisType.Log;
            //myPane.BarType = BarType.ClusterHiLow;
            //myPane.XAxis.Scale.ScaleFormatEvent += new Scale.ScaleFormatHandler( CustomFormatter );

            myPane.YAxis.IsTitleAtCross = false;

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            myPane.AxisChange( this.CreateGraphics() );

            #endif

            #if false	// Bars - different colors thru IsOverrideOrdinal

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

            /*			PointPairList list1 = new PointPairList();
            list1.Add(1,13);
            HiLowBarItem bar1 = myPane.AddHiLowBar( "First", list1, Color.Blue );
            PointPairList list2 = new PointPairList();
            list2.Add(2,22);
            HiLowBarItem bar2 = myPane.AddHiLowBar( "Second", list2, Color.Red );

            bar1.Bar.Size = 30;
            bar1.IsOverrideOrdinal = true;
            bar2.Bar.Size = 30;
            bar2.IsOverrideOrdinal = true;
            */
            PointPairList list1 = new PointPairList();
            list1.Add(1,13);
            BarItem bar1 = myPane.AddBar( "First", list1, Color.Blue );
            PointPairList list2 = new PointPairList();
            list2.Add(2,22);
            BarItem bar2 = myPane.AddBar( "Second", list2, Color.Red );

            bar1.IsOverrideOrdinal = true;
            bar2.IsOverrideOrdinal = true;

            myPane.Legend.Position = LegendPos.TopFlushLeft;

            myPane.BarType = BarType.Overlay;
            myPane.XAxis.Type = AxisType.Text;
            string[] labels = { "Label1", "Label2" };
            myPane.XAxis.TextLabels = labels;
            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test - two text axes

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

            double[] y = { 2, 4, 1, 5, 3 };

            LineItem myCurve = myPane.AddCurve( "curve 1", null, y, Color.Blue, SymbolType.Diamond );
            myCurve.IsOverrideOrdinal = true;
            myPane.XAxis.Type = AxisType.Text;
            myPane.YAxis.Type = AxisType.Text;

            string[] xLabels = { "one", "two", "three", "four", "five" };
            string[] yLabels = { "alpha", "bravo", "charlie", "delta", "echo" };
            //myPane.XAxis.TextLabels = xLabels;
            //myPane.YAxis.TextLabels = yLabels;

            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic horizontal bar test

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

            PointPairList list = new PointPairList();

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

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

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

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

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

                        xVal = ( x1 + x2 ) / 2.0;

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

                iOrd++;
            }

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// vertical bars with labels

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

            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();
            PointPairList list3 = new PointPairList();
            Random rand = new Random();

            for ( int i=0; i<5; i++ )
            {
                double x = (double) i;
                double y = rand.NextDouble() * 1000;
                double y2 = rand.NextDouble() * 1000;
                double y3 = rand.NextDouble() * 1000;
                list.Add( x, y );
                list2.Add( x, y2 );
                list3.Add( x, y3 );
            }

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

            //myPane.XAxis.IsReverse = true;
            myPane.AxisChange( this.CreateGraphics() );
            myPane.XAxis.IsTicsBetweenLabels = true;
            string[] labels = { "one", "two", "three", "four", "five" };
            myPane.XAxis.TextLabels = labels;
            myPane.XAxis.Type = AxisType.Text;
            //myPane.XAxis.Step = 3;
            myPane.XAxis.IsAllTics = false;

            ArrowItem tic = new ArrowItem( Color.Black, 1.0f, 2.5f, 0.99f, 2.5f, 1.01f );
            tic.IsArrowHead = false;
            tic.Location.CoordinateFrame = CoordType.XScaleYAxisFraction;
            myPane.GraphItemList.Add( tic );

            CreateBarLabels( myPane );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test - log/exponential axis
            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            PointPairList ppl1 = new PointPairList();
            PointPairList ppl2 = new PointPairList();

            for ( int i=0; i<100; i++ )
            {
                double x = (double) i * 1.52 + 0.001;
                double x2 = x*10000;
                double y = Math.Sin( i / 8.0 ) * 100000 + 100001;
                double y2 = Math.Sin( i / 8.0 ) * 100000 + 100001;
                double z = Math.Abs( Math.Cos( i / 8.0 ) ) * y;
                ppl1.Add( x, y, z );
                ppl2.Add( x2, y2, z );
            }

            LineItem myCurve = myPane.AddCurve( "curve", ppl1, Color.Blue, SymbolType.Diamond );
            LineItem myCurve2 = myPane.AddCurve( "curve2", ppl2, Color.Red, SymbolType.Triangle );

            myPane.XAxis.IsUseTenPower = false;
            myPane.XAxis.Type = AxisType.Log;
            myPane.XAxis.Exponent = 0.3;

            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// Basic curve test
            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            double[] x = new double[100];
            double[] y = new double[100];

            for ( int i=0; i<100; i++ )
            {
                x[i] = (double) i;
                y[i] = Math.Sin( i / 8.0 ) * 100000 + 100001;
                double z = Math.Abs(Math.Cos( i / 8.0 )) * y[i];
            }
            BasicArrayPointList list = new BasicArrayPointList( x, y );

            //LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            //myCurve.Symbol.IsVisible = true;
            //myCurve.IsY2Axis = true;
            //myPane.Y2Axis.IsVisible = true;
            //myPane.YAxis.Type = AxisType.Log;
            //myPane.YAxis.IsScaleVisible = false;
            //myPane.YAxis.IsShowTitle = false;
            //myPane.MarginLeft = 50;

            //TextItem text = new TextItem("5000", -0.01f, 5000f, CoordType.XAxisFractionYScale, AlignH.Right, AlignV.Center );
            //text.FontSpec.Border.IsVisible = false;
            //text.FontSpec.Fill.IsVisible = false;
            //myPane.GraphItemList.Add( text );

            //TextItem text2 = new TextItem( "My Title", 0.01f, 0.5f, CoordType.XPaneFractionYAxisFraction,
            //	AlignH.Center, AlignV.Top );
            //text2.FontSpec.Border.IsVisible = false;
            //text2.FontSpec.Fill.IsVisible = false;
            //text2.FontSpec.Angle = 90f;
            //myPane.GraphItemList.Add( text2 );

            //myPane.YAxis.IsVisible = false;
            //myPane.Y2Axis.Title.Text = "Y2 Axis";
            //myPane.XAxis.BaseTic = 1;
            //myPane.XAxis.Step = 5;
            //myPane.Y2Axis.Cross = 60;
            //myPane.YAxis.IsScaleLabelsInside = true;
            //myPane.Y2Axis.IsShowGrid = true;
            //myPane.XAxis.IsShowGrid = true;
            //myPane.YAxis.IsSkipFirstLabel = true;
            myPane.XAxis.IsSkipLastLabel = true;
            //myPane.XAxis.IsSkipLastLabel = true;
            //myPane.XAxis.IsReverse = true;
            //myPane.AxisBorder.IsVisible = false;
            //myPane.XAxis.Type = AxisType.Log;

            PointF[] polyPts = new PointF[7];
            polyPts[0] = new PointF( 30f, 0.2f );
            polyPts[1] = new PointF( 25f, 0.4f );
            polyPts[2] = new PointF( 27f, 0.6f );
            polyPts[3] = new PointF( 30f, 0.8f );
            polyPts[4] = new PointF( 35f, 0.6f );
            polyPts[5] = new PointF( 37f, 0.4f );
            polyPts[6] = new PointF( 30f, 0.2f );
            PolyItem poly = new PolyItem( polyPts, Color.Red, Color.LightSeaGreen, Color.White );
            myPane.GraphItemList.Add( poly );

            myPane.AxisChange( this.CreateGraphics() );

            myPane.FontSpec.IsDropShadow = true;
            myPane.FontSpec.DropShadowColor = Color.Red;
            myPane.FontSpec.Border.IsVisible = true;
            myPane.FontSpec.Fill = new Fill( Color.White, Color.LightGoldenrodYellow );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            #if false	// repetitive points
            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );

            double[] Track_DateTime_Xaxis = {1};
            double[] Y_processed_axis = {10};

            LineItem myCurve = myPane.AddCurve( "Curve Legend", Track_DateTime_Xaxis, Y_processed_axis,
                Color.DarkRed );
            myCurve.Symbol.Fill = new Fill( Color.Red );
            myPane.XAxis.Max = 1;
            myPane.YAxis.IsShowGrid = true;
            myPane.YAxis.IsShowMinorGrid = true;
            //myPane.AxisChange( g );

            #endif

            #if false	// masterpane test

            master = new MasterPane( "ZedGraph MasterPane Example",
                new Rectangle( 10, 10, this.Width-20, this.Height-100 ) );

            master.PaneFill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F );

            master.Legend.IsVisible = true;
            master.Legend.Position = LegendPos.TopCenter;

            TextItem text = new TextItem( "Priority", 0.88F, 0.12F );
            text.Location.CoordinateFrame = CoordType.PaneFraction;
            text.FontSpec.Angle = 15.0F;
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color = Color.Red;
            text.FontSpec.Fill.IsVisible = false;
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            master.GraphItemList.Add( text );

            text = new TextItem( "DRAFT", 0.5F, 0.5F );
            text.Location.CoordinateFrame = CoordType.PaneFraction;
            text.FontSpec.Angle = 30.0F;
            text.FontSpec.FontColor = Color.FromArgb( 70, 255, 100, 100 );
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 100;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Center;
            text.ZOrder = ZOrder.A_InFront;
            master.GraphItemList.Add( text );

            ColorSymbolRotator rotator = new ColorSymbolRotator();

            for ( int j=0; j<8; j++ )
            {
                // Create a new graph - rect dimensions do not matter here, since it
                // will be resized by MasterPane.AutoPaneLayout()
                GraphPane newPane = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
                    "Case #" + (j+1).ToString(),
                    "Time, Days",
                    "Rate, m/s" );

                newPane.PaneFill = new Fill( Color.PowderBlue, Color.LightYellow, 45.0F );
                newPane.BaseDimension = 6.0F;

                // Make up some data arrays based on the Sine function
                double x, y;
                PointPairList list = new PointPairList();
                for ( int i=0; i<36; i++ )
                {
                    x = (double) i + 5;
                    y = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 + (double) j ) );
                    list.Add( x, y );
                }

                LineItem myCurve = newPane.AddCurve( "Type " + j.ToString(),
                    list, rotator.NextColor, rotator.NextSymbol );
                myCurve.Symbol.Fill = new Fill( Color.White );

                master.Add( newPane );
            }

            Graphics g = this.CreateGraphics();

            master.AutoPaneLayout( g, PaneLayout.SquareRowPreferred);
            master.AxisChange( g );
            #endif

            #if false
            // Create a new GraphPane

            myPane = new GraphPane( new RectangleF( 0, 0, 640, 480 ), "Title", "XAxis", "YAxis" );
            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard" };
            double[] x = { 100, 115, 75, 22, 98, 40 };
            double[] x2 = { 120, 175, 95, 57, 113, 110 };
            double[] x3 = { 204, 192, 119, 80, 134, 156 };
            BarItem myCurve = myPane.AddBar( "Here", x, null, Color.Red );
            myCurve.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red, 90f );
            myCurve = myPane.AddBar( "There", x2, null, Color.Blue );
            myCurve.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue, 90f );
            myCurve = myPane.AddBar( "Elsewhere", x3, null, Color.Green );
            myCurve.Bar.Fill = new Fill( Color.Green, Color.White, Color.Green, 90f );
            myPane.YAxis.IsTicsBetweenLabels = true;
            myPane.YAxis.TextLabels = labels;
            myPane.YAxis.Type = AxisType.Text;
            myPane.BarType = BarType.Stack;
            myPane.BarBase = BarBase.Y;
            myPane.Chart.Fill = new Fill( Color.White, Color.FromArgb( 255, 255, 166), 45.0F );

            #endif

            #if false	// ordinal demo

            myPane = new GraphPane( new RectangleF( 0, 0, 300, 200 ), "Ordinal Demo", "X Value (ordinal)", "Y Value" );

            PointPairList list = new PointPairList();
            list.Add( 10, 50 );
            list.Add( 11, 24 );
            list.Add( 20, 75 );
            list.Add( 21, 62 );

            LineItem myCurve = myPane.AddCurve( "Curve", list, Color.Blue, SymbolType.Diamond );
            myCurve.Symbol.Fill = new Fill( Color.White );

            myPane.FontSpec.Size = 24;
            myPane.XAxis.TitleFontSpec.Size = 18;
            myPane.XAxis.Scale.FontSpec.Size = 18;
            myPane.YAxis.TitleFontSpec.Size = 18;
            myPane.YAxis.Scale.FontSpec.Size = 18;
            myPane.XAxis.Type = AxisType.Ordinal;
            myPane.AxisChange( this.CreateGraphics() );

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;

            #endif

            if ( master != null )
                _crossAxis = master[0].Y2Axis;
            else
                _crossAxis = myPane.YAxisList[1];

            trackBar1.Minimum = 0;
            trackBar1.Maximum = 100;
            trackBar1.Value = 50;
            UpdateControls();
            SetSize();

            //this.WindowState = FormWindowState.Maximized ;
            if ( this.myPane != null )
                this.myPane.AxisChange( this.CreateGraphics() );
        }
示例#7
0
        /// <summary>
        /// Bar chart.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="_options">GraphOptions.</param>
        /// <param name="binaryOutput">if set to <c>true</c> the image will output in the response stream.</param>
        /// <returns></returns>
        public static System.Drawing.Bitmap BarChart( string query, Dictionary<string, object> _options, bool binaryOutput )
        {
            ( "FUNCTION /w binaryStream barChart" ).Debug( 10 );
            /*
                * 0 = name
                * 1 = value
                * 2 = color1
                * 3 = color2
                * 4 = angle
                */
            GraphOptions options = null;
            JToken jtOpt = JToken.FromObject( _options );
            using( JTokenReader tr = new JTokenReader( jtOpt ) ) {
                JsonSerializer serializer = new JsonSerializer();
                options = ( GraphOptions )serializer.Deserialize( tr, typeof( GraphOptions ) );
            }
            System.Drawing.Bitmap image = null;
            GraphPane myPane = null;
            using(SqlConnection cn = Site.CreateConnection(true, true)) {
                cn.Open();
                try {
                    using(SqlCommand cmd = new SqlCommand(query, cn)) {
                        myPane = new GraphPane(new System.Drawing.Rectangle(0, 0, options.Width, options.Height), options.Title, "", "");
                        myPane.Title.Text = options.Title;
                        myPane.XAxis.Title.Text = options.XAxisTitle;
                        myPane.YAxis.Title.Text = options.YAxisTitle;
                        if(options.Orientation) {
                            myPane.YAxis.Type = AxisType.Ordinal;
                        } else {
                            myPane.XAxis.Type = AxisType.Ordinal;
                        }
                        float barLocation = 0;
                        using(SqlDataReader r = cmd.ExecuteReader()) {
                            if(r.HasRows) {
                                while(r.Read()) {
                                    PointPairList list = new PointPairList();
                                    if(options.Orientation) {
                                        list.Add(Convert.ToDouble(r.GetValue(1)), barLocation);
                                        BarItem myCurve = myPane.AddBar(r.GetString(0), list, System.Drawing.Color.FromName(r.GetString(2)));
                                        myCurve.Bar.Fill = new Fill(
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            System.Drawing.Color.FromName(r.GetString(3)),
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            (float)r.GetInt32(4)
                                        );
                                    } else {
                                        list.Add(barLocation, Convert.ToDouble(r.GetValue(1)));
                                        BarItem myCurve = myPane.AddBar(r.GetString(0), list, System.Drawing.Color.FromName(r.GetString(2)));
                                        myCurve.Bar.Fill = new Fill(
                                            System.Drawing.Color.FromName(r.GetString(2)),
                                            System.Drawing.Color.FromName(r.GetString(3)),
                                            (float)r.GetInt32(4)
                                        );

                                    }
                                    barLocation += options.BarSpacing;
                                }
                            }else{
                                if(image == null) {
                                    image = new Bitmap(700, 700);
                                }
                                image = WriteImageError(image, options.NoDataMessage, options.FontFamily, options.XAxisFontSize);
                                return image;
                            }
                        }
                        if(options.Orientation) {
                            myPane.YAxis.IsVisible = false;
                            //myPane.YAxis.Scale.Max=barLocation;
                            myPane.YAxis.Scale.Min = 0;
                            myPane.BarSettings.Base = BarBase.Y;
                        } else {
                            myPane.XAxis.IsVisible = false;
                            myPane.XAxis.Scale.Min = 0;
                            //myPane.XAxis.Scale.Max=barLocation-options.barSpacing;
                            myPane.BarSettings.Base = BarBase.X;
                        }
                        // Fill the chart background with a color gradient
                        myPane.Chart.Fill = new Fill(
                        System.Drawing.Color.FromName(options.Fill.StartColor),
                        System.Drawing.Color.FromName(options.Fill.EndColor), options.Fill.Angle);
                        myPane.AxisChange();

                        // Create TextObj's to provide labels for each bar
                        BarItem.CreateBarLabels(myPane, false, "f0");
                        image = myPane.GetImage(true);
                        using(MemoryStream ms = new MemoryStream()) {
                            image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                            if(HttpContext.Current != null) {
                                HttpContext.Current.Response.Clear();
                                HttpContext.Current.Response.ContentType = "image/png";
                                HttpContext.Current.Response.AddHeader("Expires", "0");/* RFC 2616 14.21 Content has already expired */
                                HttpContext.Current.Response.AddHeader("Cache-Control", "no-store");/* RFC 2616 14.9.2 Don't ever cache */
                                HttpContext.Current.Response.AddHeader("Pragma", "no-store");/* RFC 2616 14.32 Pragma - same as cache control */
                                ms.WriteTo(HttpContext.Current.Response.OutputStream);
                            }
                        }
                    }
                } catch(Exception ex) {
                    if(image == null) {
                        image = new Bitmap(700, 700);
                    }
                    image = WriteImageError(image, ex.Message, "Arial", 8f);
                }
            }
            return image;
        }
示例#8
0
        /// <summary>
        /// Plot the snow !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotSnow(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);

            //Main creation of curve
            if ( interval.Length.TotalDays < 160 )
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else if (interval.Length.TotalDays < 200)
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            else if (interval.Length.TotalDays < 400)
            {
                BarItem myCurve = myPane.AddBar("", ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            }
            //else
            //{
            //    StickItem myCurve = myPane.AddStick("", ts, Color.Blue);
            //    //LineItem myCurve = myPane.AddCurve("", ts, Color.Blue, SymbolType.None);
            //    //myCurve.Line.Width = 0F;
            //    //myCurve.Line.Fill = new Fill(Color.Blue);
            //}
        }
示例#9
0
        /// <summary>
        /// 图形描绘
        /// </summary>
        public override void DrawGraph()
        {
            #region 计算图形所需数据
            //x轴上的项目数
            int xAxisItemCount = 0;
            //项目上的柱数
            int itemElementCount = 0;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                xAxisItemCount   = base.DataSource.Rows.Count;
                itemElementCount = base.ShowValueColumns.Length;
            }
            else
            {
                xAxisItemCount   = base.ShowValueColumns.Length;
                itemElementCount = base.DataSource.Rows.Count;
            }



            //X轴元素的标签
            string[] labels = new string[xAxisItemCount];
            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                //如果X轴数据取数据表的纪录行
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
            }
            else
            {
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    labels[i] = base.ShowValueColumns[i].ColumnName;
                }
            }
            //图像显示需要的值 ,两层数组,
            //第一层数组为X轴上的项目的个数(X1,X2,X3,X4...),长度和labels长度一致
            //第二层数组为每个项目的第N个值,长度为每个项目内的元素个数如
            //{F1.Value1,F1.Value1,F3.Value1....}
            //{F1.Value2,F1.Value2,F3.Value2....}
            //{F1.Value3,F1.Value3,F3.Value3....}
            double[][] values = new double[itemElementCount][];
            //填充数组;
            for (int i = 0; i < itemElementCount; i++)
            {
                values[i] = new double[xAxisItemCount]; //长度为纪录数

                for (int j = 0; j < xAxisItemCount; j++)
                {
                    if (XAxisScaleRefrence == DataTableStruct.Rows)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]))
                        {
                            values[i][j] = 0;
                        }
                        else
                        {
                            values[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]);
                        }
                    }
                    else
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]))
                        {
                            values[i][j] = 0;
                        }
                        else
                        {
                            values[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]);
                        }
                    }
                }
            }
            //X轴下方的标签
            string[] markText;
            if (base.XAxisScaleRefrence == DataTableStruct.Columns)
            {
                markText = new string[base.DataSource.Rows.Count];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    markText[i] = base.DataSource.Rows[i][CNNameColumn].ToString();
                }
            }
            else
            {
                markText = new string[base.ShowValueColumns.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    markText[i] = base.ShowValueColumns[i].ColumnName;
                }
            }
            #endregion
            //Console.Beep();
            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom     = false;
            grphTx.IsEnableVZoom     = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text       = base.GraphTitle;
            myPane.XAxis.Title.Text = base.XAxisTitle;
            myPane.YAxis.Title.Text = base.YAxisTitle;

            ////添加显示条
            ZedGraph.BarItem bar;

            for (int i = 0; i < values.Length; i++)
            {
                double[] y = values[i];
                bar = myPane.AddBar(markText[i], null, y, Color.Red);
                //颜色如果没有指定,随机取
                Color color;
                if (base.Colors == null)
                {
                    color = GetColor();
                }
                else
                {
                    color = base.Colors[i];
                }

                bar.Bar.Fill = new ZedGraph.Fill(color, Color.White, color);
            }

            myPane.XAxis.MajorTic.IsBetweenLabels = true;
            myPane.XAxis.Scale.TextLabels         = labels;
            myPane.XAxis.Scale.FontSpec.Angle     = 90;
            myPane.XAxis.Scale.FontSpec.Size      = 11F;
            myPane.XAxis.Type = ZedGraph.AxisType.Text;
            myPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill       = new ZedGraph.Fill(Color.FromArgb(250, 250, 255));

            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
示例#10
0
        private void GenerateSuccessGraphAndTable()
        {
            #region Write graph
            GraphPane graphPane = new GraphPane(new Rectangle(0, 0, 420, 280), "", "", "");
            graphPane.CurveList.Clear();

            BarItem bar;

            // Set the bar type to percent stack, which makes the bars sum up to 100%
            graphPane.BarType = BarType.PercentStack;

            graphPane.XAxis.Title = "Test Series";
            graphPane.YAxis.Title = "Success rate";
            graphPane.YAxis.Max = 120;

            graphPane.XAxis.IsShowGrid = true;
            graphPane.YAxis.IsShowGrid = true;

            ArrayList SuccessData = statsEngine.GetSuccessRateData();
            graphPane.XAxis.Max = SuccessData.Count+1;

            int cnt = 0;
            double []ySuccess = new double[SuccessData.Count];
            double []yFailure = new double[SuccessData.Count];
            foreach (double d in SuccessData)
            {
                ySuccess[cnt] = d;
                yFailure[cnt] = 100 - d;
                cnt++;
            }

            // Add a gradient red bar
            bar = graphPane.AddBar("Failure",  null, yFailure, Color.Red);
            bar.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);

            // Add a gradient green bar
            bar = graphPane.AddBar("Success", null, ySuccess, Color.LightGreen);
            bar.Bar.Fill = new Fill(Color.LightGreen, Color.White, Color.LightGreen);

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

            #region Write table
            // write table header
            successTable = new StringBuilder();
            successTable.Append("<table><thead><tr>\n");
            successTable.Append("<th width=\"20%\">Thread</th>\n");
            successTable.Append("<th width=\"40%\">Success</th>\n");
            successTable.Append("<th width=\"40%\">Failure</th>\n");
            successTable.Append("</tr></thead><tbody>\n");
            bool oddline = true;
            for (int i=0; i<cnt; i++)
            {
                if (oddline == true)
                    successTable.Append("<tr class=\"odd\">\n");
                else
                    successTable.Append("<tr class=\"even\">\n");

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

                successTable.Append("<td class=\"s\">");
                successTable.AppendFormat("{0}", ySuccess[i]);
                successTable.Append("</td>\n");

                successTable.Append("<td class=\"s\">");
                if (yFailure[i] != 0)
                    successTable.AppendFormat("<b>{0}</b>", yFailure[i]);
                else
                    successTable.AppendFormat("{0}", yFailure[i]);
                successTable.Append("</td>\n");

                oddline = !oddline;
            }
            successTable.Append("</tr></table>\n");
            #endregion
        }
示例#11
0
        public void FindNearestObject()
        {
            testee = new GraphPane( new Rectangle( 10, 10, 10, 10 ),
            "Wacky Widget Company\nProduction Report",
            "Time, Days\n(Since Plant Construction Startup)",
            "Widget Production\n(units/hour)" );
            SetSize();

            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            LineItem curve;
            curve = testee.AddCurve( "Larry", x, y, Color.Green, SymbolType.Circle );
            curve.Line.Width = 1.5F;
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 60, 190, 50 ), 90F );
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Symbol.Size = 10;
            curve.Tag = "Larry";

            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            curve = testee.AddCurve( "Moe", x3, y3, Color.FromArgb( 200, 55, 135 ), SymbolType.Triangle );
            curve.Line.Width = 1.5F;
            //curve.Line.IsSmooth = true;
            curve.Symbol.Fill = new Fill( Color.White );
            curve.Line.Fill = new Fill( Color.White, Color.FromArgb( 160, 230, 145, 205 ), 90F );
            curve.Symbol.Size = 10;
            curve.Tag = "Moe";

            double[] x4 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4 = { 30, 45, -13, 60, 75, 83, 84, 79, 71, 57 };
            BarItem bar = testee.AddBar( "Wheezy", x4, y4, Color.SteelBlue );
            bar.Bar.Fill = new Fill( Color.RosyBrown, Color.White, Color.RosyBrown );
            bar.Tag = "Wheezy";
            //curve.Bar.Fill = new Fill( Color.Blue );
            //curve.Symbol.Size = 12;

            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, -7, 20, 25, 27, 29, 26, 24, 18 };
            bar = testee.AddBar( "Curly", x2, y2, Color.RoyalBlue );
            bar.Bar.Fill = new Fill( Color.RoyalBlue, Color.White, Color.RoyalBlue );
            bar.Tag = "Curly";
            //Brush brush = new HatchBrush( HatchStyle.Cross, Color.AliceBlue, Color.Red );
            //GraphicsPath path = new GraphicsPath();
            //path.AddLine( 10, 10, 20, 20 );
            //path.AddLine( 20, 20, 30, 0 );
            //path.AddLine( 30, 0, 10, 10 );

            //brush = new PathGradientBrush( path );
            //bar.Bar.Fill = new Fill( brush );

            testee.BarSettings.ClusterScaleWidth = 100;
            testee.BarSettings.Type = BarType.Stack;

            testee.Fill = new Fill( Color.WhiteSmoke, Color.Lavender, 0F );
            testee.Chart.Fill = new Fill( Color.White, Color.FromArgb( 255, 255, 166 ), 90F );

            testee.XAxis.MajorGrid.IsVisible = true;
            testee.YAxis.MajorGrid.IsVisible = true;
            testee.YAxis.Scale.Max = 120;
            testee.Y2Axis.IsVisible = true;
            testee.Y2Axis.Scale.Max = 120;

            TextObj text = new TextObj( "First Prod\n21-Oct-93", 175F, 80.0F );
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill( Color.White, Color.PowderBlue, 45F );
            text.Tag = "First";
            testee.GraphObjList.Add( text );

            ArrowObj arrow = new ArrowObj( Color.Black, 12F, 175F, 77F, 100F, 45F );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Upgrade", 700F, 50.0F );
            text.FontSpec.Angle = 90;
            text.FontSpec.FontColor = Color.Black;
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            testee.GraphObjList.Add( text );

            arrow = new ArrowObj( Color.Black, 15, 700, 53, 700, 80 );
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            arrow.Tag = "Arrow";
            testee.GraphObjList.Add( arrow );

            text = new TextObj( "Confidential", 0.8F, -0.03F );
            text.Location.CoordinateFrame = CoordType.ChartFraction;

            text.FontSpec.Angle = 15.0F;
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color = Color.Red;
            text.FontSpec.Fill.IsVisible = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            testee.GraphObjList.Add( text );

            testee.IsPenWidthScaled = false;

            EllipseObj ellipse = new EllipseObj( 500, 50, 200, 20, Color.Blue,
                Color.Goldenrod );
            ellipse.Location.CoordinateFrame = CoordType.AxisXYScale;
            ellipse.Tag = "Ellipse";
            testee.GraphObjList.Add( ellipse );

            //			Bitmap bm = new Bitmap( @"c:\temp\sunspot.jpg" );
            Bitmap bm = new Bitmap( @"c:\windows\winnt256.bmp" );
            Image image = Image.FromHbitmap( bm.GetHbitmap() );
            ImageObj imageItem = new ImageObj( image, new RectangleF( 0.8F, 0.8F, 0.2F, 0.2F ),
                CoordType.ChartFraction, AlignH.Left, AlignV.Top );
            imageItem.IsScaled = true;
            imageItem.Tag = "Bitmap";
            testee.GraphObjList.Add( imageItem );

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            TestUtils.ShowMessage( "For each step, read the message in the Title Bar of the form" );

            HandleFind( "Select the ellipse object", "Ellipse", 0, typeof( GraphObj ) );
            HandleFind( "Select the 'First Prod' text object", "First", 0, typeof( GraphObj ) );
            HandleFind( "Select the upgrade arrow object", "Arrow", 0, typeof( GraphObj ) );
            HandleFind( "Select the Graph Title", "", 0, typeof( GraphPane ) );
            HandleFind( "Select the X Axis", "ZedGraph.XAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y Axis", "ZedGraph.YAxis", 0, typeof( Axis ) );
            HandleFind( "Select the Y2 Axis", "ZedGraph.Y2Axis", 0, typeof( Axis ) );
            HandleFind( "Select the second curve in the legend", "", 1, typeof( Legend ) );
            HandleFind( "Select the tallest blue bar", "Curly", 6, typeof( CurveItem ) );
            HandleFind( "Select the negative brown bar", "Wheezy", 2, typeof( CurveItem ) );
            HandleFind( "Select the negative blue bar", "Curly", 2, typeof( CurveItem ) );
            HandleFind( "Select the highest green circle symbol", "Larry", 6, typeof( CurveItem ) );
            HandleFind( "Select the windows bitmap object", "Bitmap", 0, typeof( GraphObj ) );
        }
示例#12
0
        public void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            zgc.MasterPane.PaneList.Clear();

            time1 = 0;
            time2 = 0;

            XScaleValue1 = Convert.ToInt16(XScale1.Value);
            XScaleValue2 = Convert.ToInt16(XScale2.Value);

            GraphPane myPane1 = new GraphPane();
            GraphPane myPane2 = new GraphPane();

            zgc.MasterPane.Add(myPane1);
            zgc.MasterPane.Add(myPane2);

            zgc.MasterPane.PaneList[0].Legend.IsVisible = false;
            zgc.MasterPane.PaneList[1].Legend.IsVisible = false;

            myPane1.Chart.Fill = new Fill(Color.Black);
            myPane2.Chart.Fill = new Fill(Color.Black);
            myPane1.Title.Text = "myPane1";
            myPane1.Title.FontSpec.Size = 12F;
            myPane2.Title.Text = "myPane2";
            myPane2.Title.FontSpec.Size = 12F;

            if (IsScrolling)
            {
                //zgc.IsAntiAlias = true;
            }
            list1.Add(0, 0);

            //Make a new curve
            BarItem RecentBar1 = myPane1.AddBar("RecentBar", RecentPoint1, Color.Red);
            RecentBar1.Bar.Fill = new Fill(Color.Red);

            RecentBar1.Bar.Border = new Border(Color.Red, 10.0F);
            BarItem RecentBar2 = myPane2.AddBar("RecentBar", RecentPoint2, Color.Red);
            RecentBar2.Bar.Fill = new Fill(Color.Red);
            RecentBar2.Bar.Border = new Border(Color.Red, 10.0F);

            BarItem curve = myPane1.AddBar("Average Counts", list1, Color.White);
            curve.Bar.Border = new Border(Color.White, 1.0F);
            //curve.Line.Fill = new Fill (Color.White);
              //  curve.Line.IsVisible = false;

            BarItem curve2 = myPane2.AddBar("Counts (Avg ten)", list2, Color.White);
            curve2.Bar.Border = new Border(Color.White, 1.0F);

            //Timer fort the X axis, defined later
            timer1.Interval = 1; //10 - buffer size increases due to build up but levels out at about 112 bytes.
            timer1.Enabled = true;
            timer1.Start();

            // Layout the GraphPanes using a default Pane Layout
            using (Graphics g = this.CreateGraphics())
            {
                zgc.MasterPane.SetLayout(g, PaneLayout.SingleRow);
            }

            //Function to set axes of graphpanes.
            SetXAxis1();
            SetXAxis2();
            if (AutoScale.Checked == false)
            {
                SetYAxis1();
                SetYAxis2();
            }

            //Save begging time for reference
            tickStart = Environment.TickCount;

            Console.WriteLine("Create Graph");

            zgc.Invalidate();
        }
示例#13
0
        private static void CreateBar(int index, GraphPane myPane, string instanceName, double[] y, IList<Color> graphColors)
        {
            int colorIndex = index % graphColors.Count;
             Color barColor = graphColors[colorIndex];

             // Generate a bar with the Instance Name in the legend
             BarItem myBar = myPane.AddBar(instanceName, null, y, barColor);
             myBar.Bar.Fill = new Fill(barColor, Color.White, barColor);
        }
        /// <summary>
        /// 当前列表导出Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lbt_importall_Click(object sender, EventArgs e)
        {
            string TimeRange="";
            if (ext_StartInputDt.SelectedDate != DateTime.MinValue && ext_EndInputDt.SelectedDate != DateTime.MinValue)
            {
                TimeRange = ext_StartInputDt.SelectedDate.ToShortDateString() + "至" + ext_EndInputDt.SelectedDate.ToShortDateString();
            }
            else if (ext_StartInputDt.SelectedDate != DateTime.MinValue && ext_EndInputDt.SelectedDate == DateTime.MinValue)
            {
                TimeRange = ext_StartInputDt.SelectedDate.ToShortDateString() + "至—";
            }
            else if (ext_StartInputDt.SelectedDate == DateTime.MinValue && ext_EndInputDt.SelectedDate != DateTime.MinValue)
            {
                TimeRange = "—至" + ext_EndInputDt.SelectedDate.ToShortDateString();
            }
            else
            {
                TimeRange = "";
            }
            DataSet ds = logic.complaint.outputExcel(strWhere());
            DataTable dtlist = ds.Tables[0], dtcompany = ds.Tables[1], dtcomplaint = ds.Tables[2], dtcategory = ds.Tables[3], dtdepartment = ds.Tables[4];
            dtlist.Columns["complaintdt"].ColumnName = "日期";
            dtlist.Columns["buyername"].ColumnName = "客户名称";
            dtlist.Columns["productname"].ColumnName = "投诉产品";
            dtlist.Columns["complaintname"].ColumnName = "投诉类别";
            dtlist.Columns["department"].ColumnName = "责任部门";
            dtlist.Columns["responsibler"].ColumnName = "责任人";
            dtlist.Columns["sellername"].ColumnName = "责任供应商";
            dtlist.Columns["levelname"].ColumnName = "严重级别";
            dtlist.Columns["result"].ColumnName = "处理结果";
            dtlist.Columns["inputname"].ColumnName = "录入人";
            dtlist.Columns["remarks"].ColumnName = "投诉问题详情";
            dtlist.Columns.Remove("buyerid");
            dtlist.Columns.Remove("sellerid");
            ExportFacade facade = new ExportFacade();
            HSSFWorkbook workbook = facade.InitializeWorkbook("杭州农副产品物流网络有限公司", logic.sysAdmin.AdminID.ToString(), "采购配送系统", "投诉管理");
            Sheet sheet1 = workbook.CreateSheet("投诉详细");
            facade.CreateRowHeader(workbook, sheet1, TimeRange + " 投诉列表", dtlist);
            facade.FillRowData(workbook, sheet1, 2, dtlist, null, null, null, null);
            Sheet sheet2 = workbook.CreateSheet("客户投诉");
            facade.CreateRowHeader(workbook, sheet2, TimeRange + " 客户投诉情况", dtcompany);
            facade.FillRowData(workbook, sheet2, 2, dtcompany, null, null, null, null);
            Sheet sheet3 = workbook.CreateSheet("投诉汇总");
            facade.CreateRowHeader(workbook, sheet3, TimeRange + " 投诉问题汇总", dtcomplaint);
            facade.FillRowData(workbook, sheet3, 2, dtcomplaint, null, null, null, null);
            #region 小类投诉情况
            GraphPane graphpane = new GraphPane();
            graphpane.Title.Text = "小类投诉情况";
            graphpane.Title.FontSpec.Size = 12f;
            graphpane.XAxis.Title.Text = "小类";
            graphpane.XAxis.Title.FontSpec.Size = 11f;
            graphpane.YAxis.Title.Text = ChangeStr("投诉数量");
            graphpane.YAxis.Title.FontSpec.Angle = 90;
            graphpane.YAxis.Title.FontSpec.Size = 11f;
            graphpane.XAxis.IsVisible = true;
            graphpane.YAxis.IsVisible = true;
            List<string> category=new List<string>();
            List<double> cnum = new List<double>();
            int maxcnum = 2;
            foreach (DataRow dr in dtcategory.Rows)
            {
                if(Convert.ToInt32( dr[1].ToString())>maxcnum)
                    maxcnum=Convert.ToInt32( dr[1].ToString());
                category.Add(ChangeStr( dr[0].ToString()));
                cnum.Add(Convert.ToDouble(dr[1].ToString()));
            }

            BarItem baritem = graphpane.AddBar(null,null,cnum.ToArray(), Color.Red);
            baritem.Bar.Fill = new Fill(Color.Red, Color.White, Color.Red);
            BarItem.CreateBarLabels(graphpane, false, "f0");
            graphpane.XAxis.Scale.TextLabels = category.ToArray();
            graphpane.XAxis.Scale.Max = category.ToArray().Length+1;
            graphpane.XAxis.Scale.MajorStep = 1;
            graphpane.XAxis.MinorTic.Size = 0;
            graphpane.XAxis.MajorTic.Size = 0;
            graphpane.XAxis.Cross = 0;
            graphpane.XAxis.Scale.FontSpec.Size = 10f;
            graphpane.XAxis.Scale.FontSpec.Family = "宋体";
            graphpane.XAxis.Type = AxisType.Text;
            graphpane.XAxis.MajorTic.IsOutside = false;
            graphpane.XAxis.MajorTic.IsOpposite = false;
            graphpane.YAxis.Scale.Max = maxcnum+2;
            graphpane.YAxis.MinorTic.Size = 0;
            graphpane.YAxis.MinorGrid.DashOff = 0;
            graphpane.YAxis.Scale.MajorStep = 1;
            graphpane.YAxis.MajorTic.IsOpposite = false;
            graphpane.YAxis.MajorTic.IsOutside = false;
            graphpane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            graphpane.Fill = new Fill(Color.White, Color.FromArgb(250, 250, 255),45.0f);
            graphpane.Fill.IsScaled = true;
            MemoryStream ms = new MemoryStream();
            //zgc.GetImage().Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
            Bitmap map = graphpane.GetImage(750,550,17);
            map.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] picbyte = ms.ToArray();
            int index = workbook.AddPicture(picbyte, NPOI.SS.UserModel.PictureType.JPEG);
            Sheet sheet4 = workbook.CreateSheet("小类投诉");
            facade.CreateRowHeader(workbook, sheet4, TimeRange + " 小类投诉情况", dtcategory);
            facade.FillRowData(workbook, sheet4, 2, dtcategory, null, null, null, null);
            HSSFPatriarch hssfpatriarch = (HSSFPatriarch)sheet4.CreateDrawingPatriarch();
            HSSFClientAnchor hssfanchor = new HSSFClientAnchor(0, 0, 0, 0, 4, 1, 18, 28);
            HSSFPicture hssfpic = (HSSFPicture)hssfpatriarch.CreatePicture(hssfanchor, index);
            #endregion
            #region 部门投诉情况
            GraphPane gp2 = new GraphPane();
            gp2.Title.Text = "部门投诉情况";
            gp2.XAxis.IsVisible = false;
            gp2.YAxis.IsVisible = false;
            gp2.Title.FontSpec.Size = 12f;
            gp2.Fill = new Fill(Color.White);
            gp2.Chart.Fill.Type = FillType.None;
            gp2.Legend.Position = LegendPos.Float;
            gp2.Legend.Location = new Location(0.95f, 0.08f, CoordType.PaneFraction, AlignH.Right, AlignV.Top);
            gp2.Legend.FontSpec.Size = 10f;
            gp2.Legend.IsHStack = false;
            List<double> comnum=new List<double>();
            List<string> dname=new List<string>();
            foreach(DataRow dr in dtdepartment.Rows )
            {
                gp2.AddPieSlice(Convert.ToDouble(dr[1].ToString()), GetRandomColor(), 0, dr[0].ToString()+" ("+dr[1].ToString()+")").LabelType=PieLabelType.Percent;
            }
            Bitmap bitmap = gp2.GetImage(700, 700, 14);
            MemoryStream mstream = new MemoryStream();
            bitmap.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] buffer = mstream.ToArray();
            int picindex = workbook.AddPicture(buffer, NPOI.SS.UserModel.PictureType.JPEG);
            Sheet sheet5 = workbook.CreateSheet("部门投诉");
            facade.CreateRowHeader(workbook, sheet5, TimeRange + " 责任部门投诉情况", dtdepartment);
            facade.FillRowData(workbook, sheet5, 2, dtdepartment, null, null, null, null);
            HSSFPatriarch patriarch = (HSSFPatriarch)sheet5.CreateDrawingPatriarch();
            HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 0, 0, 4, 1, 15, 34);
            HSSFPicture pic = (HSSFPicture)patriarch.CreatePicture(anchor, picindex);
            #endregion
            facade.ExportByWeb(workbook, TimeRange.ToString() + "采购配送系统投诉统计", TimeRange.ToString() + "采购配送系统投诉统计.xls");
        }
示例#15
0
        private void membuat_histogram_primitif(Bitmap gambar, GraphPane histogram, string RGB)
        {
            int[] nilai_pixel = new int[256];
            int tmp, r, g, b;
            PointPairList data_pixel = new PointPairList();
            BarItem kurva;
            if (RGB == "red") //jika red
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).R;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Red);
                kurva.Bar.Fill = new Fill(Color.Red);
                //histogram.AxisFill = new Fill(Color.Red);
            }
            else if (RGB == "green") //jika green
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).G;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Green);
                kurva.Bar.Fill = new Fill(Color.Green);
            }
            else if (RGB == "blue") //jika blue
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = gambar.GetPixel(i, j).B;
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Blue);
                kurva.Bar.Fill = new Fill(Color.Blue);
            }
            else if (RGB == "gabungan") //jika gabungan
            {
                int[,] n_p = new int[256, 3];
                int nilai_mak = 0;
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {

                        r = gambar.GetPixel(i, j).R;
                        g = gambar.GetPixel(i, j).G;
                        b = gambar.GetPixel(i, j).B;

                        n_p[r, 0] += 1;
                        n_p[g, 1] += 1;
                        n_p[b, 2] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    /*if (nilai_mak < n_p[i, 0]) nilai_mak = n_p[i, 0]; //jika r lebih besar
                    else if (nilai_mak < n_p[i, 1]) nilai_mak = n_p[i, 1]; //jika g lebih besar
                    else if (nilai_mak < n_p[i, 2]) nilai_mak = n_p[i, 2]; //jika b lebih besar

                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;*/

                    nilai_mak = nilai_mak + n_p[i, 0] + n_p[i, 1] + n_p[i, 2];
                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;
                }

                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Black);
                kurva.Bar.Fill = new Fill(Color.Black);
            }
            else if(RGB == "luminositi")
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        tmp = (int)((gambar.GetPixel(i, j).R * .3) + (gambar.GetPixel(i, j).G * .59) + (gambar.GetPixel(i, j).B * .11));
                        nilai_pixel[tmp] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Black);
                //kurva.Bar.Fill = new Fill(Color.White);
            }
        }
示例#16
0
        private void membuat_histogram_emgu(Image<Bgr,byte> gambar, GraphPane histogram, string RGB)
        {
            int[] nilai_pixel = new int[256];
            //int tmp, r, g, b;
            PointPairList data_pixel = new PointPairList();
            BarItem kurva;

            //load image
            //Image<Bgr, byte> image = new Image<Bgr, byte>("sample.png");

            //get the pixel from [row,col] = 24,24
            //Bgr pixel = image[24, 24];

            //get the b,g,r values
            //double b = pixel.Blue;
               // double g = pixel.Green;
            //double r = pixel.Red;
            int r, g, b, grey;
            Bgr pixel;

            if (RGB == "red") //jika red
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        r = (int)pixel.Red;
                        nilai_pixel[r] += 1;
                        /*MessageBox.Show(r.ToString());
                        MessageBox.Show(nilai_pixel[r].ToString());*/
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Red);
                kurva.Bar.Fill = new Fill(Color.Red);
                //histogram.AxisFill = new Fill(Color.Red);
            }
            else if (RGB == "green") //jika green
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        g = (int)pixel.Green;
                        nilai_pixel[g] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Green);
                kurva.Bar.Fill = new Fill(Color.Green);
            }
            else if (RGB == "blue") //jika blue
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        b = (int)pixel.Blue;
                        nilai_pixel[b] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Blue);
                kurva.Bar.Fill = new Fill(Color.Blue);
            }
            else if (RGB == "gabungan") //jika gabungan
            {
                int[,] n_p = new int[256, 3];
                int nilai_mak = 0;
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {

                        pixel = gambar[j, i];
                        r = (int)pixel.Red;
                        g = (int)pixel.Green;
                        b = (int)pixel.Blue;

                        n_p[r, 0] += 1;
                        n_p[g, 1] += 1;
                        n_p[b, 2] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    /*if (nilai_mak < n_p[i, 0]) nilai_mak = n_p[i, 0]; //jika r lebih besar
                    else if (nilai_mak < n_p[i, 1]) nilai_mak = n_p[i, 1]; //jika g lebih besar
                    else if (nilai_mak < n_p[i, 2]) nilai_mak = n_p[i, 2]; //jika b lebih besar

                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;*/

                    nilai_mak = nilai_mak + n_p[i, 0] + n_p[i, 1] + n_p[i, 2];
                    data_pixel.Add(i, nilai_mak);
                    nilai_mak = 0;
                }

                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Black);
                kurva.Bar.Fill = new Fill(Color.Black);
            }
            else if (RGB == "luminositi")
            {
                for (int i = 0; i < gambar.Width; i++)
                {
                    for (int j = 0; j < gambar.Height; j++)
                    {
                        pixel = gambar[j, i];
                        grey = (int)((pixel.Red * .3) + (pixel.Green * .59) + (pixel.Blue * .11));
                        nilai_pixel[grey] += 1;
                    }
                }
                for (int i = 0; i < 256; i++)
                {
                    data_pixel.Add(i, nilai_pixel[i]);
                }
                kurva = histogram.AddBar("Nilai Pixel", data_pixel, Color.Black);
                //kurva.Bar.Fill = new Fill(Color.White);
            }
        }
示例#17
0
        public void SortedOverlayBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Sorted Overlay Bar Graph Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, -115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, -100, 95, -35, 0, 35, 35 };
            double[] y3 = { 80, -110, 65, 15, 54, 67, 18 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y3, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	overlay bars
            testee.BarSettings.Type = BarType.SortedOverlay;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            string lab = "";
            TextObj text = null;
            for ( int x = 0; x < 3; x++ )
                for ( int i = 0; i < y.Length; i++ )
                {
                    //	format	the label string to	have	1 decimal place
                    switch ( x )
                    {
                        case 0:
                            lab = y[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y[i] < 0 ? y[i] + 2 * shift : y[i] ) - shift );
                            break;
                        case 1:
                            lab = y2[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? y2[i] + 2 * shift : y2[i] ) - shift );
                            break;
                        case 2:
                            lab = y3[i].ToString();
                            text = new TextObj( lab, (float)( i + 1 ), (float)( y3[i] < 0 ? y3[i] + 2 * shift : y3[i] ) - shift );
                            break;
                        default:
                            break;
                    }
                    text.FontSpec.Size = 4;
                    text.FontSpec.IsBold = true;
                    //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                    text.Location.CoordinateFrame = CoordType.AxisXYScale;
                    //	Align the left-center	of the text to the	specified	point
                    text.Location.AlignH = AlignH.Center;
                    text.Location.AlignV = AlignV.Center;
                    text.FontSpec.Border.IsVisible = false;
                    //	add the	TextObj to	the	list
                    testee.GraphObjList.Add( text );
                }

            form2.WindowState = FormWindowState.Maximized;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a Sorted Overlay Stack Bar displayed with the segments in increasing value order as indicated by the embedded values? " ) );
        }
示例#18
0
        public void HorizClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Horizontal	Clustered Bar Graph Test ", "Label", "My Y Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty", "Wildcat" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10, 20 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, -35, 30 };
            double[] y3 = { 80, 0, 65, -15, 54, 67, 18, 50 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", y, null, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", y2, null, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", y3, null, Color.Green );
            //	Draw the Y tics	between the labels instead of	at the labels
            testee.YAxis.MajorTic.IsBetweenLabels = true;

            //	Set the YAxis	labels
            testee.YAxis.Scale.TextLabels = labels;
            testee.YAxis.Scale.FontSpec.Size = 9F;
            //show	the zero	line
            testee.XAxis.MajorGrid.IsZeroLine = true;
            //	Set the YAxis	to Text	type
            testee.YAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.Y;

            testee.YAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.XAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a horizontal clustered bar graph having the proper number of bars per y-Axis point visible ? <Next Step: Resize the graph>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all y-Axis labels visible?" ) );
        }
示例#19
0
        public void StkBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Stack Bar	Graph	Test ", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 0, 40, -10 };
            double[] y2 = { 90, 100, -95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, -18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;
            //display as	stack bar
            testee.BarSettings.Type = BarType.Stack;
            //display horizontal grid	lines
            testee.YAxis.MajorGrid.IsVisible = true;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;
            //turn	off pen width	scaling
            testee.IsPenWidthScaled = false;

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a stack bar graph having three bars per x-Axis point visible ?  <Next Step: Maximize the display>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?  <Next Step: Add a curve>" ) );

            LineItem curve = new LineItem( "Curve A", null, y4, Color.Black, SymbolType.TriangleDown );
            testee.CurveList.Insert( 0, curve );
            curve.Line.Width = 1.5F;
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill = new Fill( Color.Yellow );
            curve.Symbol.Size = 8;

            form2.Refresh();

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Was a new curve displayed on top of the bars?" ) );
        }
示例#20
0
        public void CreateGraph(ZedGraph.ZedGraphControl zgc)
        {
            zgc.MasterPane.PaneList.Clear();

            time1 = 0;
            time2 = 0;
            GraphPane myPane1 = new GraphPane();
            //GraphPane myPane2 = new GraphPane();
            zgc.MasterPane.Add(myPane1);
            //    zgc.MasterPane.Add(myPane2);

            myPane1.Title.Text = "myPane1" ;
            //myPane2.Title.Text = "myPane2";
            zgc.GraphPane.TitleGap = 0f;
            zgc.GraphPane.XAxis.Scale.LabelGap = 0f;
            zgc.GraphPane.YAxisList[0].Scale.LabelGap = 0f;

            //FilteredPointList Flist = new FilteredPointList(x,y);
            //FilterList = Flist;
            //Flist.SetBounds(x[j] - 10000, x[j], 500);
            //Make a new curve
             BarItem curve = myPane1.AddBar("Average Counts", list1, Color.Black/*, SymbolType.None*/);
            // TextureBrush joebrush = new TextureBrush(Joe);
            curve.Bar.Fill = new Fill(Color.Black);
             //curve.Line.IsVisible = false;
            //zgc.IsAntiAlias = true;

            // LineItem curve2 = myPane2.AddCurve("Counts (Avg ten)", list2, Color.Black, SymbolType.None);
             //TextureBrush grahambrush = new TextureBrush(graham);
               //  curve2.Line.Fill = new Fill(Color.Black);
               //  curve2.Line.Width = 3.0F;

            myPane1.Margin.All = 0;
            myPane1.Legend.IsVisible = false;
            myPane1.Title.IsVisible = false;
            myPane1.XAxis.IsVisible = false;

            //myPane1.XAxis.Draw(this.CreateGraphics(), myPane1, 1, 2000F);
            //Font XAxisFont = new Font("Arial", 6, GraphicsUnit.Pixel);
            //this.Font = f1;
            //myPane1.XAxis.Scale.FontSpec.Family = XAxisFont;
               /* myPane1.XAxis.Scale.FontSpec.Size = 10;
            Console.WriteLine("Width is {0}", myPane1.XAxis.Scale.FontSpec.GetWidth(this.CreateGraphics(),Convert.ToString(123),1);
            myPane1.XAxis.MinorTic.Size = 0;
            myPane1.XAxis.MajorTic.Size = 7;

            myPane1.YAxis.Scale.FontSpec.Size = 10;
            myPane1.YAxis.MinorTic.Size = 0;
            myPane1.YAxis.MajorTic.Size = 7;
            */

               // myPane1.YAxis.IsVisible = false;
            //Timer fort the X axis, defined later
            timer1.Interval = 10; //10 - buffer size increases due to build up but levels out at about 112 bytes.
            timer1.Enabled = true;
            timer1.Start();

            //Function to set axes of graphpanes.
            SetXAxis1();
            SetXAxis2();
            if (AutoScale.Checked == false)
            {
                SetYAxis();
            }

            // Layout the GraphPanes using a default Pane Layout
            using (Graphics g = this.CreateGraphics())
            {
                zgc.MasterPane.SetLayout(g, PaneLayout.SingleRow);
            }

            zgc.AxisChange();
            /*Save begging time for reference
            tickStart = Environment.TickCount;*/
            myPane1.XAxis.IsVisible = true;
            Console.WriteLine("Create Graph");
        }
示例#21
0
        public void ClusteredBarGraph()
        {
            //	Create a new	graph
            testee = new GraphPane( new Rectangle( 40, 40, form2.Size.Width - 80, form2.Size.Height - 80 ),
                "Clustered Bar Graph Test", "Label", "My	Y	Axis" );

            string[] labels = { "Panther", "Lion", "Cheetah", "Cougar", "Tiger", "Leopard", "Kitty" };
            double[] y = { 100, 115, 75, -22, 98, 40, -10 };
            double[] y2 = { 90, 100, 95, 35, 0, 35, -35 };
            double[] y3 = { 80, 110, 65, -15, 54, 67, 18 };

            double[] y4 = { 120, 125, 100, 20, 105, 75, -40 };

            //	Generate three	bars	with	appropriate entries in	the legend
            CurveItem myCurve = testee.AddBar( "Curve	1", null, y, Color.Red );
            CurveItem myCurve1 = testee.AddBar( "Curve	2", null, y2, Color.Blue );
            CurveItem myCurve2 = testee.AddBar( "Curve	3", null, y3, Color.Green );
            //	Draw the X tics	between the labels instead of	at the labels
            testee.XAxis.MajorTic.IsBetweenLabels = true;

            //	Set the XAxis	labels
            testee.XAxis.Scale.TextLabels = labels;
            testee.XAxis.Scale.FontSpec.Size = 9F;
            //	Set the XAxis	to Text type
            testee.XAxis.Type = AxisType.Text;
            testee.BarSettings.Base = BarBase.X;

            testee.XAxis.Scale.IsReverse = false;
            testee.BarSettings.ClusterScaleWidth = 1;

            //Add Labels to the curves

            //	Shift	the text items up by	5 user	scale units	above	the	bars
            const float shift = 5;

            for ( int i = 0; i < y.Length; i++ )
            {
                //	format	the label string to	have	1 decimal place
                string lab = y2[i].ToString( "F1" );
                //	create	the text item (assumes	the	x	axis is	ordinal or	text)
                //	for negative bars, the	label appears just	above	the zero	value
                TextObj text = new TextObj( lab, (float)( i + 1 ), (float)( y2[i] < 0 ? 0.0 : y2[i] ) + shift );
                //	tell	Zedgraph to use user	scale units	for locating	the	TextObj
                text.Location.CoordinateFrame = CoordType.AxisXYScale;
                //	Align the left-center	of the text to the	specified	point
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Center;
                text.FontSpec.Border.IsVisible = false;
                //	rotate the	text 90 degrees
                text.FontSpec.Angle = 90;
                //	add the	TextObj to	the	list
                testee.GraphObjList.Add( text );
            }

            //	Tell ZedGraph to	refigure	the
            //	axes	since the data have	changed
            testee.AxisChange( form2.CreateGraphics() );
            //	Add one step to the	max	scale value	to leave	room for the labels
            testee.YAxis.Scale.Max += testee.YAxis.Scale.MajorStep;

            testee.AxisChange( form2.CreateGraphics() );
            SetSize();
            form2.Refresh();

            Assert.IsTrue( TestUtils.promptIfTestWorked(
                "Is a clustered bar graph having the proper number of bars per x-Axis point visible ?  <Next Step: Resize the chart>" ) );

            TestUtils.DelaySeconds( 3000 );

            Assert.IsTrue( TestUtils.promptIfTestWorked( "Did the graph resize ok with all x-Axis labels visible?" ) );
        }
示例#22
0
        /// <summary>
        /// Plot the hourly precipitation !!!!
        /// </summary>
        private void PlotPrecipHour(ITimeSeries ts, GraphPane myPane)
        {
            TimeInterval interval = new TimeInterval(ts.Start, ts.End);
            string varName = Resources.precip_label;

            //Main creation of curve
            if ( interval.Length.TotalDays <= 2 )
            {
                BarItem myCurve = myPane.AddBar(varName, ts, Color.Blue);
                myCurve.Bar.Border.Color = Color.Blue;
                myCurve.Bar.Border.IsVisible = true;
                myCurve.Bar.Fill.Type = FillType.Solid;
                myCurve.Bar.Fill.IsScaled = false;
            }
            else
            {
                StickItem myCurve = myPane.AddStick(varName, ts, Color.Blue);
            }

            //cumulative precipitation..
            ITimeSeries ts2 = ts.ShowCumulative();
            LineItem myCurve2 = myPane.AddCurve(Resources.precip_sum_label,
                ts2, Color.Red, SymbolType.None);
            myCurve2.IsY2Axis = true;
            myPane.AxisChange();
        }
示例#23
0
        public void SortedOverlayBar(GraphPane myPane, ZedGraphControl zedGraphControl)
        {
            myPane = zedGraphControl.GraphPane;
            myPane.YAxis.Title.Text = "数量";
            myPane.XAxis.Title.Text = "金属";
            myPane.XAxis.Title.FontSpec.Size = 15.0F;
            myPane.YAxis.Title.FontSpec.Size = 15.0F;
            myPane.Title.Text = "库存图表";
            List<Inventory> inventoryList = new List<Inventory>();//库存
            List<DeliveryLine> internalTDList = new List<DeliveryLine>();//内贸
            List<DeliveryLine> externalTDList = new List<DeliveryLine>();//外贸
            List<Commodity> commodityList = new List<Commodity>();
            using (var inventoryService = SvcClientManager.GetSvcClient<InventoryServiceClient>(SvcType.InventorySvc))
            {
                inventoryList = inventoryService.GetInventoriesByInternalCustomer(CurrentUser.Id, InternalCustomerID);
                internalTDList = inventoryService.GetInternalTDList(null, InternalCustomerID, CurrentUser.Id);
                externalTDList = inventoryService.GetExternalTDList(null, InternalCustomerID, CurrentUser.Id);
            }
            if (inventoryList.Count > 0)
            {
                commodityList.AddRange(inventoryList.Select(c => c.Commodity).ToList());
            }
            if (internalTDList.Count > 0)
            {
                commodityList.AddRange(internalTDList.Select(c => c.Delivery.Quota.Commodity).ToList());
            }
            if (externalTDList.Count > 0)
            {
                commodityList.AddRange(externalTDList.Select(c => c.Delivery.Quota.Commodity).ToList());
            }
            List<Commodity> cList = new List<Commodity>();
            foreach(Commodity commodity in commodityList)
            {
                if (cList.Count > 0)
                {
                    if (!cList.Select(c => c.Id).Contains(commodity.Id))
                    {
                        cList.Add(commodity);
                    }
                }
                else
                {
                    cList.Add(commodity);
                }
            }

            string[] labels = new string[cList.Count];
            double[] y = new double[cList.Count];
            double[] y2 = new double[cList.Count];
            double[] y3 = new double[cList.Count];
            int num = 0;
            if (cList.Count > 0)
            {
                foreach (Commodity c in cList)
                {
                    labels[num] = c.Name;
                    List<Inventory> list = inventoryList.Where(a => a.CommodityId == c.Id).ToList();
                    List<DeliveryLine> list1 = internalTDList.Where(d => d.Delivery.Quota.CommodityId == c.Id).ToList();
                    List<DeliveryLine> list2 = externalTDList.Where(o => o.Delivery.Quota.CommodityId == o.Id).ToList();
                    if (list.Count > 0)
                    {
                        y[num] = Convert.ToDouble(list.Sum(a => a.Quantity));
                    }
                    else
                    {
                        y[num] = 0;
                    }
                    if (list1.Count > 0)
                    {
                        y2[num] = Convert.ToDouble(list1.Sum(a => a.VerifiedWeight));
                    }
                    else
                    {
                        y2[num] = 0;
                    }
                    if (list2.Count > 0)
                    {
                        y3[num] = Convert.ToDouble(list2.Sum(a => a.VerifiedWeight));
                    }
                    else
                    {
                        y3[num] = 0;
                    }
                    num++;
                }
            }

            CurveItem myCurve = myPane.AddBar("仓库库存", null, y, Color.Red);

            // Generate a blue bar with "Curve 2" in the legend
            myCurve = myPane.AddBar("内贸提单", null, y2, Color.Blue);

            // Generate a green bar with "Curve 3" in the legend
            myCurve = myPane.AddBar("外贸提单", null, y3, Color.Green);

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

            // Set the XAxis to the ordinal type

            myPane.XAxis.Type = AxisType.Text;
            myPane.XAxis.Scale.TextLabels = labels;
            myPane.XAxis.Scale.FontSpec.Size = 15.0F;

            //types = ChartType.Bar;

            //const float shift = 5;

            //for (int i = 0; i < y.Length; i++)
            //{
            //    // format the label string to have 1 decimal place
            //    string lab = y3[i].ToString("F1");
            //    // create the text item (assumes the x axis is ordinal or text)
            //    // for negative bars, the label appears just above the zero value
            //    TextObj text = new TextObj(lab, (float)(i + 1), (float)(y3[i] + y2[i] + y[i]) + shift);//y3[i] < 0 ? 0.0 : y3[i]
            //    // tell Zedgraph to use user scale units for locating the TextObj
            //    text.Location.CoordinateFrame = CoordType.AxisXYScale;
            //    // AlignH the left-center of the text to the specified point
            //    text.Location.AlignH = AlignH.Left;
            //    text.Location.AlignV = AlignV.Center;
            //    text.FontSpec.Border.IsVisible = false;
            //    text.FontSpec.Fill.IsVisible = false;
            //    // rotate the text 90 degrees
            //    text.FontSpec.Angle = 90;
            //    // add the TextObj to the list
            //    myPane.GraphObjList.Add(text);
            //}

            // Indicate that the bars are overlay type, which are drawn on top of eachother
            myPane.BarSettings.Type = BarType.Overlay;

            // Fill the axis background with a color gradientC:\Documents and Settings\champioj\Desktop\ZedGraph-4.9-CVS\demo\ZedGraph.Demo\StepChartDemo.cs
            myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0F);

            zedGraphControl.AxisChange();

            // Add one step to the max scale value to leave room for the labels
            //myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;
        }
示例#24
0
        /// <summary>
        /// Plot the hourly precipitation !!!!
        /// </summary>
        /// <param name="ts"></param>
        /// <param name="myPane"></param>
        private void PlotPrecipHour(ITimeSeries ts, GraphPane myPane)
        {
            DateTime MinDate, MaxDate;

            if (ts.Count > 0)
            {
                TimeSeries ts1 = (TimeSeries)ts.AggregateHourly();

                MinDate = ts1.Start;
                MaxDate = ts1.End;

                //Main creation of curve
                double totalDays = (MaxDate.Subtract(MinDate)).TotalDays;
                if (totalDays < 2)
                {
                    BarItem myCurve = myPane.AddBar("srážky", ts1, Color.Blue);
                    myCurve.Bar.Border.Color = Color.Blue;
                    myCurve.Bar.Border.IsVisible = true;
                    myCurve.Bar.Fill.Type = FillType.Solid;
                    myCurve.Bar.Fill.IsScaled = false;
                }
                else
                {
                    StickItem myCurve = myPane.AddStick("srážky", ts1, Color.Blue);
                }

                //cumulative precipitation..
                if (ts != null)
                {

                    TimeSeries ts2 = (TimeSeries)ts.ShowCumulative();
                    LineItem myCurve2 = myPane.AddCurve("suma srážek", ts2, Color.Red, SymbolType.None);
                    myCurve2.IsY2Axis = true;

                    myPane.AxisChange();
                }
            }
        }
示例#25
0
        private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray)
        {
            _graphPane = zed.GraphPane;
            _graphPane.Title.Text = title;

			_graphPane.XAxis.Title.Text = xAxisTitle;
			_graphPane.XAxis.MajorGrid.IsVisible = true;

			_graphPane.YAxis.Title.Text = y1AxisTitle;
			_graphPane.YAxis.MajorGrid.IsVisible = true;

			_graphPane.Y2Axis.Title.Text = y2AxisTitle;
			_graphPane.Y2Axis.MajorGrid.IsVisible = false;

            // Create point-pair lists and bind them to the graph control.
            int sourceCount = dataSourceArray.Length;
            _pointPlotArray = new PointPairList[sourceCount];
            for(int i=0; i<sourceCount; i++)
            {
                SummaryDataSource ds = dataSourceArray[i];
                _pointPlotArray[i] =new PointPairList();

                Color color = _plotColorArr[i % 3];
                BarItem barItem = _graphPane.AddBar(ds.Name, _pointPlotArray[i], color);
                barItem.Bar.Fill = new Fill(color);
                _graphPane.BarSettings.MinClusterGap = 0;

                barItem.IsY2Axis = (ds.YAxis == 1);
            }
        }
示例#26
0
	private string CreateStatisticMoneyImage(GameServer server, string dateFrom, string dateTo, ChartType type, bool showSymbol)
	{
		using (IBlazeDatabase db = DbFactory.GetDatabase())
		{
			IBlazeTable gameLogTable = db.GetTable(TableString.GameLogTableName);
			DataSet data = new DataSet();			

			gameLogTable.Get(
				data,
				FilterFactory.CreateAndFilter(
					FilterFactory.CreateEqualFilter(TableString.GameLogFieldGameServerId, server.Id),
					FilterFactory.CreateAndFilter(
						FilterFactory.CreateLargerEqualFilter(TableString.GameLogFieldDate, dateFrom),
						FilterFactory.CreateLesserEqualFilter(TableString.GameLogFieldDate, dateTo)
					)
				)
			);

			DataTable table = data.Tables[0];

			int count = table.Rows.Count;
			double[] money = new double[count];
			double[] moneyInBox = new double[count];
			double[] moneyTotal = new double[count];
			double[] date = new double[count];
			for (int i = 0; i < count; i++)
			{
				DataRow row = table.Rows[i];
				money[i] = (long)row[TableString.GameLogFieldTotalMoney];
				moneyInBox[i] = (long)row[TableString.GameLogFieldTotalMoneyInBox];
				moneyTotal[i] = money[i] + moneyInBox[i];
				DateTime currentDate = (DateTime)row[TableString.GameLogFieldDate];
				date[i] = new XDate(currentDate.Year, currentDate.Month, currentDate.Day);
			}

			bool success = true;

			if (success)
			{
				//»æÖÆͼ±í
				GraphPane graphPane = new GraphPane();

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

				graphPane.Legend.Fill.IsVisible = false;
				graphPane.Legend.Border.IsVisible = false;

				graphPane.XAxis.Title.Text = StringDef.Date;
				graphPane.XAxis.MajorGrid.Color = WebConfig.GraphXAxisGridColor;
				graphPane.XAxis.Type = AxisType.DateAsOrdinal;				
				graphPane.XAxis.MinorTic.Size = 0;
				graphPane.XAxis.Scale.MajorStep = 1;
				graphPane.XAxis.Scale.MajorUnit = DateUnit.Day;				
				graphPane.XAxis.Scale.FontSpec.Size = 12;
				graphPane.XAxis.Scale.Format = "M-d";

				graphPane.YAxis.Title.Text = StringDef.Money;
				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 (type == ChartType.Bar)
				{
					graphPane.BarSettings.Type = BarType.Stack;

					BarItem barItemMoney = graphPane.AddBar(StringDef.Money, date, money, Colors[0]);
					BarItem barItemMoneyInBox = graphPane.AddBar(StringDef.MoneyInBox, date, moneyInBox, Colors[1]);
					barItemMoney.Bar.Fill = new Fill(Colors[0]);
					barItemMoneyInBox.Bar.Fill = new Fill(Colors[1]);
				}
				else if (type == ChartType.Line)
				{
					LineItem lineItemMoney = graphPane.AddCurve(StringDef.Money, date, money, Colors[0], (showSymbol ? WebConfig.GraphSymbols[0] : SymbolType.None));
					LineItem lineItemMoneyInBox = graphPane.AddCurve(StringDef.MoneyInBox, date, moneyInBox, Colors[1], (showSymbol ? WebConfig.GraphSymbols[1] : SymbolType.None));
					LineItem lineItemMoneyTotal = graphPane.AddCurve(StringDef.MoneyTotal, date, moneyTotal, Colors[2], (showSymbol ? WebConfig.GraphSymbols[2] : SymbolType.None));
				}

				Bitmap bitmap = new Bitmap(1, 1);
				using (Graphics g = Graphics.FromImage(bitmap))
				{
					graphPane.AxisChange(g);
				}

				bitmap = graphPane.GetImage(WebConfig.StatisticRoleCountByLevelGraphWidth, WebConfig.StatisticRoleCountByLevelGraphHeight, 75.0f);
				string imageName = WebUtil.CreateRandomName("Statistic", WebConfig.GraphFileSuffix);
				string file = WebConfig.WebsiteRootPath + WebConfig.TempGraphPath + imageName;
				try
				{
					bitmap.Save(file, WebConfig.GraphImageFormat);
					TempFileManager.TheInstance.AddTempFile(file, 5000 * WebConfig.TempGraphDeleteDelayMultiple);

					return imageName;
				}
				catch (Exception)
				{
					//TODO ¼Ç¼´íÎó
					return null;
				}
			}

			return null;
		}
	}
示例#27
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 );
        }
示例#28
0
        private void graphYYDetails(GraphPane myPane)
        {
            myPane.BarSettings.Type = BarType.Stack;

            // vai buscar uma cor
            int color = 0;

            foreach(int c in Business.ManagementDataBase.caracteristicas_escolhidas.Keys) {
                PointPairList list = new PointPairList();

                list = graphYYDetailsAux("" + c);

                Business.Characteristic ch = Business.ManagementDataBase.getCharacteristics(c);

                BarItem barra = myPane.AddBar(ch.Name, list, myColor(color));
                barra.Bar.Fill = new Fill(myColor(color));
                color++;
            }

            return;
        }