Skip to content

Instantly share code, notes, and snippets.

@azcoov
Created January 21, 2011 22:21
Show Gist options
  • Save azcoov/790542 to your computer and use it in GitHub Desktop.
Save azcoov/790542 to your computer and use it in GitHub Desktop.
Renders a Google Chart Sparkline
namespace Sparkline.Helpers
{
public static class ChartHelper
{
public static String DrawSparkline(this HtmlHelper helper, String display, List<Int32?> plotData)
{
int? max = plotData.Max();
int? min = plotData.Min();
string list = String.Join(",", plotData);
String spark = "<img src=\"http://chart.apis.google.com/chart?cht=lc&chf=bg,s,F5F5F5&cgh=0,50,1,0&chds={0},{1}&chs={2}&chd=t:{3}&chco=999999&chls=1,1,0&chm=o,990000,0,20,4&chxt=r,x,y&chxs=0,990000,11,0,_|1,990000,1,0,_|2,990000,1,0,_&chxl=0:|{4}|1:||2:||\">";
return String.Format(spark, min, max, display, list, plotData.Last());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment