Action that mounts the Chart:
public ActionResult GraficoPedidos()
{
int [] arrayP = new int[12];
int aux = 0;
for(int i = 1;i <= 12;i++)
{
int numero = Convert.ToInt32(context.Pedidos.Count(p => p.DataPedido.Month == i && p.DataPedido.Year == DateTime.Now.Year));
arrayP[aux] = numero;
aux++;
}
var grafico = new Chart(1000, 400, theme: ChartTheme.Yellow);
grafico.AddTitle("Pedidos " + DateTime.Now.Year);
grafico.AddLegend("Pedidos");
grafico.AddSeries(
name: "Número de Pedidos",
chartType: "column",
xValue: new[] { "Jan", "Fev", "Mar", "Abr", "Mai", "Jun","Jul","Ago","Set","Out","Nov","Dez" },
yValues: new[] { arrayP[0], arrayP[1], arrayP[2], arrayP[3], arrayP[4], arrayP[5],arrayP[6],arrayP[7],arrayP[8],arrayP[9]
,arrayP[10],arrayP[11]});
return File(grafico.GetBytes("png"), "images/png");
}
Part of the VIEW where I display the Chart:
<fieldset>
<legend>Números de Pedidos em @DateTime.Now.Year</legend>
<div style="">
<img src="@Url.Action("GraficoPedidos")" />
</div>
</fieldset>
I see a Chart in my application ... that when running local it appears normal:
WhenIruntheapplicationontheserver:
Errordisplayedinbrowser:
Continuetheerror:
Does anyone have any idea what it might be?