当前位置: 首页>>代码示例>>C#>>正文


C# Chart.SaveImage方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataVisualization.Charting.Chart.SaveImage方法的典型用法代码示例。如果您正苦于以下问题:C# Chart.SaveImage方法的具体用法?C# Chart.SaveImage怎么用?C# Chart.SaveImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataVisualization.Charting.Chart的用法示例。


在下文中一共展示了Chart.SaveImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateChart

        private void GenerateChart(SeriesCreator creator, string filePath)
        {
            IEnumerable<Series> serieses = creator.ToSerieses();

            using (var ch = new Chart())
            {
                ch.Size = new Size(1300, 800);
                ch.AntiAliasing = AntiAliasingStyles.All;
                ch.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
                ch.Palette = ChartColorPalette.BrightPastel;

                ChartArea area = new ChartArea();
                area.AxisX.MajorGrid.Enabled = false;
                area.AxisY.MajorGrid.Enabled = false;
                area.AxisY.Minimum = creator.GetMinimumY();
                ch.ChartAreas.Add(area);

                Legend legend = new Legend();
                legend.Font = new Font("Microsoft Sans Serif", 12, FontStyle.Regular);
                ch.Legends.Add(legend);

                foreach (var s in serieses)
                {
                    ch.Series.Add(s);
                }

                string savePath = filePath + ".png";
                ch.SaveImage(savePath, ChartImageFormat.Png);
            }
        }
开发者ID:riyadparvez,项目名称:csv-to-chart,代码行数:30,代码来源:ChartCreator.cs

示例2: RenderChart

        private void RenderChart(Chart chart, string chartName)
        {
            chart.Invalidate();

            var path = Path.Combine(_directory, chartName.Replace(":", "-"));
            path = Path.ChangeExtension(path, "png");
            chart.SaveImage(path, ChartImageFormat.Png);
        }
开发者ID:timbarrass,项目名称:Alembic.Metrics,代码行数:8,代码来源:MultiPlotter.cs

示例3: CreatePlotAndSave

        private static void CreatePlotAndSave(TestItem testItem)
        {
            // Create a Chart
            var chart = new Chart();

            // Chart title
            var chartTitle = new Title(testItem.Label);
            chart.Titles.Add(chartTitle);

            // Create Chart Area
            ChartArea chartArea = new ChartArea();
            chartArea.AxisX.Title = "Milestone title";
            chartArea.AxisY.Title = "ms";
            chartArea.AxisX.IsMarginVisible = false;

            for (int i = 0; i < testItem.MilestoneLabels.Length;i++)
            {
                chartArea.AxisX.CustomLabels.Add(i + 0.5, i + 1.5, testItem.MilestoneLabels[i]);
            }

            // Legend
            Legend legend = new Legend("default");
            legend.Docking = Docking.Bottom;
            chart.Legends.Add(legend);

            // Add Chart Area to the Chart
            chart.ChartAreas.Add(chartArea);

            foreach (var line in testItem.Lines)
            {
                Series series = new Series();
                series.Legend = "default";
                series.LegendText = line.Label;
                series.ChartType = SeriesChartType.Line;
                series.MarkerStyle = MarkerStyle.Circle;
                series.BorderWidth = 2;
                series.MarkerSize = 5;
                for (int i = 0; i < line.Points.Length; i++)
                {
                    series.Points.Add(line.Points[i].GetMinTime());
                }
                chart.Series.Add(series);
            }

            // Set chart control location
            chart.Location = new System.Drawing.Point(16, 48);

            // Set Chart control size
            chart.Size = new System.Drawing.Size(400, 300);
            var fileName = GenerateFileName(testItem);
            var file = new FileStream(fileName, FileMode.Create);
            chart.SaveImage(file, ChartImageFormat.Png);
            file.Close();

            Console.WriteLine(String.Format("Report: \"{0}\" created.", fileName));
        }
开发者ID:Coderik,项目名称:NGauge,代码行数:56,代码来源:Program.cs

