У меня есть контроллер, который берет данные базы данных и возвращает json на javascript Но у меня проблема, что я не могу показать диаграмму, но не могу показать бары Я пробовал разные методы, и теперь мне нужна ваша помощь!mvc C# не удалось распечатать карту флота, данные json недействительны?
Контроллер:
foreach (Dashboard item in result)
{
DateTime kint = Convert.ToDateTime(item.date);
String dd = kint.Day.ToString();
stats.Add(new ReferralStat {data = Convert.ToInt16(item.percentage), label = "" + dd + ""});
perc.Add(new AccupancyPerc {data = Convert.ToInt16(item.percentage), label = Convert.ToInt16(dd)});
arr.Add(new Tuple<int, int>(Convert.ToInt16(dd), Convert.ToInt16(item.percentage)));
percent.Add(Convert.ToInt16(item.percentage));
json_string = json_string + "[" + dd + ", 100], ";
};
Я пытался Ретур Diferent форматы: стат/PERC/обр/процентов
return Json(stats, "application/json", JsonRequestBehavior.AllowGet);
JavaScript:
function chartWeek(placeholder) {
var chartdata = [];
$(function() {
`$`.getJSON('../../Home/WeekAccupancy', function (chart_data) {
console.log(chart_data);
$.plot(placeholder, chart_data, {
series: {
pie: {
show: true,
innerRadius: .4,
stroke: {
width: 4,
color: "#F9F9F9"
},
label: {
show: true,
radius: 3/4,
formatter: donutLabelFormatter
}
},
},
legend: {
show: true
},
grid: {
hoverable: true
},
colors: ["#7d939a", "#5399D6", "#d7ea2b"],
})
//alert(chart_data);
});
});
}
Как работает console.log (chart_data); выглядит как? – FailedUnitTest