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


C# Chart.GetBytes方法代码示例

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


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

示例1: Agitator

        public ActionResult Agitator(int Id)
        {
            var politicalViews = new List<KeyValuePair<string, int>>();
            var agitatorHouses = dataManager.AgitatorHouseRelations.GetAll().Where(ah => ah.AgitatorId == Id && ah.HouseId.HasValue).Select(wh => wh.HouseId.Value).ToList();

            var houses = dataManager.Houses.GetAll().Where(h => agitatorHouses.Contains(h.Id) && h.Latitude.HasValue && h.Longitude.HasValue).ToList();
            var persons = dataManager.Persons.GetAll().Where(p => houses.Select(x => x.Id).Contains(p.HouseId ?? 0)).ToList();
            var voters = dataManager.Voters.GetAll().Where(v => persons.Select(x => x.Id).Contains(v.PersonId ?? 0)).ToList();
            var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().ToList();
            var parties = voterPartyRelations.Where(vp => voters.Select(x => x.Id).Contains(vp.VoterId ?? 0))
                .Select(x => dataManager.Parties.Get(x.PartyId ?? 0)).ToList();

            foreach (var house in houses)
            {
                var hPersons = persons.Where(x => x.HouseId == house.Id).ToList();
                var hVoters = voters.Where(x => hPersons.Select(x2 => x2.Id).Contains(x.PersonId ?? 0)).ToList();
                var hVoterPartyRelations = voterPartyRelations.Where(x => hVoters.Select(x2 => x2.Id).Contains(x.VoterId ?? 0)).ToList();
                var hParties = parties.Where(x => hVoterPartyRelations.Select(x2 => x2.PartyId).Contains(x.Id)).ToList();

                foreach (var hParty in hParties.GroupBy(x => x.Id).Select(x => x.First()))
                {
                    politicalViews.Add(new KeyValuePair<string, int>(hParty.Name, hVoterPartyRelations.Where(x => x.PartyId == hParty.Id).Count()));
                }
            }
            var chart = new Chart(width: 200, height: 200)
            .AddSeries(
                name: "Employee",
                xValue: politicalViews.Select(p => p.Key).ToArray(),
                yValues: politicalViews.Select(p => p.Value).ToArray(),
                chartType: "Pie");
            return File(chart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:32,代码来源:ChartController.cs

示例2: Input

        public ActionResult Input()
        {
            List<string> xval = new List<string>();
            List<string> yval = new List<string>();
            List<string> yval2 = new List<string>();

            foreach (var points in db.Users.ToList().OrderByDescending(c => c.Win).Take(9))
            {
                xval.Add(points.Name);
                yval.Add(points.Input.ToString());
                yval2.Add(points.Win.ToString());

            }

            string[] _xval = xval.ToArray();
            string[] _yval = yval.ToArray();
            string[] _yval2 = yval2.ToArray();

            var chartsPoint = new Chart(width: 1000, height: 400, theme: ChartTheme.Blue) //,theme: ChartTheme.Blue
            .AddSeries(
                name: "Buy-In",
                xValue: _xval,
                yValues: _yval
                )
            .AddSeries(
                name:"Gewonnen",
                xValue: _xval,
                yValues: _yval2)
            .AddLegend();

            return File(chartsPoint.GetBytes("png"), "image/png");
        }
开发者ID:rogerbollmann,项目名称:SickFriday,代码行数:32,代码来源:ChartsController.cs

示例3: RenderChart

        public ActionResult RenderChart()
        {
            var myChart = new Chart(width: 600, height: 400)
                .AddSeries(
                    name: "Employee", xValue: new[] {"Peter", "Andrew", "Julie", "Mary", "Dave"},
                    yValues: new[] {"2", "6", "4", "5", "3"});

            return File(myChart.GetBytes(), "image/jpeg");
        }
开发者ID:noug,项目名称:neuesinaspnetmvc3rc,代码行数:9,代码来源:FancyController.cs

示例4: Games

        public ActionResult Games()
        {

            var db = new ZkDataContext();
            db.Database.CommandTimeout = 600;

            var data = MemCache.GetCached(
                "gameStats",
                () =>
                {
                    var start = new DateTime(2011, 2, 3);
                    var end = DateTime.Now.Date;
                    return (from bat in db.SpringBattles
                        where bat.StartTime < end && bat.StartTime > start
                        group bat by DbFunctions.TruncateTime(bat.StartTime)
                        into x
                        orderby x.Key
                        let players = x.SelectMany(y => y.SpringBattlePlayers.Where(z => !z.IsSpectator)).Select(z => z.AccountID).Distinct().Count()
                        select
                            new GameStats
                            {
                                Day = x.Key.Value,
                                PlayersAndSpecs = x.SelectMany(y => y.SpringBattlePlayers).Select(z => z.AccountID).Distinct().Count(),
                                MinutesPerPlayer = x.Sum(y => y.Duration*y.PlayerCount)/60/players,
                                FirstGamePlayers =
                                    x.SelectMany(y => y.SpringBattlePlayers)
                                        .GroupBy(y => y.Account)
                                        .Count(y => y.Any(z => z == y.Key.SpringBattlePlayers.FirstOrDefault()))
                            }).ToList();
                },
                60*60*20);

            var chart = new Chart(1500, 700, ChartTheme.Blue);

            chart.AddTitle("Daily activity");
            chart.AddLegend("Daily values", "dps");

            chart.AddSeries("unique players+specs", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.PlayersAndSpecs).ToList(), legend: "dps");
            chart.AddSeries("minutes/player", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.MinutesPerPlayer).ToList(), legend: "dps");
            chart.AddSeries("new players", "Line", xValue: data.Select(x => x.Day).ToList(), yValues: data.Select(x => x.FirstGamePlayers).ToList(), legend: "dps");

            return File(chart.GetBytes("png"), "image/png");
        }
