Exemplo n.º 1
0
        public void DrawValues()
        {
            if (_AddTextValue && _TraceType == TraceType.Bar)
            {
                BarItem.CreateBarLabels(myPane, false, "0", "Arial", 7, Color.Black, false, false, false);
            }

            if (_AddTextValue && (_TraceType == TraceType.Square || TraceType == TraceType.Line || TraceType == TraceType.Curve))
            {
                foreach (SynapseGraphTrace trace in TraceCollection)
                {
                    foreach (SynapseGraphPoint pt in trace.PointList)
                    {
                        string  lb   = pt.y.ToString(_TextValueFormat);
                        TextObj text = new TextObj();
                        text.Text                     = lb;
                        text.Location.AlignH          = AlignH.Left;
                        text.Location.AlignV          = AlignV.Bottom;
                        text.Location.CoordinateFrame = CoordType.AxisXYScale;
                        //text.Location.X = (float)pt.x - 0.06;
                        //text.Location.Y = (float)pt.y + 0.1;

                        text.Location.X = trace.XType == Graph.XAxisType.Dates ? (float)((new XDate(pt.Date))) : (float)pt.x - 0.14;
                        text.Location.Y = (float)pt.y * 1.05;// -1.3;

                        text.ZOrder                    = ZOrder.A_InFront;
                        text.FontSpec.Size             = _TextValueFontSize;
                        text.FontSpec.Border.IsVisible = false;
                        text.FontSpec.Fill.IsVisible   = false;

                        myPane.GraphObjList.Add(text);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ShowGraph(DataTable _dt, string graphtitle)
        {
            ZedGraphControl zgc = new ZedGraphControl();

            zgc.IsEnableHZoom = false;
            zgc.IsEnableVZoom = false;

            GraphPane     myPane = zgc.GraphPane;
            List <string> xname  = new List <string>();

            myPane.Title.Text       = graphtitle;
            myPane.XAxis.Title.Text = "";
            myPane.YAxis.Title.Text = "";
            PointPairList list = new PointPairList();

            for (int i = 0; i < _dt.Rows.Count; i++)
            {
                list.Add(0.0, Convert.ToDouble(_dt.Rows[i][_dt.Columns.Count - 1].ToString()), _dt.Rows[i][_dt.Columns.Count - 4].ToString());
                // list.Add(0.0, Convert.ToDouble(_dt.Rows[i]["yValue"].ToString()), _dt.Rows[i]["xValue"].ToString());
                //  xname.Add(_dt.Rows[i]["xValue"].ToString());
                xname.Add(_dt.Rows[i][_dt.Columns.Count - 4].ToString());
            }
            BarItem myCurve = myPane.AddBar(null, list, Color.Blue);

            myPane.XAxis.Type             = AxisType.Text;
            myPane.XAxis.Scale.TextLabels = xname.ToArray();
            myPane.Chart.Fill             = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);
            BarItem.CreateBarLabels(myPane, false, "");
            zgc.AxisChange();
            zgc.Refresh();
            this.panelyr.Controls.Clear();
            this.panelyr.Controls.Add(zgc);
            zgc.Dock = DockStyle.Fill;
        }
Exemplo n.º 3
0
        private void CreateGraph(ZedGraphControl zgc)
        {
            try
            {
                Dictionary <string, int> map = new Dictionary <string, int>();
                GraphPane myPane             = zg1.GraphPane;

                myPane.Title.Text       = "Stats";
                myPane.XAxis.Title.Text = "Response Number";
                myPane.YAxis.Title.Text = "Kinds of Responses";

                // Create data points for three BarItems using Random data
                PointPairList list = new PointPairList();
                string[]      str;
                List <string> names = new List <string>();
                int           h     = dic.Count;
                for (int i = 0; i < h; i++)
                {
                    names.Add(dic.First().Key);
                    map.Add(dic.First().Key, dic.First().Value);
                    list.Add(dic.First().Value, i + 1, i / 4.0);
                    dic.Remove(dic.First().Key);
                }

                str = names.ToArray <string>();
                dic = map;
                BarItem bar1   = myPane.AddBar(this.field, list, Color.Blue);
                Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple };
                bar1.Bar.Fill      = new Fill(colors);
                bar1.Bar.Fill.Type = FillType.GradientByZ;

                bar1.Bar.Fill.RangeMin = 0;
                bar1.Bar.Fill.RangeMax = 2;


                // Set the YAxis labels
                myPane.YAxis.Scale.TextLabels = str;

                // Set the YAxis to Text type
                myPane.YAxis.Type = AxisType.Text;

                myPane.BarSettings.Base = BarBase.Y;
                // Make the bars stack instead of cluster
                myPane.BarSettings.Type = BarType.Stack;
                // Create TextObj's to provide labels for each bar
                BarItem.CreateBarLabels(myPane, true, "f0");

                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45);
                myPane.Fill       = new Fill(Color.White, Color.FromArgb(255, 255, 225), 45);



                // Calculate the Axis Scale Ranges
                zgc.AxisChange();
            }
            catch (Exception exp)
            { MessageBox.Show(exp.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
        public VerticalBarsWithLabelsDemo() : base("A bar graph that includes a text label above each bar",
                                                   "Vertical Bars with Labels Demo", DemoType.Bar)
        {
            GraphPane myPane = base.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text       = "Vertical Bars with Value Labels Above Each Bar";
            myPane.XAxis.Title.Text = "Position Number";
            myPane.YAxis.Title.Text = "Some Random Thing";

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

            // Generate random data for three curves
            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);
            }

            // create the curves
            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);

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

            base.ZedGraphControl.AxisChange();

            // expand the range of the Y axis slightly to accommodate the labels
            myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;

            // Create TextObj's to provide labels for each bar
            BarItem.CreateBarLabels(myPane, false, "f0");


            // Create a label for each bar
//			CreateBarLabels( myPane, false, "N0" );
        }
        public void CreatePpdGraph(ZedGraphControl zg, IList <string> projectInfoLines,
                                   IEnumerable <ProteinBenchmark> benchmarks,
                                   IList <Color> graphColors, int decimalPlaces,
                                   Protein protein, bool calculateBonus)
        {
            Debug.Assert(zg != null);

            try
            {
                // get a reference to the GraphPane
                GraphPane myPane = zg.GraphPane;

                // Clear the bars
                myPane.CurveList.Clear();
                // Clear the bar labels
                myPane.GraphObjList.Clear();
                // Clear the XAxis Project Information
                myPane.XAxis.Title.Text = String.Empty;

                // If no Project Information, get out
                if (projectInfoLines.Count == 0)
                {
                    return;
                }

                // Scale YAxis In Thousands?
                bool inThousands = false;

                // Create the bars for each benchmark
                int i = 0;
                foreach (ProteinBenchmark benchmark in benchmarks)
                {
                    double minimumFrameTimePPD = 0;
                    double averageFrameTimePPD = 0;
                    if (protein != null)
                    {
                        minimumFrameTimePPD = GetPPD(benchmark.MinimumFrameTime, protein, calculateBonus);
                        averageFrameTimePPD = GetPPD(benchmark.AverageFrameTime, protein, calculateBonus);
                    }

                    if (minimumFrameTimePPD >= 1000 || averageFrameTimePPD >= 1000)
                    {
                        inThousands = true;
                    }

                    var yPoints = new double[2];
                    yPoints[0] = Math.Round(minimumFrameTimePPD, decimalPlaces);
                    yPoints[1] = Math.Round(averageFrameTimePPD, decimalPlaces);

                    CreateBar(i, myPane, benchmark.OwningSlotName, yPoints, graphColors);
                    i++;
                }

                // Create the bar labels
                BarItem.CreateBarLabels(myPane, true, String.Empty, zg.Font.Name, zg.Font.Size, Color.Black, true, false, false);

                // Set the Titles
                myPane.Title.Text = "HFM.NET - Client Benchmarks";
                var sb = new StringBuilder();
                for (i = 0; i < projectInfoLines.Count - 2; i++)
                {
                    sb.Append(projectInfoLines[i]);
                    sb.Append("   ");
                }
                sb.Append(projectInfoLines[i]);
                myPane.XAxis.Title.Text = sb.ToString();
                myPane.YAxis.Title.Text = "PPD";

                // Draw the X tics between the labels instead of at the labels
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                // Set the XAxis labels
                var labels = new[] { "Min. Frame Time", "Avg. Frame Time" };
                myPane.XAxis.Scale.TextLabels = labels;
                // Set the XAxis to Text type
                myPane.XAxis.Type = AxisType.Text;

                // Don't show YAxis.Scale as 10^3
                myPane.YAxis.Scale.MagAuto = false;
                // Set the YAxis Steps
                if (inThousands)
                {
                    myPane.YAxis.Scale.MajorStep = 1000;
                    myPane.YAxis.Scale.MinorStep = 500;
                }
                else
                {
                    myPane.YAxis.Scale.MajorStep = 100;
                    myPane.YAxis.Scale.MinorStep = 10;
                }

                // Fill the Axis and Pane backgrounds
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
                myPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));
            }
            finally
            {
                // Tell ZedGraph to refigure the
                // axes since the data have changed
                zg.AxisChange();
                // Refresh the control
                zg.Refresh();
            }
        }
        public void CreateFrameTimeGraph(ZedGraphControl zg, IList <string> projectInfoLines,
                                         IEnumerable <ProteinBenchmark> benchmarks,
                                         IList <Color> graphColors)
        {
            Debug.Assert(zg != null);

            try
            {
                // get a reference to the GraphPane
                GraphPane myPane = zg.GraphPane;

                // Clear the bars
                myPane.CurveList.Clear();
                // Clear the bar labels
                myPane.GraphObjList.Clear();
                // Clear the XAxis Project Information
                myPane.XAxis.Title.Text = String.Empty;

                // If no Project Information, get out
                if (projectInfoLines.Count == 0)
                {
                    return;
                }

                // Create the bars for each benchmark
                int i = 0;
                foreach (ProteinBenchmark benchmark in benchmarks)
                {
                    var yPoints = new double[2];
                    yPoints[0] = benchmark.MinimumFrameTime.TotalSeconds;
                    yPoints[1] = benchmark.AverageFrameTime.TotalSeconds;

                    CreateBar(i, myPane, benchmark.OwningSlotName, yPoints, graphColors);
                    i++;
                }

                // Create the bar labels
                BarItem.CreateBarLabels(myPane, true, String.Empty, zg.Font.Name, zg.Font.Size, Color.Black, true, false, false);

                // Set the Titles
                myPane.Title.Text = "HFM.NET - Client Benchmarks";
                var sb = new StringBuilder();
                for (i = 0; i < projectInfoLines.Count - 2; i++)
                {
                    sb.Append(projectInfoLines[i]);
                    sb.Append("   ");
                }
                sb.Append(projectInfoLines[i]);
                myPane.XAxis.Title.Text = sb.ToString();
                myPane.YAxis.Title.Text = "Frame Time (Seconds)";

                // Draw the X tics between the labels instead of at the labels
                myPane.XAxis.MajorTic.IsBetweenLabels = true;
                // Set the XAxis labels
                var labels = new[] { "Min. Frame Time", "Avg. Frame Time" };
                myPane.XAxis.Scale.TextLabels = labels;
                // Set the XAxis to Text type
                myPane.XAxis.Type = AxisType.Text;

                // Fill the Axis and Pane backgrounds
                myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
                myPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));
            }
            finally
            {
                // Tell ZedGraph to refigure the
                // axes since the data have changed
                zg.AxisChange();
                // Refresh the control
                zg.Refresh();
            }
        }
