當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。