using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.UI;
public class StackedBarGraph
{
public ActionResult CreateStackedBarGraph()
{
//Using Web Helpers Chart methods
// chartType: StackedBar, StackedColumn, etc
//Writing this because no documentation or code samples on how to pass multiple values for x and y exist
var key = new Chart(width: 300, height: 200, theme: ChartTheme.Green).AddTitle("Stacked bar demo")
.AddSeries
(
chartType: "StackedBar",
legend: "Item1",
xValue: new[] { "2012", "2013", "2014", "2015"},
yValues: new [] {34, 50, 10, 25}
)
.AddSeries(
chartType:"StackedBar",
xValue: new[] { "2012", "2013", "2014", "2015" },
yValues: new [] {12,54,85,3}
)
.AddSeries(chartType: "StackedBar",
xValue: new[] {"2012", "2013", "2014", "2015"},
yValues: new [] {15, 5, 74, 32}
);
return File(key.ToWebImage().GetBytes(), "image/jpeg");
}
}
}