Exemplo n.º 7
0
        private void DrawOverLayBar1(DataTable _dt, string _xName, string _yName)
        {
            //行数
            int iRowCount = _dt.Rows.Count;
            //列数 去除第一列 分区名称
            int iColCount = _dt.Columns.Count - 1;

            double[,] value = new double[iRowCount, iColCount];
            string[] labels        = new string[iRowCount];
            string[] sColorNameArr = { "Blue", "BlueViolet", "Brown", "BurlyWood", "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk", "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGray", "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange", "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue", "DarkSlateGray", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue", "DimGray", "DodgerBlue", "Firebrick", "FloralWhite", "ForestGreen", "Fuchsia", "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Gray", "Green", "GreenYellow", "Honeydew", "HotPink", "IndianRed", "Indigo", "LightGray", "LightGreen", "LightPink", "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGray", "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta", "Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple", "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise", "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin", "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed", "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed", "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple", "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown", "SeaGreen", "SeaShell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGray", "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato", "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen" };

            //分区名称
            for (int i = 0; i < iRowCount; i++)
            {
                labels[i] = _dt.Rows[i][0].ToString();
            }
            //数据区域
            for (int i = 0; i < iRowCount; i++)
            {
                for (int j = 0; j < iColCount; j++)
                {
                    value[i, j]        = Convert.ToDouble(_dt.Rows[i][j + 1].ToString()) / 10000000;
                    _dt.Rows[i][j + 1] = Convert.ToDouble(_dt.Rows[i][j + 1].ToString()) / 10000000;
                }
            }

            this.dgvData.DataSource = _dt;

            GraphPane myPane = zedGraphControl1.GraphPane;

            myPane.Title.Text       = _xName + "&" + _yName + "面积柱状图";
            myPane.YAxis.Title.Text = _yName + "(Km2)";
            myPane.XAxis.Title.Text = _xName;


            double[] list = null;
            list = new double[iRowCount];
            BarItem myBar = null;

            for (int i = 0; i < iColCount; i++)
            {
                for (int j = 0; j < iRowCount; j++)
                {
                    list[j] = value[j, i];
                }
                myBar          = myPane.AddBar(_dt.Columns[i + 1].ColumnName, null, list, Color.FromName(sColorNameArr[i]));
                myBar.Bar.Fill = new Fill(Color.FromName(sColorNameArr[i]));
            }

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

            myPane.AxisChange();

            myPane.IsFontsScaled = true;
            //myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;
            // expand the range of the Y axis slightly to accommodate the labels
            myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;

            // Create TextObj's to provide labels for each bar
            BarItem.CreateBarLabels(myPane, false, "f0");
        }
Exemplo n.º 8
0
        public void GenerateFrameTypeChart(
            TSPlaylistFile playlist,
            ushort PID,
            int angleIndex,
            bool isSizes)
        {
            IsHoverDisabled = true;

            GraphControl.GraphPane.XAxis.Title.Text = "Frame Type";

            if (isSizes)
            {
                UnitText = "KB";
                GraphControl.GraphPane.YAxis.Title.Text = "Average / Peak Size (KB)";
            }
            else
            {
                UnitText = "";
                GraphControl.GraphPane.YAxis.Title.Text = "Count";
            }

            Dictionary <string, double> frameCount = new Dictionary <string, double>();
            Dictionary <string, double> frameSizes = new Dictionary <string, double>();
            Dictionary <string, double> framePeaks = new Dictionary <string, double>();

            foreach (TSStreamClip clip in playlist.StreamClips)
            {
                if (clip.AngleIndex != angleIndex ||
                    clip.StreamFile == null ||
                    clip.StreamFile.StreamDiagnostics == null ||
                    !clip.StreamFile.StreamDiagnostics.ContainsKey(PID))
                {
                    continue;
                }

                List <TSStreamDiagnostics> diagList =
                    clip.StreamFile.StreamDiagnostics[PID];

                for (int i = 0; i < diagList.Count; i++)
                {
                    TSStreamDiagnostics diag = diagList[i];
                    if (diag.Tag == null)
                    {
                        continue;
                    }

                    string frameType = diag.Tag;
                    double frameSize = diag.Bytes / 1024;

                    if (!framePeaks.ContainsKey(frameType))
                    {
                        framePeaks[frameType] = frameSize;
                    }
                    else if (frameSize > framePeaks[frameType])
                    {
                        framePeaks[frameType] = frameSize;
                    }
                    if (!frameCount.ContainsKey(frameType))
                    {
                        frameCount[frameType] = 0;
                    }
                    frameCount[frameType]++;

                    if (!frameSizes.ContainsKey(frameType))
                    {
                        frameSizes[frameType] = 0;
                    }
                    frameSizes[frameType] += frameSize;
                }
            }

            string[] labels = new string[frameCount.Keys.Count];
            double[] values = new double[frameCount.Keys.Count];
            double[] peaks  = new double[frameCount.Keys.Count];
            Dictionary <string, int> frameTypes = new Dictionary <string, int>();

            frameCount.Keys.CopyTo(labels, 0);

            double totalFrameCount = 0;

            for (int i = 0; i < labels.Length; i++)
            {
                string label = labels[i];
                frameTypes[label] = i;
                if (isSizes)
                {
                    values[i] = frameSizes[label] / frameCount[label];
                    peaks[i]  = framePeaks[label];
                }
                else
                {
                    values[i] = frameCount[label];
                }
                totalFrameCount += frameCount[label];
            }

            if (isSizes)
            {
                BarItem barItem = GraphControl.GraphPane.AddBar(
                    "Average", null, values, Color.Black);
                barItem.Bar.Fill.Type = FillType.Solid;

                BarItem barItemMax = GraphControl.GraphPane.AddBar(
                    "Peak", null, peaks, Color.Black);
                barItemMax.Bar.Fill.Type = FillType.None;

                GraphControl.GraphPane.XAxis.MajorTic.IsBetweenLabels = true;
                GraphControl.GraphPane.XAxis.Scale.TextLabels         = labels;
                GraphControl.GraphPane.XAxis.Type = AxisType.Text;
                GraphControl.AxisChange();

                GraphControl.GraphPane.YAxis.Scale.Max +=
                    GraphControl.GraphPane.YAxis.Scale.MajorStep;

                BarItem.CreateBarLabels(GraphControl.GraphPane, false, "f0");
                GraphControl.GraphPane.Legend.IsVisible = true;
            }
            else
            {
                GraphControl.GraphPane.Chart.Fill.Type = FillType.None;
                GraphControl.GraphPane.XAxis.IsVisible = false;
                GraphControl.GraphPane.YAxis.IsVisible = false;

                int drgb = (int)Math.Truncate(255.0 / labels.Length);
                int rgb  = 0;

                List <SortableFrameCount> sortedFrameCounts = new List <SortableFrameCount>();
                foreach (string frameType in frameCount.Keys)
                {
                    sortedFrameCounts.Add(new SortableFrameCount(frameType, frameCount[frameType]));
                }
                sortedFrameCounts.Sort();

                int j = sortedFrameCounts.Count;
                for (int i = 0; i < j; i++)
                {
                    AddPieSlice(sortedFrameCounts[i].Name, sortedFrameCounts[i].Count, totalFrameCount, rgb);
                    rgb += drgb;
                    if (--j > i)
                    {
                        AddPieSlice(sortedFrameCounts[j].Name, sortedFrameCounts[j].Count, totalFrameCount, rgb);
                        rgb += drgb;
                    }
                }
                GraphControl.GraphPane.AxisChange();
            }

            GraphControl.IsShowHScrollBar  = false;
            GraphControl.IsAutoScrollRange = false;
            GraphControl.IsEnableHPan      = false;
            GraphControl.IsEnableHZoom     = false;
            GraphControl.IsEnableSelection = false;
            GraphControl.IsEnableWheelZoom = false;
        }
Exemplo n.º 9
0
    protected void ZedGraphWebExpStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
    {
        Color  statColor      = Color.Blue;
        string statTitle      = string.Empty;
        string statXAxisTitle = string.Empty;

        switch (ListBoxViewContent.SelectedValue)
        {
        case "NpcBeKilled":
            statColor      = Color.Orange;
            statTitle      = StringDef.NpcBeKilledStatistic;
            statXAxisTitle = StringDef.NpcBeKilledCount;
            break;

        case "NpcKill":
            statColor      = Color.Red;
            statTitle      = StringDef.NpcKillPlayerStatistic;
            statXAxisTitle = StringDef.NpcKillPlayerCount;
            break;
        }

        GraphPane graphPane = masterPane[0];

        graphPane.Fill                  = new Fill(WebConfig.GraphPaneBgColor);
        graphPane.Title.Text            = statTitle;
        graphPane.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.Title.FontSpec.Size   = 10;
        graphPane.Legend.IsVisible      = false;
        graphPane.BarSettings.Base      = BarBase.Y;

        graphPane.XAxis.Title.Text            = statXAxisTitle;
        graphPane.XAxis.Title.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.XAxis.Title.FontSpec.Size   = 6.2f;
        graphPane.XAxis.MajorGrid.IsVisible   = true;
        graphPane.XAxis.MajorGrid.DashOff     = 0;
        graphPane.XAxis.MajorGrid.Color       = Color.Gray;
        graphPane.XAxis.MinorGrid.IsVisible   = true;
        graphPane.XAxis.MinorGrid.Color       = Color.LightGray;
        graphPane.XAxis.MinorGrid.DashOff     = 0;
        graphPane.XAxis.Scale.FontSpec.Size   = 5.6f;
        graphPane.XAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;

        //graphPane.YAxis.Title.Text = StringDef.NpcTemplate;
        graphPane.YAxis.Title.FontSpec.Family       = StringDef.DefaultFontFamily;
        graphPane.YAxis.MajorTic.IsBetweenLabels    = true;
        graphPane.YAxis.Scale.IsPreventLabelOverlap = false;
        graphPane.YAxis.Scale.AlignH          = AlignH.Center;
        graphPane.YAxis.Scale.FontSpec.Size   = 5.6f;
        graphPane.YAxis.Scale.FontSpec.Family = StringDef.DefaultFontFamily;
        graphPane.YAxis.Scale.IsReverse       = true;
        graphPane.YAxis.Type = AxisType.Text;

        double[] countList    = new double[_recordList.Count];
        string[] templateList = new string[_recordList.Count];
        for (int i = 0; i < _recordList.Count; i++)
        {
            NpcStatisticInfo info = _recordList[i];
            countList[i] = info.Count;
            FS2NpcData npcData = FS2GameDataManager.TheInstance.GetNpcData(int.Parse(info.TemaplteId));
            if (npcData != null)
            {
                templateList[i] = npcData.ToString();
            }
            else
            {
                templateList[i] = info.TemaplteId;
            }
        }
        BarItem barItem = graphPane.AddBar(StringDef.NpcBeKilledCount, countList, null, Color.Blue);

        barItem.Bar.Fill = new Fill(statColor);
        graphPane.YAxis.Scale.TextLabels = templateList;
        masterPane.AxisChange();
        BarItem.CreateBarLabels(graphPane, false, string.Empty, StringDef.DefaultFontFamily, 5.6f, TextObj.Default.FontColor, false, false, false);
    }
Exemplo n.º 10
0
        public void PrepareArray(string title, string xAxis, string yAxis, ChartStyle style, bool excludeUnknowns, List <StatsItem> vals)
        {
            GraphPane gPane = fGraph.GraphPane;

            try
            {
                gPane.CurveList.Clear();

                gPane.Title.Text       = title;
                gPane.XAxis.Title.Text = xAxis;
                gPane.YAxis.Title.Text = yAxis;

                if (style != ChartStyle.ClusterBar)
                {
                    PointPairList ppList = new PointPairList();

                    int num = vals.Count;
                    for (int i = 0; i < num; i++)
                    {
                        StatsItem item = vals[i];

                        string s   = item.Caption;
                        double lab = (s == "?") ? 0.0f : SysUtils.ParseFloat(s, 0.0f, true);

                        if (lab != 0.0d || !excludeUnknowns)
                        {
                            ppList.Add(lab, item.Value);
                        }
                    }
                    ppList.Sort();

                    switch (style)
                    {
                    case ChartStyle.Bar:
                        gPane.AddBar("-", ppList, Color.Green);
                        break;

                    case ChartStyle.Point:
                        gPane.AddCurve("-", ppList, Color.Green, SymbolType.Diamond).Symbol.Size = 3;
                        break;
                    }
                }
                else
                {
                    gPane.CurveList.Clear();

                    int      itemscount = vals.Count;
                    double[] yValuesF   = new double[itemscount];
                    double[] yValuesM   = new double[itemscount];
                    double[] xValues    = new double[itemscount];

                    for (int i = 0; i < itemscount; i++)
                    {
                        StatsItem sti = vals[i];
                        xValues[i]  = SysUtils.ParseInt(sti.Caption, 0);
                        yValuesF[i] = sti.ValF;
                        yValuesM[i] = sti.ValM;
                    }

                    gPane.AddBar("F", xValues, yValuesF, Color.Red);
                    gPane.AddBar("M", xValues, yValuesM, Color.Blue);

                    gPane.BarSettings.MinBarGap     = 0.0f;
                    gPane.BarSettings.MinClusterGap = 2.5f;

                    // expand the range of the Y axis slightly to accommodate the labels
                    //gPane.YAxis.Scale.Max += gPane.YAxis.Scale.MajorStep;

                    // Create TextObj's to provide labels for each bar
                    BarItem.CreateBarLabels(gPane, false, "f0");
                }
            }
            finally
            {
                fGraph.AxisChange();
                fGraph.Invalidate();
            }
        }
Exemplo n.º 11
0
        public void UpdatePutCallRatioGraphCurves()
        {
            GraphPane pane = putCallRatioGraph.GraphPane;

            // delete old curves
            if (call_curve != null)
            {
                pane.CurveList.Remove(call_curve);
                call_curve = null;
            }
            if (put_curve != null)
            {
                pane.CurveList.Remove(put_curve);
                put_curve = null;
            }

            // update titles
            switch (mode)
            {
            case GraphMode.MODE_BY_EXPIRATION:
                pane.XAxis.Title.Text = "Date";
                pane.XAxis.Type       = AxisType.DateAsOrdinal;
                break;

            case GraphMode.MODE_BY_STRIKE:
                pane.XAxis.Title.Text = "Strike";
                pane.XAxis.Type       = AxisType.Linear;
                break;
            }

            // x-axis
            pane.XAxis.Scale.FormatAuto    = true;
            pane.XAxis.Scale.MinAuto       = true;
            pane.XAxis.Scale.MaxAuto       = true;
            pane.XAxis.Scale.MinorStepAuto = true;
            pane.XAxis.Scale.MajorStepAuto = true;

            // y-axis
            pane.YAxis.Scale.MinAuto       = true;
            pane.YAxis.Scale.MinorStepAuto = true;
            pane.YAxis.Scale.MaxAuto       = true;
            pane.YAxis.Scale.MajorStepAuto = true;


            ArrayList xscale_list = null;

            switch (mode)
            {
            case GraphMode.MODE_BY_EXPIRATION:
                xscale_list = core.GetExpirationDateList(DateTime.Now, DateTime.MaxValue);
                break;

            case GraphMode.MODE_BY_STRIKE:
                xscale_list = core.GetStrikeList(DateTime.MinValue);
                break;
            }
            if (xscale_list == null)
            {
                return;
            }

            string[] type_list = new string[2] {
                "Call", "Put"
            };

            foreach (string type in type_list)
            {
                ArrayList x = new ArrayList();
                ArrayList y = new ArrayList();

                foreach (object xscale in xscale_list)
                {
                    ArrayList option_list = null;

                    try
                    {
                        switch (mode)
                        {
                        case GraphMode.MODE_BY_EXPIRATION:
                            option_list = core.GetOptionList("(Type = '" + type + "') AND (Expiration = '" + Global.DefaultCultureToString((DateTime)xscale) + "')");
                            break;

                        case GraphMode.MODE_BY_STRIKE:
                            option_list = core.GetOptionList("(Type = '" + type + "') AND (Strike = " + Global.DefaultCultureToString((double)xscale) + ")");
                            break;
                        }
                    }
                    catch { option_list = null; }

                    if (option_list == null)
                    {
                        continue;
                    }

                    // open int
                    int open_int = 0;
                    foreach (Option option in option_list)
                    {
                        open_int += option.open_int;
                    }

                    switch (mode)
                    {
                    case GraphMode.MODE_BY_EXPIRATION:
                        // date
                        XDate x_expdate = new XDate((DateTime)xscale);
                        x.Add((double)x_expdate.XLDate);
                        break;

                    case GraphMode.MODE_BY_STRIKE:
                        x.Add((double)xscale);
                        break;
                    }
                    y.Add((double)open_int);
                }
                if (x.Count == 0)
                {
                    continue;
                }

                double[] putcallratio_x = (double[])x.ToArray(System.Type.GetType("System.Double"));
                double[] putcallratio_y = (double[])y.ToArray(System.Type.GetType("System.Double"));

                string name = type;

                if (type == "Call")
                {
                    call_curve = pane.AddBar(name, putcallratio_x, putcallratio_y, Config.Color.PositionBackColor(1));
                    call_curve.Bar.Fill.Type = FillType.Solid;
                }
                else
                {
                    put_curve = pane.AddBar(name, putcallratio_x, putcallratio_y, Config.Color.PositionBackColor(0));
                    put_curve.Bar.Fill.Type = FillType.Solid;
                }
            }

            putCallRatioGraph.AxisChange();
            putCallRatioGraph.Invalidate();

            // expand the range of the Y axis slightly to accommodate the labels
            pane.YAxis.Scale.Max += pane.YAxis.Scale.MajorStep;

            Color fg = Config.Color.GraphForeColor;

            if (invert_colors)
            {
                fg = Color.FromArgb(255 - fg.R, 255 - fg.G, 255 - fg.B);
            }

            // create TextObj's to provide labels for each bar
            DeleteBarLabels();
            BarItem.CreateBarLabels(pane, false, "f0", "Microsoft San Serif", 10F, fg, false, false, false);

            // update graph default axis
            putcallratio_xaxis_min = pane.XAxis.Scale.Min;
            putcallratio_xaxis_max = pane.XAxis.Scale.Max;
            putcallratio_xaxis_maj = pane.XAxis.Scale.MajorStep;
            putcallratio_xaxis_mor = pane.XAxis.Scale.MinorStep;
            putcallratio_yaxis_min = pane.YAxis.Scale.Min;
            putcallratio_yaxis_max = pane.YAxis.Scale.Max;
            putcallratio_yaxis_maj = pane.YAxis.Scale.MajorStep;
            putcallratio_yaxis_mor = pane.YAxis.Scale.MinorStep;
        }
Exemplo n.º 12
0
    //void CreateTableHead()
    //{
    //    if(TextBoxRoleName.Text!=null&&TextBoxRoleName.Text.Trim().Length!=0)
    //    {
    //        TableRow rowHead = new TableRow();

    //        TableHeaderCell cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.RoleName;
    //        rowHead.Cells.Add(cellHead);

    //        cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Date;
    //        rowHead.Cells.Add(cellHead);

    //        cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Count;
    //        rowHead.Cells.Add(cellHead);

    //        cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Percentage;
    //        rowHead.Cells.Add(cellHead);

    //        TableSearchTaiSuiList.Rows.Add(rowHead);
    //    }
    //    else
    //    {
    //        TableRow rowHead = new TableRow();

    //        TableHeaderCell cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Date;
    //        rowHead.Cells.Add(cellHead);

    //        cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Count;
    //        rowHead.Cells.Add(cellHead);

    //        cellHead = new TableHeaderCell();
    //        cellHead.Text = StringDef.Percentage;
    //        rowHead.Cells.Add(cellHead);

    //        TableSearchTaiSuiList.Rows.Add(rowHead);
    //    }
    //}

    //void CreateSearchResultList(TaiSuiUseInfo[] infos, int total)
    //{
    //    if (infos != null)
    //    {
    //        if (TextBoxRoleName.Text != null && TextBoxRoleName.Text.Trim().Length != 0)
    //        {
    //            foreach (TaiSuiUseInfo info in infos)
    //            {
    //                TableRow row = new TableRow();
    //                TableCell cell = new TableCell();
    //                cell.Text = TextBoxRoleName.Text.Trim();
    //                row.Cells.Add(cell);
    //                cell = new TableCell();
    //                cell.Text = info.date.ToShortDateString();
    //                row.Cells.Add(cell);
    //                cell = new TableCell();
    //                cell.Text = info.num.ToString();
    //                row.Cells.Add(cell);
    //                cell = new TableCell();
    //                cell.Text = total == 0 ? "0" : Decimal.Round((decimal)info.num / total, 2) * 100 + "%";
    //                row.Cells.Add(cell);
    //                TableSearchTaiSuiList.Rows.Add(row);
    //            }
    //        }
    //        else
    //        {
    //            foreach (TaiSuiUseInfo info in infos)
    //            {
    //                TableRow row = new TableRow();
    //                TableCell cell = new TableCell();
    //                cell.Text = info.date.ToShortDateString();
    //                row.Cells.Add(cell);
    //                cell = new TableCell();
    //                cell.Text = info.num.ToString();
    //                row.Cells.Add(cell);
    //                cell = new TableCell();
    //                cell.Text = total == 0 ? "0" : Decimal.Round((decimal)info.num / total, 2) * 100 + "%";
    //                row.Cells.Add(cell);
    //                TableSearchTaiSuiList.Rows.Add(row);
    //            }
    //        }
    //        TableRow rowTail = new TableRow();
    //        TableCell cellTail = new TableCell();
    //        cellTail.ColumnSpan = TextBoxRoleName.Text != null && TextBoxRoleName.Text.Trim().Length != 0 ? 4 : 3;
    //        cellTail.Font.Bold = true;
    //        cellTail.Text = StringDef.Total + StringDef.Colon + total;
    //        rowTail.Cells.Add(cellTail);

    //        TableSearchTaiSuiList.Rows.Add(rowTail);
    //    }
    //}

    protected void ZedGraphWebTaiSuiStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
    {
        if (_statInfo != null)
        {
            //整理数据
            double[] timeArray = null;
            double[] counts    = null;

            if (RadioButtonListType.SelectedValue.Equals("Day"))
            {
                //按天
                TimeSpan span = _end.Subtract(_start);
                timeArray = new double[span.Days + 1];
                counts    = new double[span.Days + 1];

                for (int index = 0; index != span.Days + 1; ++index)
                {
                    DateTime tempDate = _start.Date.AddDays(index);
                    timeArray[index] = new XDate(tempDate);
                    foreach (TaiSuiUseInfo info in _statInfo)
                    {
                        //如果相等赋num,如果比date的日期小则结束
                        if (tempDate.Date.Equals(info.date))
                        {
                            counts[index] = info.num;
                            break;
                        }
                        else if (tempDate.Date < info.date)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                //按月
                int monthLength = (_end.Year - _start.Year) * 12 + (_end.Month - _start.Month);
                timeArray = new double[monthLength + 1];
                counts    = new double[monthLength + 1];

                for (int index = 0; index != monthLength + 1; ++index)
                {
                    DateTime tempDate = _start.Date.AddMonths(index);
                    timeArray[index] = new XDate(tempDate);
                    foreach (TaiSuiUseInfo info in _statInfo)
                    {
                        //如果相等赋num,如果比date的日期小则结束
                        if (tempDate.ToString("yyyyMM").Equals(info.date.ToString("yyyyMM")))
                        {
                            counts[index] = info.num;
                            break;
                        }
                        else if (tempDate.Date < info.date)
                        {
                            break;
                        }
                    }
                }
            }

            GraphPane graphPane = masterPane[0];

            //绘制图表
            graphPane.Title.Text = string.Format("{0} {1} {2} {3}", _start.ToShortDateString(), StringDef.To, _end.ToShortDateString(),
                                                 StringDef.TaiSui + StringDef.Total + StringDef.Colon + _totalCount.ToString());
            graphPane.Title.IsVisible     = true;
            graphPane.Title.FontSpec.Size = 14;

            graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);
            graphPane.Legend.FontSpec.Fill.IsVisible = false;
            graphPane.Legend.FontSpec.Size           = 10.5f;
            graphPane.Legend.Fill.IsVisible          = false;
            graphPane.Legend.Border.IsVisible        = false;

            graphPane.YAxis.Title.Text            = StringDef.UseCount;
            graphPane.YAxis.Title.FontSpec.IsBold = false;
            graphPane.YAxis.Title.FontSpec.Size   = 10.5f;
            graphPane.YAxis.Scale.FontSpec.Size   = 10.5f;
            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;

            graphPane.XAxis.Title.Text            = StringDef.Date;
            graphPane.XAxis.Title.FontSpec.IsBold = false;
            graphPane.XAxis.Title.FontSpec.Size   = 10.5f;
            graphPane.XAxis.Scale.MajorUnit       = DateUnit.Day;
            graphPane.XAxis.MinorGrid.IsVisible   = false;
            graphPane.XAxis.Type = AxisType.DateAsOrdinal;
            if (RadioButtonListType.SelectedValue.Equals("Day"))
            {
                graphPane.XAxis.Scale.Format = "MM-dd";
            }
            else
            {
                graphPane.XAxis.Scale.Format = "yyyy-MM";
            }
            graphPane.XAxis.Scale.FontSpec.Size = 10.5f;
            //graphPane.XAxis.Scale.FontSpec.Angle = 45;

            graphPane.BarSettings.Type = BarType.Cluster;

            BarItem barItem = graphPane.AddBar(StringDef.UseCount, timeArray, counts, Color.Blue);
            masterPane.AxisChange(g);
            BarItem.CreateBarLabels(graphPane, false, string.Empty, TextObj.Default.FontFamily, 10.5f,
                                    TextObj.Default.FontColor, false, false, false);
        }
    }
Exemplo n.º 13
0
    protected void ZedGraphWebLevelSuiStatistic_RenderGraph(ZedGraph.Web.ZedGraphWeb webObject, Graphics g, MasterPane masterPane)
    {
        if (_infoHashtable != null)
        {
            //整理数据
            int      startLevel = int.Parse(TextBoxStartLevel.Text.Trim());
            int      endLevel   = int.Parse(TextBoxEndLevel.Text.Trim());
            int      groupCount = int.Parse(TextBoxGroup.Text.Trim());
            string[] levels     = new string[(endLevel - startLevel) / groupCount + 1];
            double[] counts;
            Color[]  roleTypeColor = new Color[] {
                Color.Blue,
                Color.Brown,
                Color.DarkGoldenrod,
                Color.Beige,
                Color.Yellow,
                Color.Coral,
                Color.Pink,
                Color.Green,
                Color.Gray
            };

            for (int index = 0; index != levels.Length; ++index)
            {
                levels[index] = string.Concat(startLevel + index * groupCount, '-', startLevel + (index + 1) * groupCount - 1);
            }

            GraphPane graphPane = masterPane[0];

            //绘制图表
            graphPane.Title.Text = string.Format("{0}-{1} {2} {3}", startLevel, endLevel,
                                                 StringDef.Role + StringDef.Total + StringDef.Colon, _total.ToString());
            graphPane.Title.IsVisible     = true;
            graphPane.Title.FontSpec.Size = 14;

            graphPane.Fill = new Fill(WebConfig.GraphPaneBgColor);
            graphPane.Legend.FontSpec.Fill.IsVisible = false;
            graphPane.Legend.FontSpec.Size           = 10.5f;
            graphPane.Legend.Fill.IsVisible          = false;
            graphPane.Legend.Border.IsVisible        = false;

            graphPane.YAxis.Title.Text            = StringDef.Count;
            graphPane.YAxis.Title.FontSpec.IsBold = false;
            graphPane.YAxis.Title.FontSpec.Size   = 10.5f;
            graphPane.YAxis.Scale.FontSpec.Size   = 10.5f;
            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;

            graphPane.XAxis.Title.Text            = StringDef.Level;
            graphPane.XAxis.Title.FontSpec.IsBold = false;
            graphPane.XAxis.Title.FontSpec.Size   = 10.5f;
            graphPane.XAxis.Scale.IsVisible       = true;
            graphPane.XAxis.Type                = AxisType.Text;
            graphPane.XAxis.Scale.TextLabels    = levels;
            graphPane.XAxis.Scale.FontSpec.Size = 10.5f;

            switch (DropDownListBarType.SelectedItem.Text)
            {
            case "Stack":
                graphPane.BarSettings.Type = BarType.Stack;
                break;

            case "PercentStack":
                graphPane.BarSettings.Type = BarType.PercentStack;
                break;

            case "Cluster":
                graphPane.BarSettings.Type = BarType.Cluster;
                break;

            case "ClusterHiLow":
                graphPane.BarSettings.Type = BarType.ClusterHiLow;
                break;

            case "Overlay":
                graphPane.BarSettings.Type = BarType.Overlay;
                break;

            case "SortedOverlay":
                graphPane.BarSettings.Type = BarType.SortedOverlay;
                break;
            }

            for (int roleType = 0; roleType != 10; ++roleType)
            {
                ArrayList infoList = _infoHashtable[(FS2RoleType)roleType] as ArrayList;
                if (infoList != null)
                {
                    counts = new double[(endLevel - startLevel) / groupCount + 1];
                    for (int index = 0; index != levels.Length; ++index)
                    {
                        foreach (LevelInfo info in (LevelInfo[])infoList.ToArray(typeof(LevelInfo)))
                        {
                            if (info.Level >= startLevel + index * groupCount && info.Level < startLevel + (index + 1) * groupCount)
                            {
                                counts[index] += info.Num;
                            }
                            else if (info.Level >= startLevel + (index + 1) * groupCount)
                            {
                                break;
                            }
                        }
                    }
                    string classDescription = string.Empty;
                    switch ((FS2RoleType)roleType)
                    {
                    case FS2RoleType.Jiashi:
                        classDescription = StringDef.Jiashi;
                        break;

                    case FS2RoleType.Xuanfeng:
                        classDescription = StringDef.XuanFeng;
                        break;

                    case FS2RoleType.Xingtian:
                        classDescription = StringDef.XingTian;
                        break;

                    case FS2RoleType.Daoshi:
                        classDescription = StringDef.Daoshi;
                        break;

                    case FS2RoleType.Zhenren:
                        classDescription = StringDef.ZhenRen;
                        break;

                    case FS2RoleType.Tianshi:
                        classDescription = StringDef.TianShi;
                        break;

                    case FS2RoleType.Yiren:
                        classDescription = StringDef.Yiren;
                        break;

                    case FS2RoleType.Shoushi:
                        classDescription = StringDef.ShouShi;
                        break;

                    case FS2RoleType.Yishi:
                        classDescription = StringDef.YiShi;
                        break;
                    }
                    BarItem bar = graphPane.AddBar(classDescription, null, counts, roleTypeColor[(int)roleType]);
                    bar.Bar.Fill = new Fill(roleTypeColor[(int)roleType]);
                }
            }

            masterPane.AxisChange(g);
            BarItem.CreateBarLabels(graphPane, true, string.Empty, TextObj.Default.FontFamily, 10.5f,
                                    TextObj.Default.FontColor, false, false, false);
        }
    }