예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }