I have been working with charts today And I think that i finaly found a way for it all to work but I encountered an issue that I don't know how to pass.
Create my Charts in my controller:
foreach (var m in model[0].HistoryValues)
{
var chart = new Chart(width: 300, height: 200)
.AddSeries(
chartType: "bar",
xValue: new[] { "Server", "Db", "Tickets" },
yValues: new[] { m.ServerPerformance, m.Databaseperformance, m.SoldTicketsLastUpdate })
.GetBytes("png");
m.Bytes = chart;
//m.ChartFile = File(chart, "image/bytes");
};
now I want to display them as Images in the view:
@foreach (var m in Model[0].HistoryValues)
{
<img src="@Html.Action("getImage", "OverWatch", new { byte[] Mybytes= m.Bytes })" alt="Person Image" />
}
but im getting:
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
getImage method:
public FileContentResult getImage(byte[] bytes)
{
return new FileContentResult(bytes, "image/jpeg");
}
How do I solve this?
In an anonymous type you dont define the variable type byte[]. It works it out itself based on the type of m.Bytes
@foreach (var m in Model[0].HistoryValues)
{
<img src="@Html.Action("getImage", "OverWatch", new { Mybytes= m.Bytes })" alt="Person Image" />
}