Created
January 21, 2011 22:21
-
-
Save azcoov/790542 to your computer and use it in GitHub Desktop.
Renders a Google Chart Sparkline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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