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


C# Chart.Write方法代码示例

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


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

示例1: ChartImage

        public void ChartImage()
        {
            var products = new[]
            {
                new Product {Name = "Kayak", Category = "Watersports", Price = 275m},
                new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95m},
                new Product {Name = "Soccer ball", Category = "Football", Price = 19.50m},
                new Product {Name = "Corner flags", Category = "Football", Price = 34.95m},
                new Product {Name = "Thinking cap", Category = "Chess", Price = 16m},
            };

            Chart chart = new Chart(600, 200,
                                    @"<Chart BackColor=""Gray"" BackSecondaryColor=""WhiteSmoke""
            BackGradientStyle=""DiagonalRight"" AntiAliasing=""All""
            BorderlineDashStyle = ""Solid"" BorderlineColor = ""Gray"">
            <BorderSkin SkinStyle = ""Emboss"" />
            <ChartAreas>
            <ChartArea Name=""Default"" _Template_=""All"" BackColor=""Wheat""
            BackSecondaryColor=""White"" BorderColor=""64, 64, 64, 64""
            BorderDashStyle=""Solid"" ShadowColor=""Transparent"">
            </ChartArea>
            </ChartAreas>
            </Chart>");

            chart.AddSeries(
                chartType: "Column",
                yValues: products.Select(p => p.Price).ToArray(),
                xValue: products.Select(p => p.Name).ToArray()
            );

            chart.Write();
        }
开发者ID:aistrate,项目名称:ProAspNetMvc3,代码行数:32,代码来源:HomeController.cs

示例2: Chart

        public ActionResult Chart(string strid, int acYr)
        {
            ArrayList xValues = new ArrayList();
            ArrayList yValues = new ArrayList();

            var myChart = new Chart(350, 300, ChartTheme.Blue);

            if (acYr == 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 = new Chart(350, 300, ChartTheme.Blue);
                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");
            }
            else if(acYr == 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 = new Chart(350, 300, ChartTheme.Blue);
                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");
            }

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

示例3: WriteUpdatesResponse

 public void WriteUpdatesResponse()
 {
     var context = GetContext();
     var chart = new Chart(context, GetVirtualPathProvider(), 100, 100);
     chart.Write();
     Assert.Equal("", context.Response.Charset);
     Assert.Equal("image/jpeg", context.Response.ContentType);
     Assert.True((_writeData != null) && (_writeData.Length > 0));
 }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:9,代码来源:ChartTest.cs

示例4: WriteThrowsWithInvalidFormat

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

示例5: WriteWorksWithJPGFormat

        public void WriteWorksWithJPGFormat()
        {
            var response = new Mock<HttpResponseBase>();
            var stream = new MemoryStream();
            response.Setup(c => c.Output).Returns(new StreamWriter(stream));

            var context = new Mock<HttpContextBase>();
            context.Setup(c => c.Response).Returns(response.Object);

            var chart = new Chart(context.Object, GetVirtualPathProvider(), 100, 100);
            chart.Write("jpeg");

            byte[] a = stream.GetBuffer();

            stream.SetLength(0);
            chart.Write("jpg");
            byte[] b = stream.GetBuffer();

            Assert.Equal(a, b);
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:20,代码来源:ChartTest.cs

示例6: ScoreChart

        public ActionResult ScoreChart(int id)
        {
            var game = handler.GetGameInfo(id);

            var chart = new Chart(width: 350, height: 250)
                .AddTitle("Game Focus")
                .AddSeries(
                    name: "Score",
                    chartType: "Radar",
                    xValue: new[] { "Strategic Difficulty", "Replay Value", "Mechanical Difficulty", "Ease of Access", "Atmosphere" },
                    yValues: new[] {
                        game.Score.iStrategy.ToString(),
                        game.Score.iLongevity.ToString(),
                        game.Score.iMechanics.ToString(),
                        game.Score.iEase.ToString(),
                        game.Score.iAtmosphere.ToString()
                    });
            chart.Write();

            return null;
        }
开发者ID:RasmusHansson,项目名称:GaimaMvc,代码行数:21,代码来源:SearchController.cs

示例7: MyChart

        /// <summary>
        /// Render weight graph.
        /// </summary>
        /// <param name="username">The username to display graph for.</param>
        /// <returns></returns>
        public ActionResult MyChart(string username)
        {
            var dates = new List<DateTime>();
            var weights = new List<double>();
            var plots = _context.Users.Find(username).WeightPlots.Where(x=>x.PlotStamp>DateTime.Parse("2015-01-01")).OrderByDescending(x => x.PlotStamp);

            var minWeight = plots.Min(x => x.Weight);
            var maxWeight = plots.Max(x => x.Weight);

            minWeight -= 2;
            maxWeight += 2;

            foreach(var plot in plots)
            {
                dates.Add(plot.PlotStamp);
                weights.Add(Math.Round(plot.Weight,2));
            }

            var chart = new Chart(540,280);
            chart.AddSeries
                (
                chartType: "line",
                xValue: dates,
                yValues: weights
                );
            chart.SetYAxis("", Math.Round(minWeight,1), Math.Round(maxWeight,1));
            chart.Write("png");

            return null;
        }
开发者ID:tiddan,项目名称:WeightMeas,代码行数:35,代码来源:HomeController.cs


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