Esempio n. 1
0
        public async Task <ActionResult> Start(string Url)
        {
            TestDto results;

            try
            {
                results = await tester.TestAllPages(Url);

                ChartTypeBar chart = new ChartTypeBar()
                {
                    Data = new BarData()
                    {
                        Labels   = results.Pages.Select(x => x.Id.ToString()).ToArray(),
                        Datasets = new BarDataSets[]
                        {
                            new BarDataSets()
                            {
                                Label           = "Response Time (ms)",
                                BackgroundColor = "rgb(89, 207, 240)",
                                BorderColor     = "rgb(187, 89, 240)",
                                BorderWidth     = 0,
                                LinearData      = results.Pages.Select(x => (int)Math.Round(x.Results.Last().ResponseTime)).ToArray()
                            }
                        }
                    },
                    Options = new BarOptions()
                    {
                        Title = new ChartOptionsTitle()
                        {
                            Display = true,
                            Text    = new string[] { results.Url }
                        },
                        Legend = new ChartOptionsLegend()
                        {
                            Position = ConstantPosition.TOP
                        },
                        BarPercentage      = 0,
                        CategoryPercentage = 0,
                    }
                };
                ViewBag.ChartObj = chart;

                var ordered = results;
                ordered.Pages = ordered.Pages.OrderBy(p => p.Results.Last().ResponseTime).Reverse().ToList();

                return(PartialView("TestResult", ordered));
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.Message;

                return(PartialView("TestResult"));
            }
        }
Esempio n. 2
0
        public ActionResult Vertical()
        {
            ChartTypeBar chart = new ChartTypeBar()
            {
                Data = new BarData()
                {
                    Labels   = new string[] { "January", "February", "March", "April", "May", "June", "July" },
                    Datasets = new BarDataSets[]
                    {
                        new BarDataSets()
                        {
                            Label           = "Dataset 1",
                            BackgroundColor = "green",
                            BorderColor     = "green",
                            BorderWidth     = 1,
                            LinearData      = new int[] { -63, -64, 34, 43, -56, 12, 70 }
                        },
                        new BarDataSets()
                        {
                            Label           = "Dataset 2",
                            BackgroundColor = "blue",
                            BorderColor     = "blue",
                            BorderWidth     = 1,
                            LinearData      = new int[] { 15, -54, 45, 24, -50, 43, 36 }
                        }
                    }
                },
                Options = new BarOptions()
                {
                    Title = new ChartOptionsTitle()
                    {
                        Display = true,
                        Text    = new string[] { "Chart.js Bar Chart" }
                    },
                    Legend = new ChartOptionsLegend()
                    {
                        Position = ConstantPosition.TOP,
                    }
                }
            };

            ViewBag.Chart    = new MvcHtmlString(chart.Draw("myChart"));
            ViewBag.chartObj = chart;
            return(View());
        }
Esempio n. 3
0
        public ActionResult StackedGroup()
        {
            ChartTypeBar chart = new ChartTypeBar()
            {
                Data = new BarData()
                {
                    Labels   = new string[] { "January", "February", "March", "April", "May", "June", "July" },
                    Datasets = new BarDataSets[]
                    {
                        new BarDataSets()
                        {
                            Label           = "Dataset 1",
                            BackgroundColor = "green",
                            BorderColor     = "green",
                            BorderWidth     = 1,
                            Stack           = "stack 1",
                            LinearData      = new int[] { -63, -64, 34, 43, -56, 12, 70 }
                        },
                        new BarDataSets()
                        {
                            Label           = "Dataset 2",
                            BackgroundColor = "blue",
                            BorderColor     = "blue",
                            BorderWidth     = 1,
                            Stack           = "stack 1",
                            LinearData      = new int[] { 15, -54, 45, 24, -50, 43, 36 }
                        },
                        new BarDataSets()
                        {
                            Label           = "Dataset 3",
                            BackgroundColor = "yellow",
                            BorderColor     = "yellow",
                            BorderWidth     = 1,
                            Stack           = "stack 2",
                            LinearData      = new int[] { 10, 23, 45, -12, 48, -32, -25 }
                        }
                    }
                },
                Options = new BarOptions()
                {
                    Title = new ChartOptionsTitle()
                    {
                        Display = true,
                        Text    = new string[] { "Chart.js Bar Chart - Stacked" }
                    },
                    Legend = new ChartOptionsLegend()
                    {
                        Position = ConstantPosition.TOP,
                    },
                    Tooltips = new ChartOptionsTooltip()
                    {
                        Mode      = ConstantMode.INDEX,
                        Intersect = false
                    },
                    Scales = new ChartOptionsScales()
                    {
                        XAxes = new ChartOptionsScalesAxes[] { new ChartOptionsScalesAxes()
                                                               {
                                                                   Stacked = true
                                                               } },
                        YAxes = new ChartOptionsScalesAxes[] { new ChartOptionsScalesAxes()
                                                               {
                                                                   Stacked = true
                                                               } }
                    }
                }
            };

            ViewBag.Chart    = new MvcHtmlString(chart.Draw("myChart"));
            ViewBag.chartObj = chart;
            return(View());
        }
Esempio n. 4
0
        public ActionResult MultiAxis()
        {
            ChartTypeBar chart = new ChartTypeBar()
            {
                Data = new BarData()
                {
                    Labels   = new string[] { "January", "February", "March", "April", "May", "June", "July" },
                    Datasets = new BarDataSets[]
                    {
                        new BarDataSets()
                        {
                            Label           = "Dataset 1",
                            BackgroundColor = "green",
                            BorderColor     = "green",
                            BorderWidth     = 1,
                            YAxisID         = "y-axis-1",
                            LinearData      = new int[] { -63, -64, 34, 43, -56, 12, 70 }
                        },
                        new BarDataSets()
                        {
                            Label           = "Dataset 2",
                            BackgroundColor = "blue",
                            BorderColor     = "blue",
                            BorderWidth     = 1,
                            YAxisID         = "y-axis-2",
                            LinearData      = new int[] { 15, -54, 45, 24, -50, 43, 36 }
                        }
                    }
                },
                Options = new BarOptions()
                {
                    Scales = new ChartOptionsScales()
                    {
                        YAxes = new ChartOptionsScalesAxes[]
                        {
                            new ChartOptionsScalesAxes()
                            {
                                Display  = true,
                                Position = ConstantPosition.LEFT,
                                Id       = "y-axis-1"
                            },
                            new ChartOptionsScalesAxes()
                            {
                                Display   = true,
                                Position  = ConstantPosition.RIGHT,
                                Id        = "y-axis-2",
                                GridLines = new ChartOptionsScaleGridLines()
                                {
                                    DrawOnChartArea = false
                                }
                            }
                        }
                    },
                    Title = new ChartOptionsTitle()
                    {
                        Display = true,
                        Text    = new string[] { "Chart.js Bar Chart - Multi Axis" }
                    },
                    Tooltips = new ChartOptionsTooltip()
                    {
                        Mode      = ConstantMode.INDEX,
                        Intersect = true
                    },
                    Legend = new ChartOptionsLegend()
                    {
                        Position = ConstantPosition.TOP,
                    }
                }
            };

            ViewBag.Chart    = new MvcHtmlString(chart.Draw("myChart"));
            ViewBag.chartObj = chart;
            return(View());
        }