Watch this example on YouTube
1. Add to Home Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Web.Helpers;
namespace WebApplication3.Controllers
{
public class HomeController : Controller
{
public ActionResult ChartWithMultipleValues()
{
Chart key = new Chart(width: 500, height: 500)
.AddTitle("Employee Chart")
.AddLegend("Some legend")
.SetYAxis("Percentage Value", 0, 100)
.AddSeries(
chartType: "Column",
name: "January",
xValue: new[] { "Bob", "Ivan", "Frank", "Anna" },
yValues: new[] { "33", "44", "22", "88" }
)
.AddSeries(
name: "February",
yValues: new[] { "99", "78", "88", "33" }
);
return File(key.ToWebImage().GetBytes(), "image/jpeg");
}
2. View
@{
ViewBag.Title = "Home Page";
}
<img src="@Url.Action("ChartWithMultipleValues")" />
No comments:
Post a Comment