示例4: Show_MSChart

        public Bitmap Show_MSChart()
        {
            try
            {
                if (!Check_Chart())
                    return null;

                ChartArea chartArea = new ChartArea("chartArea");
                Grid grid = new Grid();
                grid.LineDashStyle = ChartDashStyle.Solid;
                grid.LineColor = Color.Black;

                Legend lengend = new Legend();
                lengend.Docking = Docking.Right;

                chartArea.AxisX.MajorGrid = grid;
                chartArea.AxisY.MajorGrid = grid;
                chartArea.AxisX.Interval = 1;
                chartArea.AxisX.IsLabelAutoFit = false;
                chartArea.BackColor = Color.FromArgb(0xEF, 0xEF, 0xEF);

                Series series = new Series("危险度");
                series.ChartType = SeriesChartType.Column;
                //series.IsValueShownAsLabel = true;
                series.Color = dataColor;
                series.BorderWidth = 0;

                SmartLabelStyle smartLabelStyle = new SmartLabelStyle();
                smartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes;
                series.SmartLabelStyle = smartLabelStyle;

                series.Points.DataBindXY(dataTable.DefaultView, dataX, dataTable.DefaultView, dataY);
                Chart chart = new Chart();
                chart.Width = width;
                chart.Height = height;
                chart.ChartAreas.Add(chartArea);
                chart.Series.Add(series);
                chart.Legends.Add(lengend);

                MemoryStream memoryStream = new MemoryStream();
                chart.SaveImage(memoryStream, ChartImageFormat.Jpeg);

                Bitmap bitmap = new Bitmap(memoryStream);
                return bitmap;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
开发者ID:hihua,项目名称:hihuacode,代码行数:50,代码来源:Class_Chart.cs

示例5: SaveImage

 /// <summary>
 /// 
 /// </summary>
 /// <param name="chart"></param>
 public static void SaveImage(Chart chart)
 {
     try
     {
         using (var ms = new MemoryStream())
         {
             chart.SaveImage(ms, ChartImageFormat.Bmp);
             var bm = new Bitmap(ms);
             bm.Save(chart.Name + ".png");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(@"Image save error: " + ex.Message);
     }
 }
开发者ID:FinalFrontierPrototyping,项目名称:AxialFluxGeneratorDesigner,代码行数:20,代码来源:Chart.cs

示例6: CreateGraph

        //Creating a fun little graph
        public static void CreateGraph(YearMap yearMap)
        {
            //Order the list of keys to get all of the years and find out how many years there were that someone lived in
            var orderedList = yearMap.YearVals.Keys.OrderBy(x => x).ToArray();
            var numberOfYears = orderedList.Count();

            var xvals = new int[numberOfYears];
            var yvals = new int[numberOfYears];
            for (int i = 0; i < yvals.Length; i++)
            {
                yvals[i] = yearMap.YearVals[orderedList[i]];
                xvals[i] = orderedList[i];
            }

            var chart = new Chart();
            chart.Size = new Size(1000, 1000);
            Title title = new Title("Number of people alive each year");
            title.Font = new Font("Calibri", 16, System.Drawing.FontStyle.Bold);
            chart.Titles.Add(title);

            var chartArea = new ChartArea();
            chartArea.AxisX.LabelStyle.Font = new Font("Calibri", 8);
            chartArea.AxisY.LabelStyle.Font = new Font("Calibri", 8);
            chartArea.AxisY.Minimum = 0;
            chartArea.AxisX.Minimum = 1900;
            chartArea.AxisX.Maximum = 2000;
            chartArea.AxisX.Title = "Years";
            chartArea.AxisX.TitleFont = new Font("Calibri", 14, System.Drawing.FontStyle.Bold);
            chartArea.AxisY.Title = "Number of People Alive";
            chartArea.AxisY.TitleFont = new Font("Calibri", 14, System.Drawing.FontStyle.Bold);
            chartArea.AxisY.Interval = 1;
            chartArea.AxisX.Interval = 5;

            chart.ChartAreas.Add(chartArea);

            var series = new Series();
            series.Name = "Series";
            series.ChartType = SeriesChartType.Bar;
            chart.Series.Add(series);

            chart.Series["Series"].Points.DataBindXY(xvals, yvals);

            chart.Invalidate();

            chart.SaveImage("../../Output/chart.png", ChartImageFormat.Png);
        }
开发者ID:johnjalex,项目名称:YearCalc,代码行数:47,代码来源:Program.cs

示例7: GenerateChart

        public static void GenerateChart(ChartParamterers parameters, string resultPath)
        {
            var csvPath = string.Format("{0}.csv", resultPath);

            var records = ReadDataFromFile(csvPath);

            var myChart = new Chart
            {
                Size = ChartSize
            };

            var myChartArea = new ChartArea();
            myChart.ChartAreas.Add(myChartArea);

            var series = new Series("default")
                             {
                                 ChartType = parameters.ChartType
                             };

            foreach (var thing in records)
            {
                series.Points.AddXY(thing.X.Length > 25 ? thing.X.Substring(0, 25) : thing.X, thing.Y);
            }

            myChart.Series.Add(series);

            if (parameters.AllValuesInXInterval)
            {
                myChart.ChartAreas[0].AxisX.Interval = 1;
            }

            var font = new Font("Arial", 12, FontStyle.Bold);
            var title = new Title
            {
                Text = resultPath,
                Font = font
            };

            myChart.Titles.Add(title);

            var pngPath = string.Format("{0}.png", resultPath);
            myChart.SaveImage(pngPath, ChartImageFormat.Png);
        }
开发者ID:dziedrius,项目名称:EILA,代码行数:43,代码来源:ChartGenerator.cs

示例8: CreateChart

        private void CreateChart(string filename, IEnumerable<Tuple<string, double>> values)
        {
            Chart singletonChart = new Chart()
            {
                Size = new Size(800, 600),
                Palette = ChartColorPalette.Pastel,
            };

            singletonChart.ChartAreas.Add("Series1");

            singletonChart.Series.Add("Series1");
            singletonChart.Series["Series1"].ChartType = SeriesChartType.Bar;
            singletonChart.ChartAreas[0].AxisX.Interval = 1;

            foreach (var value in values)
            {
                singletonChart.Series["Series1"].Points.AddXY(value.Item1, value.Item2);
            }

            singletonChart.SaveImage(filename, ChartImageFormat.Png);
        }
开发者ID:stevehebert,项目名称:IocPerformance,代码行数:21,代码来源:ChartOutput.cs

示例9: GeneratePlot

        public string GeneratePlot(double[] items, string title)
        {
            string file = "";
            chart = new Chart();

            chart.ChartAreas.Add(new ChartArea());
            int i = 1;
            foreach (var item in items)
            {
                SetChart(title, i, item);
                i++;
            }

            DateTime d = DateTime.Now;
            var xxx = String.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}", d.Year, d.Month, d.Day, d.Hour, d.Minute, d.Second, d.Millisecond);
            String chartFilename = Common.Folder.Data + "\\" + xxx + ".bmp";
            chart.Update();
            chart.SaveImage(chartFilename, System.Drawing.Imaging.ImageFormat.Bmp);
            file = chartFilename;

            return file;
        }
开发者ID:DrZeil,项目名称:nbn-csharp,代码行数:22,代码来源:ResearchNBN.cs

示例10: generaGrafica

        public System.Drawing.Image generaGrafica(IList<DataPoint> series, string Pr1)
        {
            using (MemoryStream graph = new MemoryStream())
            using (var ch = new Chart())
            {
                ch.ChartAreas.Add(new ChartArea());

                var s = new Series();
                foreach (var pnt in series) s.Points.Add(pnt);
                s.XValueType = ChartValueType.DateTime;
                ch.Series.Add(s);
                s.ChartType = SeriesChartType.FastLine;
                s.Color = Color.Red;
                s.Name = Pr1;

                ch.Size = new Size(600, 400);
                ch.SaveImage(graph, ChartImageFormat.Jpeg);
                ch.Legends.Add("leyenda");

                MemoryStream ms = new MemoryStream(graph.GetBuffer());
                var image = System.Drawing.Image.FromStream(ms);
                return image;
            }
        }
开发者ID:ProyInge,项目名称:ProyectoInge,代码行数:24,代码来源:Reportes.aspx.cs

示例11: SaveChart

        private static void SaveChart(List<double> requestTimes, TimeSpan totalTime, double minTime, double maxTime, double avgTime)
        {
            DataSet dataSet = new DataSet();
            DataTable dt = new DataTable();
            dt.Columns.Add("Seconds", typeof(int));
            dt.Columns.Add("RequestCount", typeof(int));

            Dictionary<int, int> timeTable = new Dictionary<int, int>();

            List<DataRow> rows = new List<DataRow>();
            List<int> intTimes = requestTimes.OrderBy(t => t).Select(t => (int)Math.Round(t/1000)).ToList();

            foreach (int time in intTimes)
            {
                DataRow row = rows.FirstOrDefault(r => ((int)r[0]) == time);

                if (row == null)
                {
                    row = dt.NewRow();
                    row[0] = time;
                    row[1] = 0;
                    rows.Add(row);
                }

                row[1] = ((int)row[1]) + 1;
            }

            rows.ForEach(r => dt.Rows.Add(r));

            dataSet.Tables.Add(dt);

            Chart chart = new Chart();
            chart.DataSource = dataSet.Tables[0];
            chart.Width = 900;
            chart.Height = 500;

            Series series = new Series();
            series.Name = "Serie1";
            series.Color = Color.FromArgb(220, 0, 27);
            series.ChartType = SeriesChartType.Column;
            series.ShadowOffset = 0;
            series.IsValueShownAsLabel = true;
            series.XValueMember = "Seconds";
            series.YValueMembers = "RequestCount";
            series.Font = new Font(series.Font.FontFamily, 10);
            chart.Series.Add(series);

            ChartArea ca = new ChartArea();
            ca.Name = "ChartArea1";
            ca.BackColor = Color.White;
            ca.BorderWidth = 0;
            ca.AxisX = new Axis();
            ca.AxisY = new Axis();
            ca.AxisX.Title = "Time (seconds)";
            Font f = ca.AxisX.TitleFont;
            ca.AxisX.TitleFont = new Font(f.FontFamily, 12, f.Style);
            ca.AxisY.Title = "Request count";
            ca.AxisY.TitleFont = ca.AxisX.TitleFont;
            ca.AxisX.MajorGrid.LineColor = Color.LightGray;
            ca.AxisY.MajorGrid.LineColor = ca.AxisX.MajorGrid.LineColor;
            chart.ChartAreas.Add(ca);

            chart.Titles.Add("Requests times");
            chart.Titles[0].Font = ca.AxisX.TitleFont;
            chart.Titles.Add(GetChartDescriptionString(totalTime, minTime, maxTime, avgTime));
            chart.Titles[1].Font = new Font(chart.Titles[1].Font.FontFamily, 10);

            chart.DataBind();

            int i = 0;
            string fileName = "";

            //loop until you find a free file name (in case multiple instances are running at the same time)
            do
            {
                fileName = string.Format("chart-{0}.png", i++);
            }
            while(File.Exists(fileName));

            chart.SaveImage(fileName, ChartImageFormat.Png);
        }
开发者ID:dland512,项目名称:loadrunnerx,代码行数:81,代码来源:Program.cs

示例12: TeamWinChart


//.........这里部分代码省略.........
            }

            dataSet.Tables.Add(dt);

            //now build the chart
            Chart chart = new Chart();
            //chart.DataSource = dataSet.Tables[0];
            chart.Width = 1000;
            chart.Height = 400;
            var legend = new Legend();
            //create serie...
            foreach (var team in new[] { "Wolf", "Village", "Tanner", "Cult", "SerialKiller", "Lovers" })
            {
                Series serie1 = new Series();
                //serie1.Label = team;
                serie1.LegendText = team;
                serie1.Name = team;
                switch (team)
                {
                    case "Wolf":
                        serie1.Color = Color.SaddleBrown;
                        break;
                    case "Village":
                        serie1.Color = Color.Green;
                        break;
                    case "Tanner":
                        serie1.Color = Color.Red;
                        break;
                    case "Cult":
                        serie1.Color = Color.Blue;
                        break;
                    case "SerialKiller":
                        serie1.Color = Color.Black;
                        break;
                    case "Lovers":
                        serie1.Color = Color.Pink;
                        break;
                }
                serie1.MarkerBorderWidth = 2;
                serie1.BorderColor = Color.FromArgb(164, 164, 164);
                serie1.ChartType = SeriesChartType.StackedBar100;
                serie1.BorderDashStyle = ChartDashStyle.Solid;
                serie1.BorderWidth = 1;
                //serie1.ShadowColor = Color.FromArgb(128, 128, 128);
                //serie1.ShadowOffset = 1;
                serie1.IsValueShownAsLabel = false;
                serie1.XValueMember = "Players";
                serie1.YValueMembers = "Wins";
                serie1.Font = new Font("Tahoma", 8.0f);
                serie1.BackSecondaryColor = Color.FromArgb(0, 102, 153);
                serie1.LabelForeColor = Color.FromArgb(100, 100, 100);
                //add our values
                var pl = 4;
                foreach (var r in result.Where(x => x.Team == team).OrderBy(x => x.Players))
                {
                    pl++;
                    if (r.Players != pl)
                    {
                        while (pl < r.Players)
                        {
                            serie1.Points.AddXY(pl, 0);
                            pl++;
                        }
                    }
                    serie1.Points.AddXY(r.Players, r.Wins);
                }
                //make sure we filled all the points...
                var top = (int)(serie1.Points.OrderByDescending(x => x.XValue).FirstOrDefault()?.XValue ?? 4);

                if (top < 35)
                {
                    top++;
                    while (top <= 35)
                    {
                        serie1.Points.AddXY(top, 0);
                        top++;
                    }
                }
                //legend.CustomItems.Add(serie1.Color, team);
                chart.Series.Add(serie1);
            }
            //create chartareas...
            ChartArea ca = new ChartArea();
            ca.Name = "ChartArea1";
            ca.BackColor = Color.White;
            ca.BorderColor = Color.FromArgb(26, 59, 105);
            ca.BorderWidth = 0;
            ca.BorderDashStyle = ChartDashStyle.Solid;
            ca.AxisX = new Axis();
            ca.AxisY = new Axis();
            chart.ChartAreas.Add(ca);
            chart.Legends.Add(legend);
            //databind...
            //chart.DataBind();
            //save result

            var path = Path.Combine(Bot.RootDirectory, "myChart.png");
            chart.SaveImage(path, ChartImageFormat.Png);
            SendImage(path, u.Message.Chat.Id);
        }
