programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, March 8, 2017

How to add google chart api data

How to add google chart api data 

i want to create created a graph with the help of google chart api and I have a problem with correct display name of the month on the chart 
this is  code in controller looks like:

public ActionResult ListOrder()
        var result = from s in db.Orders.ToList()
                     group s by
          new { Year = s.dateCreated.Year, Month = s.dateCreated.Month, Day = 1 }
             into g
        select new OrderViewModel
        dateCreated = new DateTime(g.Key.Year, g.Key.Month, g.Key.Day),
        TotalPrice = g.Sum(x => x.totalPrice)
        return Json(result, JsonRequestBehavior.AllowGet);

// change column data type to 'date'
data.addColumn('date', 'Month');
data.addColumn('number', 'Total sum order for month');

for (var i = 0; i < chartData.length; i++) {
    var rowDate;

    // convert dateCreated
    rowDate = chartData[i].dateCreated;

    // replace first forward slash (/) with 'new'
    rowDate = rowDate.replace('/', 'new ');

    // remove second forward slash (/)
    rowDate = rowDate.replace('/', '');

    // evaluate the string to an actual date
    rowDate = eval(rowDate);

    data.addRow([rowDate, chartData[i].TotalPrice]);

Sql Server Interview Qus:

No comments:

Post a Comment