0
I have a Controller that generates a list of Graphs as you can see below:
[EXEMPLO DE DADOS]
Pergunta: Estrutura
Dados: [1, 3]
       [2, 5]
       [3, 1]
       [4, 0]
       [5, 10]
Pergunta: Organização
Dados: [1, 2]
       [2, 0]
       [3, 3]
       [4, 2]
       [5, 7]
public class Grafico
{
    public string Pergunta { get; set; }
    public Dictionary<int, int> Dados { get; set; }
}
[Controller]
public ActionResult Grafico()
{
    List<Grafico> graficos = GeraGraficos(modulo, satisfacao);          
    return View(graficos);
}
To display in View I can display like this:
[View]
@foreach (var grafico in model)
{
    <h2>@grafico.Pergunta</h2>
    foreach (var dados in grafico.Dados)
    {
        <label><b>@dados.Key - </b> @dados.Value</label><br />
    }
}
But I needed to convert this list of charts into a Javascript array in order to display this data in graph.
Example how I would need:
var data = [
            { label: "1",  data: 3},
            { label: "2",  data: 5},
            { label: "3",  data: 1},
            { label: "4",  data: 0},
            { label: "5",  data: 10},
        ];
it would not be better to use a Jsonresult instead of Actionresult?
– Tobias Mesquita