开发者ID:CloneMMDDCVII,项目名称:Werewolf,代码行数:101,代码来源:Charting.cs

示例13: DumpColRowsPlot


//.........这里部分代码省略.........
                    tg.NColumns, tg.NRows, tg.ThumbWidth, tg.ThumbHeight,
                    wastedWidth, wastedHeight,
                    extraWidth, extraHeight,
                    newContainer.Width, newContainer.Height,
                    extraWidthPercent, extraHeightPercent,
                    newContainer.AspectRatio
                    ));

                int index;

                if (plotThresholds)
                    {
                    index = seriesWW.Points.AddXY (aspectRatio, wastedWidth * 100.0);
                    if (wastedWidth == 0.0)
                        seriesWW.Points[index].IsEmpty = true;

                    index = seriesWH.Points.AddXY (aspectRatio, wastedHeight * 100.0);
                    if (wastedHeight == 0.0)
                        seriesWH.Points[index].IsEmpty = true;
                    }

                seriesNCols.Points.AddXY (aspectRatio, tg.NColumns);
                seriesNRows.Points.AddXY (aspectRatio, tg.NRows);
                }
            chartArea.RecalculateAxesScale ();

            AddARAnnotation (chart, "Fullscreen 4:3\n(1.33)", 1.33, annotationFont, plotThresholds);
            AddARAnnotation (chart, "HD 16:9\n(1.78)", 1.78, annotationFont, plotThresholds);
            AddARAnnotation (chart, "Widescreen\n(1.85)", 1.85, annotationFont, plotThresholds);
            AddARAnnotation (chart, "CinemaScope\n(2.35)", 2.35, annotationFont, plotThresholds);
            AddARAnnotation (chart, "Ultra-Panavision\n(2.76)", 2.76, annotationFont, plotThresholds);

            AddARAnnotation (chart,
                    String.Format ("Layout Threshold\n({0:F2})",
                                crossoverThreshold),
                    crossoverThreshold,
                    _tnSettings.LayoutMode == ThumbnailSettings.LayoutModes.Auto ?
                        annotationFont : annotationItFont,
                    plotThresholds,
                    true);

            if (_tnSettings.RCOptimization && plotThresholds)
                {
                switch (_tnSettings.LayoutMode)
                    {
                    case ThumbnailSettings.LayoutModes.Auto:

                        if (_tnSettings.WidthThreshold == _tnSettings.HeightThreshold)
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Width & Height Threshold\n" +
                                                                 "({0:F2})", _tnSettings.WidthThreshold),
                                                   _tnSettings.WidthThreshold,
                                                   annotationFont);
                        else
                            {
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Width Threshold\n" +
                                                                 "({0:F2})", _tnSettings.WidthThreshold),
                                                   _tnSettings.WidthThreshold,
                                                   annotationFont);
                            AddThresholdAnnotation (chart,
                                                   String.Format ("Height Threshold\n" +
                                                                 "({0:F2})", _tnSettings.HeightThreshold),
                                                   _tnSettings.HeightThreshold,
                                                   annotationFont);
                            }
                        break;

                    case ThumbnailSettings.LayoutModes.RowPriority:
                        AddThresholdAnnotation (chart,
                                               String.Format ("Width Threshold\n" +
                                                             "({0:F2})", _tnSettings.WidthThreshold),
                                               _tnSettings.WidthThreshold,
                                               annotationFont);
                        break;

                    case ThumbnailSettings.LayoutModes.ColumnPriority:
                        AddThresholdAnnotation (chart,
                                               String.Format ("Height Threshold\n" +
                                                             "({0:F2})", _tnSettings.HeightThreshold),
                                               _tnSettings.HeightThreshold,
                                               annotationFont);
                        break;
                    }
                }

            chart.SaveImage (filename, Charting.ChartImageFormat.Png);
            THelper.Information ("'{0}' created.", filename);

            labelStyle1.Dispose ();
            labelStyle2.Dispose ();
            labelStyle3.Dispose ();

            titleFont.Dispose ();
            subTitleFont.Dispose ();
            axisFont.Dispose ();
            annotationFont.Dispose ();
            annotationItFont.Dispose ();
            chart.Dispose ();
        }
