Posted Beta package to NuGet

Coordinator
Jan 19, 2014 at 4:44 AM
Edited Jan 19, 2014 at 4:45 AM
The beta first package has been released to NuGet. See the Home View in the source code for an example on how to use the library.

View the sample page at http://charts.porrey.net/.

Ensure the styles and scripts are rendered by placing this line at the top of the layout page:
@Mvc.RazorTools.BundleManager.Styles.Render()
and this line at the botton of the layout page (or the specific view you are using the charts in).
@Mvc.RazorTools.BundleManager.Scripts.Render()
Render a simple chart in your view with the following code:
@Html.MorrisChart(new RazorBarChart("monthlyPrecipitation")
{
    DataUrl = this.Url.Action("MonthlyPrecipitation", "Home"),
    XKey = "month",
    YKeys = new string[] { "avg", "rec", "actual" },
    Labels = new string[] { "Average", "Record", "Actual" },
    GridTextSize = gridTextSize,
    BarColors = colors
})
Add the data to the Home controller as shown below:

public JsonResult MonthlyPrecipitation()
{
    object data = new object[]
            {
                new {month = "January", avg = 2.06, rec = 6.09, actual = 3.18},
                new {month = "February", avg = 1.94, rec = 6.77, actual = 2.57},
                new {month = "March", avg = 2.72, rec = 5.77, actual = 2.22},
                new {month = "April", avg = 3.64, rec = 7.74, actual = 7.95},
                new {month = "May", avg = 4.13, rec = 7.68, actual = 6.47},
                new {month = "June", avg = 4.06, rec = 9.53, actual = 3.12},
                new {month = "July", avg = 4.01, rec = 10.39, actual = 2.19},
                new {month = "August", avg = 3.99, rec = 9.23, actual = 2.52},
                new {month = "September", avg = 3.31, rec = 11.15, actual = 1.93},
                new {month = "October", avg = 3.24, rec = 11.70, actual = 5.69},
                new {month = "November", avg = 3.42, rec = 8.08, actual = 2.94},
                new {month = "December", avg = 2.57, rec = 7.51, actual = 1.54}
            };

    return Json(data, JsonRequestBehavior.AllowGet);
}