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


C# Chart.ToWebImage方法代码示例

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


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

示例1: GetPieChart

        public ActionResult GetPieChart()
        {
            int[] ranges = { 4, 8, 12 };

            var query = from value in uploadDataMgr.GetUploadedLive().ToList()
                            .Where(p => p.ScoreTotal != null)
                            .Select(p => p.ScoreTotal)
                        group value by ranges.Where(x => value >= x)
                                             .DefaultIfEmpty()
                                             .Last() into groups
                        select new { Key = groups.Key, Values = groups };
            Dictionary<string, int> dictRiskCat = new Dictionary<string, int>();
            foreach (var group in query)
            {
                if (group.Key == 0)
                    dictRiskCat.Add("Low Risk", group.Values.Count());
                else if (group.Key == 4)
                    dictRiskCat.Add("Medium Risk", group.Values.Count());
                else if (group.Key == 8)
                    dictRiskCat.Add("High Risk", group.Values.Count());
            }

            var key = new Chart(width: 300, height: 300)
                .AddTitle("Risk Summary")
                .AddSeries(
                chartType: "Pie",
                name: "Risk Summary",
                xValue: dictRiskCat.Keys,
                yValues: dictRiskCat.Values);

            return File(key.ToWebImage().GetBytes(), "image/jpeg");
        }
开发者ID:dashboard1234,项目名称:Dashboard,代码行数:32,代码来源:ChartController.cs

示例2: GetUrlFromChart

 public static object GetUrlFromChart(this HtmlHelper helper, Chart chart)
 {
     string path = "~/Images/graphs/";
         string filename = path + Guid.NewGuid();
         chart.ToWebImage("jpeg").Save(filename);
         return ".." + filename.Substring(1) + ".jpeg";
 }
开发者ID:przemko07,项目名称:ZaliczenieTenglera,代码行数:7,代码来源:SimpleExtension.cs

示例3: ToWebImageUsesFormat

 public void ToWebImageUsesFormat()
 {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     var image = chart.ToWebImage(format: "png");
     Assert.NotNull(image);
     Assert.Equal("png", image.ImageFormat);
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:7,代码来源:ChartTest.cs

示例4: TemplateWithIncorrectPropertiesThrows

 public void TemplateWithIncorrectPropertiesThrows()
 {
     var template = WriteTemplate(@"<Chart borderWidth=""2""><fjkjkgjklfg /></Chart>");
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: template);
     Assert.Throws<InvalidOperationException>(() => chart.ToWebImage(),
                                                       "Cannot deserialize property. Unknown property name 'borderWidth' in object \" System.Web.UI.DataVisualization.Charting.Chart");
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:7,代码来源:ChartTest.cs

示例5: TemplateWithCommentsDoesNotThrow

 public void TemplateWithCommentsDoesNotThrow()
 {
     var template = WriteTemplate(@"<Chart BorderWidth=""2""><!-- This is a XML comment.  --> </Chart>");
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100, themePath: template);
     Assert.NotNull(chart.ToWebImage());
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:6,代码来源:ChartTest.cs

示例6: Chart

        public ActionResult Chart(string strid, int acYear)
        {
            ArrayList xValues = new ArrayList();
            ArrayList yValues = new ArrayList();
            var myChart = new Chart(350, 300, ChartTheme.Blue);

            if (acYear == 201516)
            {
                var chart_data = db.Lecture_Attendance_Count_view.Where(t => t.idsubject_faculties == strid).OrderBy(t => t.lecture_no);
                try
                {
                    chart_data.ToList().ForEach(rs => xValues.Add(rs.lecture_no));
                    chart_data.ToList().ForEach(rs => yValues.Add(rs.Total_students));
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                }

                ViewBag.idsubject_faculties = strid;

                myChart.AddSeries(chartType: "Line", xValue: xValues, yValues: yValues);
                myChart.SetXAxis(title: "Lecture No.", min: 1);
                myChart.SetYAxis(title: "No. of Students");

                myChart.AddTitle("Attendance Chart");
                myChart.Write("png");
            }
               else if(acYear==201617)
            {
                var chart_data = db.Lecture_Attendance_Count_view_201617.Where(t => t.idsubject_faculties == strid).OrderBy(t => t.lecture_no);
                try
                {
                    chart_data.ToList().ForEach(rs => xValues.Add(rs.lecture_no));
                    chart_data.ToList().ForEach(rs => yValues.Add(rs.Total_students));
                }
                catch (Exception e)
                {
                    string msg = e.Message;
                }

                ViewBag.idsubject_faculties = strid;

                myChart.AddSeries(chartType: "Line", xValue: xValues, yValues: yValues);
                myChart.SetXAxis(title: "Lecture No.", min: 1);
                myChart.SetYAxis(title: "No. of Students");

                myChart.AddTitle("Attendance Chart");
                myChart.Write("png");
            }

            return File(myChart.ToWebImage().GetBytes(), "image/bytes");
        }
开发者ID:piit,项目名称:ams,代码行数:53,代码来源:LectPlanDeliver_count_View_201617Controller.cs

示例7: TaskDetails

        public ActionResult TaskDetails(string id)
        {
            if (id == null)
            {
                return RedirectToAction("MessagePage", "Home", "Task ID is null");
            }

            Chart chart = new Chart(height:400, width:600).AddSeries(name:"Title", chartType:"line");
            ViewBag.Chart = chart.ToWebImage().GetBytes();

            var task = _dbContext.CoursesCreatingTasks.Find(x => x.Id == ObjectId.Parse(id)).SingleAsync().Result;
            return View(task);
        }
开发者ID:wadim1611,项目名称:CourseBuildingsSystemMVCandWCF,代码行数:13,代码来源:HomeController.cs

示例8: ToWebImage

 public void ToWebImage() {
     var chart = new Chart(GetContext(), GetVirtualPathProvider(), 100, 100);
     var image = chart.ToWebImage();
     Assert.IsNotNull(image);
     Assert.AreEqual("jpeg", image.ImageFormat);
 }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:6,代码来源:ChartTest.cs


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