开发者ID:rm2,项目名称:CLAutoThumbnailer,代码行数:101,代码来源:CLAutoThumbnailer.cs

示例14: generateImage

        /// <summary>
        /// Expecting a list of series names, which are the type and name, split with an ">", or can be a list of regex's
        /// </summary>
        /// <param name="series"></param>
        public Stream generateImage(List<string> series)
        {
            DateTime graphStartTime = DateTime.Now;

            //set up a windows form graph thing
            try
            {
                using (var ch = new Chart())
                {
                    ch.Width = 1200;
                    ch.Height = 600;
                    ch.TextAntiAliasingQuality = TextAntiAliasingQuality.High;

                    Title t = new Title(Roboto.Settings.botUserName + " Statistics", Docking.Top, new System.Drawing.Font("Roboto", 14), Color.Black);
                    ch.Titles.Add(t);

                    ChartArea cha = new ChartArea("cha");
                    cha.BackColor = Color.FromArgb(200,225,255);

                    cha.AxisX.Title = "Hours Ago";
                    //cha.AxisX.TitleFont = new System.Drawing.Font("Calibri", 11, System.Drawing.FontStyle.Bold);
                    cha.AxisX.TitleFont = new System.Drawing.Font("Roboto", 11);
                    cha.AxisX.MajorGrid.Interval = 6;
                    cha.AxisY.Title = "Value / " + granularity.TotalMinutes.ToString() + " mins"  ;
                    cha.AxisY.TitleFont = new System.Drawing.Font("Roboto", 11);
                    //cha.AxisY.TitleFont = new System.Drawing.Font("Calibri", 11, System.Drawing.FontStyle.Bold);

                    Legend l = new Legend("Legend");
                    l.DockedToChartArea = "cha";
                    l.IsDockedInsideChartArea = true;
                    l.Docking = Docking.Right;

                    ch.ChartAreas.Add(cha);
                    ch.Legends.Add(l);

                   //if nothing passed in, assume all stats
                    if (series.Count == 0) { series.Add(".*"); }

                    //gather all matching statTypes
                    List<statType> matches = new List<statType>();

                    foreach (string s in series)
                    {
                        //populate list of statTypes that match our query. Dont worry about order / dupes - will be ordered later
                        //try exact matches
                        string[] titles = s.Trim().Split(">"[0]);
                        if (titles.Length == 2)
                        {
                            //get the series info
                            statType seriesStats = getStatType(titles[1], titles[0]);
                            if (seriesStats != null) { matches.Add(seriesStats); }
                        }

                        //try regex matches
                        List<statType> matchingTypes = getStatTypes(s);
                        foreach (statType mt in matchingTypes)
                        {
                            matches.Add(mt);
                        }

                    }
                    if (matches.Count == 0)
                    {
                        Roboto.log.log("No chart type matches", logging.loglevel.warn);
                        return null;
                    }
                    else
                    {
                        matches = matches.Distinct().OrderBy(x => x.moduleType + ">" + x.name).ToList();
                        foreach (statType seriesStats in matches)
                        {
                            ch.Series.Add(seriesStats.getSeries(graphStartTime));
                        }
                        //ch.SaveImage(@"C:\temp\chart.jpg", ChartImageFormat.Jpeg);
                        MemoryStream ms = new MemoryStream();
                        ch.SaveImage(ms, ChartImageFormat.Jpeg);
                        return (ms);
                    }
                }
            }
            catch (Exception e)
            {
                Roboto.log.log("Error generating chart. " + e.ToString() , logging.loglevel.critical);
            }
            return null;
        }
开发者ID:davep1ke,项目名称:roboto,代码行数:90,代码来源:stats.cs

示例15: GenerateChart

        private void GenerateChart(string fileName, float[] values, float[] otherValues, string xAxisName, string yAxisName)
        {
            using ( Chart chart = new Chart() )
            {
                chart.Width = this.CharWidth;
                chart.Height = this.CharHeight;

                using ( ChartArea area = new ChartArea( "Start Times" ) )
                {
                    using ( Series firstSeries = new Series() )
                    using ( Series secondSeries = new Series() )
                    {
                        AddData( values, chart, firstSeries );
                        AddData( otherValues, chart, secondSeries );
                        firstSeries.ChartType = secondSeries.ChartType = SeriesChartType.Column;
                        area.AxisX.Title = xAxisName;// "Start Time";
                        area.AxisY.Title = yAxisName;// "#Episodes";
                        area.AxisX.Interval = 2;
                        area.Visible = true;
                        chart.ChartAreas.Add( area );
                        firstSeries.Name = FirstSeriesName;
                        secondSeries.Name = SecondSeriesName;
                        firstSeries.Color = System.Drawing.Color.RoyalBlue;
                        firstSeries.BorderColor = System.Drawing.Color.Black;
                        firstSeries.BorderWidth = 1;
                        secondSeries.Color = System.Drawing.Color.Red;
                        secondSeries.BorderColor = System.Drawing.Color.Black;
                        secondSeries.BorderWidth = 1;
                        using ( Legend legend = new Legend() )
                        {
                            chart.Legends.Add( legend );
                            chart.SaveImage( fileName, ChartImageFormat.Png );
                        }
                    }
                }
            }
        }
开发者ID:Cocotus,项目名称:XTMF,代码行数:37,代码来源:ComparisonOfFiles.cs


注:本文中的System.Windows.Forms.DataVisualization.Charting.Chart.SaveImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。