List<DataSource> data1 = new List<DataSource>();
data1.Add(new DataSource() { x = 0, y1 = 0, y2 = 1 });
// Add more data
ViewBag.data = data1;
ViewBag.Colors = new string[] { "#3D78EF", "green" };
function loadComplete(args) {
setTimeout(function() {
for (var i = 1; i < 3; i++) {
line = new ej.charts.Sparkline({
height: '50px',
width: '150px',
valueType: 'Numeric',
xName: 'x',
yName: 'y' + i,
fill: getSparkColor(i),
dataSource: @Html.Raw(Json.Serialize(@ViewBag.data))
});
line.appendTo('#spkline' + i);
}
},
1000)
}
function getSparkColor(count) {
var colors = @Html.Raw(Json.Serialize(@ViewBag.Colors));
return colors[count - 1];
} |