This way
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-sparklines/2.1.2/jquery.sparkline.min.js"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "POST",
url: "CS.aspx/GetData",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response.d);
$("#linechart-2").sparkline(response.d, {
type: "line",
width: "100%",
height: "226",
lineColor: "#a5e1ff",
fillColor: "rgba(241, 251, 255, 0.9)",
lineWidth: 2,
spotColor: "#a5e1ff",
minSpotColor: "#bee3f6",
maxSpotColor: "#a5e1ff",
highlightSpotColor: "#80cff4",
highlightLineColor: "#cccccc",
spotRadius: 6,
chartRangeMin: 0
});
}
});
});
</script>
<div id = "linechart-2"></div>
Code
[System.Web.Services.WebMethod]
public static int[] GetData()
{
return new int[] { 160, 240, 250, 280, 300, 250, 230, 200, 280, 380, 400, 360, 300, 220, 200, 150, 100, 100, 180, 180, 200, 160, 220, 140 };
}
Screenshot