开发者ID:Jamanno,项目名称:Zero-K-Infrastructure,代码行数:43,代码来源:LaddersController.cs

示例5: Points

        public ActionResult Points()
        {
            List<string> xval = new List<string>();
            List<string> yval = new List<string>();

            foreach (var points in db.Users.ToList().OrderByDescending(c => c.Points).Take(9))
            {
                xval.Add(points.Name);
                yval.Add(points.Points.ToString());

            }

            string[] _xval = xval.ToArray();
            string[] _yval = yval.ToArray();

            var chartsPoint = new Chart(width: 1000, height: 400, theme: ChartTheme.Yellow) //,theme: ChartTheme.Yellow
            .AddSeries(
                xValue: _xval,
                yValues: _yval);

            return File(chartsPoint.GetBytes("png"), "image/png");
        }
开发者ID:rogerbollmann,项目名称:SickFriday,代码行数:22,代码来源:ChartsController.cs

示例6: GetChartBytes

        private byte[] GetChartBytes(int userId, Func<StatisticSeriesEntry, double> yValueAccessor, string chartTitle)
        {
            Debug.Assert(yValueAccessor != null);

            var seriesData = this.chartDataService.CalculateSeriesForUser(userId, DateTime.UtcNow.AddMonths(-12), null);

            var myChart = new Chart(width: 800, height: 450)
                .AddTitle(chartTitle)
                .AddLegend();

            if (ChartController.PlotMultipleChartLine(myChart, seriesData.Entries, yValueAccessor))
            {
                return myChart.GetBytes("jpeg");
            }
            else
            {
                return null;
            }
        }
开发者ID:harimukkapati,项目名称:FootPrint,代码行数:19,代码来源:ChartController.cs

示例7: GetBytesThrowsWhenFormatIsNull

 public void GetBytesThrowsWhenFormatIsNull()
 {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     Assert.ThrowsArgumentNullOrEmptyString(() => { chart.GetBytes(format: null); }, "format");
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:5,代码来源:ChartTest.cs

示例8: GetBytesThrowsWhenFormatIsInvalid

 public void GetBytesThrowsWhenFormatIsInvalid()
 {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     Assert.ThrowsArgument(() => { chart.GetBytes(format: "foo"); }, "format", "\"foo\" is invalid image format. Valid values are image format names like: \"JPEG\", \"BMP\", \"GIF\", \"PNG\", etc.");
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:5,代码来源:ChartTest.cs

示例9: GetBytesReturnsNonEmptyArray

 public void GetBytesReturnsNonEmptyArray()
 {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     Assert.True(chart.GetBytes().Length > 0);
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:5,代码来源:ChartTest.cs

示例10: GetBytesThrowsWhenFormatIsEmpty

 public void GetBytesThrowsWhenFormatIsEmpty() {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     ExceptionAssert.ThrowsArgNullOrEmpty(() => {
         chart.GetBytes(format: String.Empty);
     }, "format");
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:6,代码来源:ChartTest.cs

示例11: Precinct

        public ActionResult Precinct(int Id)
        {
            var parties = new List<KeyValuePair<string, int>>();
            var itemHouses = dataManager.Houses.GetAll().Where(h => h.PrecinctId == Id).Select(x => x.Id).ToList();
            var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().ToList();
            var voters = from v in dataManager.Voters.GetAll()
                         where itemHouses.Contains(dataManager.Persons.Get(v.PersonId ?? 0).HouseId ?? 0)
                         select new VoterViewModel
                         {
                             Person = dataManager.Persons.Get(v.PersonId ?? 0),
                             PoliticalViews = (from vp in voterPartyRelations
                                               where vp.VoterId == v.Id
                                               select new VoterPartyRelationViewModel
                                               {
                                                   VoterPartyRelation = vp,
                                                   Voter = v,
                                                   Party = dataManager.Parties.Get(vp.PartyId ?? 0)
                                               }).ToList()
                         };

            foreach (var v in voters.SelectMany(x => x.PoliticalViews).ToList().GroupBy(v => v.Party != null ? v.Party.Id : 0))
            {
                var party = dataManager.Parties.Get(v.Key);
                parties.Add(new KeyValuePair<string, int>(party != null ? party.Name : "не указано", v.Count()));
            }

            var myChart = new Chart(width: 160, height: 140)
            .AddSeries(
                name: "Employee",
                xValue: parties.Select(p => p.Key).ToArray(),
                yValues: parties.Select(p => p.Value).ToArray(),
                chartType: "Pie");
            //return File(myChart.Write().GetBytes(), "image/jpeg");
            //Image image = Image.FromFile(Path.Combine(Server.MapPath("/Images/Resources"), "img1.png"));
            //var str = new FileStream(Path.Combine(Server.MapPath("/Images/Resources"), "img1.png"), FileMode.Create);
            //str.Write(myChart.GetBytes(), 0, myChart.GetBytes().Length);
            //Image image2 = Image.FromStream(str);

            //using (Graphics g = Graphics.FromImage(image2))
            //{
            //    // do something with the Graphics (eg. write "Hello World!")
            //    string text = "Hello World!";

            //    // Create font and brush.
            //    Font drawFont = new Font("Arial", 10);
            //    SolidBrush drawBrush = new SolidBrush(Color.Black);

            //    // Create point for upper-left corner of drawing.
            //    PointF stringPoint = new PointF(0, 0);

            //    g.DrawString(text, drawFont, drawBrush, stringPoint);
            //}

            //MemoryStream ms = new MemoryStream();

            //image2.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

            return File(myChart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:59,代码来源:ChartController.cs

示例12: Municipality

        public ActionResult Municipality(int Id)
        {
            var parties = new List<KeyValuePair<string, int>>();
            var municipalityHouses = dataManager.MunicipalityHouseRelations.GetAll().Where(x => x.MunicipalityId == Id).Select(x => x.HouseId ?? 0).ToList();

            var voterPartyRelations = dataManager.VoterPartyRelations.GetAll();
            var voters = from v in dataManager.Voters.GetAll()
                         where municipalityHouses.Contains(dataManager.Persons.Get(v.PersonId ?? 0).HouseId ?? 0)
                         select new VoterViewModel
                         {
                             Person = dataManager.Persons.Get(v.PersonId ?? 0),
                             PoliticalViews = (from vp in voterPartyRelations
                                               where vp.VoterId == v.Id
                                               select new VoterPartyRelationViewModel
                                               {
                                                   VoterPartyRelation = vp,
                                                   Voter = v,
                                                   Party = dataManager.Parties.Get(vp.PartyId ?? 0)
                                               }).ToList()
                         };

            foreach (var v in voters.SelectMany(x => x.PoliticalViews).GroupBy(v => v.Party != null ? v.Party.Id : 0))
            {
                var party = dataManager.Parties.Get(v.Key);
                parties.Add(new KeyValuePair<string, int>(party != null ? party.Name : "не указано", v.Count()));
            }

            var myChart = new Chart(width: 160, height: 140)
            .AddSeries(
                name: "Employee",
                xValue: parties.Select(p => p.Key).ToArray(),
                yValues: parties.Select(p => p.Value).ToArray(),
                chartType: "Pie");

            return File(myChart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:36,代码来源:ChartController.cs

示例13: House

        public ActionResult House(int Id)
        {
            var politicalViews = new List<KeyValuePair<string, int>>();
            var hPersons = dataManager.Persons.GetAll().Where(x => x.HouseId == Id).ToList();
            var hVoters = dataManager.Voters.GetAll().Where(x => hPersons.Select(x2 => x2.Id).Contains(x.PersonId ?? 0)).ToList();
            var hVoterPartyRelations = dataManager.VoterPartyRelations.GetAll().Where(x => hVoters.Select(x2 => x2.Id).Contains(x.VoterId ?? 0)).ToList();
            var hParties = dataManager.Parties.GetAll().Where(x => hVoterPartyRelations.Select(x2 => x2.PartyId).Contains(x.Id)).ToList();
            foreach (var hParty in hParties.GroupBy(x => x.Id).Select(x => x.First()).ToList())
            {
                politicalViews.Add(new KeyValuePair<string, int>(hParty.Name, hVoterPartyRelations.Where(x => x.PartyId == hParty.Id).ToList().Count));
            }

            var chart = new Chart(width: 160, height: 140)
            .AddSeries(
                name: "Employee",
                xValue: politicalViews.Select(p => p.Key).ToArray(),
                yValues: politicalViews.Select(p => p.Value).ToArray(),
                chartType: "Pie");
            return File(chart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:20,代码来源:ChartController.cs

示例14: Candidate3

        public ActionResult Candidate3(int Id)
        {
            var politicalViews = new List<KeyValuePair<string, int>>();

            var candidateMunicipalities = dataManager.CandidateMunicipalityRelations.GetAll().Where(cm => cm.CandidateId == Id && cm.MunicipalityId.HasValue).Select(cm => cm.MunicipalityId.Value).ToList();

            var municipalitiesHouses = dataManager.MunicipalityHouseRelations.GetAll().Where(mh => candidateMunicipalities.Contains(mh.MunicipalityId ?? 0)).Select(mh => mh.HouseId.Value).ToList();
            var houses = dataManager.Houses.GetAll().Where(h => municipalitiesHouses.Contains(h.Id) && h.Latitude.HasValue && h.Longitude.HasValue).ToList();
            var persons = dataManager.Persons.GetAll().Where(p => houses.Select(x => x.Id).Contains(p.HouseId ?? 0)).ToList();
            var voters = dataManager.Voters.GetAll().Where(v => persons.Select(x => x.Id).Contains(v.PersonId ?? 0)).ToList();
            var voterPartyRelations = dataManager.VoterPartyRelations.GetAll().Where(vp => voters.Select(x => x.Id).Contains(vp.VoterId ?? 0)).ToList();
            var parties = voterPartyRelations.Select(x => dataManager.Parties.Get(x.PartyId ?? 0)).ToList();

            foreach(var party in parties.GroupBy(x => x.Id).Select(x => x.First()))
            {
                politicalViews.Add(new KeyValuePair<string, int>(party.Name, voterPartyRelations.Where(x => x.PartyId == party.Id).Count()));
            }
            var chart = new Chart(width: 200, height: 200)
            .AddSeries(
                name: "Employee",
                xValue: politicalViews.Select(p => p.Key).ToArray(),
                yValues: politicalViews.Select(p => p.Value).ToArray(),
                chartType: "Pie");
            return File(chart.GetBytes(), "image/jpeg");
        }
开发者ID:buddzbuddy,项目名称:MSECAnalyze,代码行数:25,代码来源:ChartController.cs

示例15: ChartGenerator

        public ActionResult ChartGenerator()
        {
            List<ChartData> listData = Session["ListData"] as List<ChartData>;
            RiskChartViewModel vm = Session["RiskChartViewModel"] as RiskChartViewModel;

            List<string> xValues = new List<string>();
            List<decimal> yValues = new List<decimal>();
            List<decimal> yValues2 = new List<decimal>();
            foreach (var data in listData)
            {
                xValues.Add(data.Name);
                yValues.Add(data.Value);
                yValues2.Add(data.Value2);
            }

            string seriesName = string.Empty;
            string seriesName2 = string.Empty;
            if (vm.YValueId == DATA_COUNT)
                seriesName = "Banyak Data";
            else if (vm.YValueId == DATA_PROBLEVEL)
                seriesName = "Tingkat Probabilitas";
            else if (vm.YValueId == DATA_IMPACTLEVEL)
                seriesName = "Tingkat Dampak";
            else if (vm.YValueId == DATA_PROBIMPACTLEVEL)
            {
                seriesName = "Tingkat Probabilitas";
                seriesName2 = "Tingkat Dampak";
            }
            else
                seriesName = "Tingkat Risiko";

            string chartType = "column";
            int chartTypeId = vm.ChartTypeId;
            if (chartTypeId == 2)
                chartType = "bar";
            else if (chartTypeId == 3)
                chartType = "pie";

            string xAxisTitle = GetXAxisTitle(vm.XValueId);
            string yAxisTitle = GetYAxisTitle(vm.YValueId);

            var cht = new Chart(width: 600, height: 400, theme: ChartTheme.Blue)
                .SetXAxis(xAxisTitle)
                .SetYAxis(yAxisTitle)
                .AddSeries(name: seriesName,
                    chartType: chartType,
                    xValue: xValues,
                    yValues: yValues, markerStep: 1);
            if (!string.IsNullOrEmpty(seriesName2))
            {
                cht = cht
                    .AddSeries(name: seriesName2,
                        chartType: chartType,
                        xValue: xValues,
                        yValues: yValues2)
                    .AddLegend();
            }

            var bytes = cht.GetBytes("jpg");
            return File(bytes, "image/jpg");
        }
开发者ID:ryanask,项目名称:MRK,代码行数:61,代码来源:RiskChartController.cs


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