0
I’m new around here, I’m trying to consume Razor data inside a js file. From what I understand the two languages do not communicate so I would need an alternative that does intermediation, taking the data from Razor to javascript, but I do not know how to apply it.
My script:
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
Function drawChart(data) {
if (dados === undefined)
dados = "**@Html.Raw(Model.GraficoColaboradores.JsonDados)**";
var obj = eval(dados);
var data = new google.visualization.DataTable();
data.addColumn('string', 'Unidades');
data.addColumn('number', 'Colaboradores');
data.addRows(obj);
var options = {
chartArea: {
'width': '80%',
'height': '80%'
},
legend: { position: "none" },
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}