/// <summary> /// /// </summary> /// <returns>Json data for Monthly sales for this month</returns> public JsonResult ForMorris2() { ReportsController rc = new ReportsController(); var model = rc.MonthlySalesByDate_forCharts(DateTime.Today.Year, DateTime.Today.Month); var value = model.Select(i => new Object[] { i.Day.ToString(), i.Total }).ToArray(); return(Json(value, JsonRequestBehavior.AllowGet)); }
//******************************************* //****************Charts ******************** /// <summary> /// Returns Json data for yearly sales. /// </summary> /// <returns></returns> public JsonResult ForMorris() { string year = Convert.ToString(DateTime.Today.Year); ReportsController rc = new ReportsController(); var model = rc.YearlySalesByMonth_forCharts(year).ToList(); var count = model.Select(i => new Object[] { i.GrandTotal }).ToList(); return(Json(count, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Displays Partial View for Yearly Sales /// </summary> /// <returns></returns> public PartialViewResult MyChart() { string year = Convert.ToString(DateTime.Today.Year); ReportsController rc = new ReportsController(); var model = rc.YearlySalesByMonth_forCharts(year).ToList(); var name = model.Select(i => i.Month.ToString()).ToArray(); var count = model.Select(i => new Object[] { i.GrandTotal }).ToArray(); String[] arr = { "Jan", " Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; var charts = new Highcharts("charts").InitChart(new Chart { DefaultSeriesType = ChartTypes.Line }) .SetTitle(new Title { Text = "Graph of Yearly sales" }) .SetSubtitle(new Subtitle { Text = "For year 2015" }) // .SetXAxis(new XAxis { Categories = name, Title = new XAxisTitle{Text = "Months"} }) .SetXAxis(new XAxis { Categories = arr, Title = new XAxisTitle { Text = "Months" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Total Sales/Month" } }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetSeries(new[] { new Series { Name = "Total sales", Data = new Data(count) } }); return(PartialView("MyChartPartialView", charts)); }
/// <summary> /// Displays Prtial View for Monthly sales /// </summary> /// <returns></returns> public ActionResult MyChartForSalesOfMonth() { //string year = Convert.ToString(DateTime.Today.Year); ReportsController rc = new ReportsController(); var model = rc.MonthlySalesByDate_forCharts(DateTime.Today.Year, DateTime.Today.Month); var name = model.Select(i => i.Day.ToString()).ToArray(); var count = model.Select(i => new Object[] { i.Total }).ToArray(); var charts2 = new Highcharts("charts").InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) .SetTitle(new Title { Text = "Graph of Sales in a month" }) .SetSubtitle(new Subtitle { Text = "For year: " + DateTime.Today.Year + ", month: " + DateTime.Today.Month }) .SetXAxis(new XAxis { Categories = name, Title = new XAxisTitle { Text = "Months" } }) .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Total Sales per Day" } }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) .SetSeries(new[] { new Series { Name = "Total sales", Data = new Data(count) } }); return(PartialView("MyChartForSalesOfMonthPartialView", charts2)); }