我正在尝试使用图表js在我的视图中显示来自控制器的数据;现在我只得到图表的模板,但没有数据显示。 这是控制器中的方法:
kubectl describe pod c80b7631698
Events:
Type Reason Message
---- ------ -------
Normal Pulling pulling image "gcr.io/my-api:latest"
Warning Failed Failed to pull image "gcr.io/my-api:latest": rpc error: code = Unknown desc = Error: Status 429 trying to pull repository my-api: "Quota Exceeded."
Warning Failed Error: ErrImagePull
Normal BackOff Back-off pulling image "gcr.io/my-api:latest"
Normal SandboxChanged Pod sandbox changed, it will be killed and re-created.
Warning Failed Error: ImagePullBackOff
在我的视图中我有这段代码:
public IEnumerable<DateTime> EachDay(DateTime from, DateTime thru)
{
for (var day =from.Date; day.Date <= thru.Date; day = day.AddDays(1))
yield return day;
}
public ActionResult Dashboard()
{
return View();
}
[HttpPost]
public ActionResult Dashboard(DateTime ddebut, DateTime dfin)
{
Réception_phosphateEntities db = new Réception_phosphateEntities();
List<Réception_camions> listréception = db.Réception_camions.ToList();
List<Wagons> listwg = db.Wagons.ToList();
List<Consommation> co = db.Consommation.ToList();
List<Double?> stock = new List<Double?>();
List<DateTime?> dates = new List<DateTime?>();
foreach (DateTime date in EachDay(ddebut, dfin))
{
var stk = listwg.Where(x => x.Date_culbutage <= date.Date).Select(x => x.Poids).Sum()
+ listréception.Where(x => x.Date_d_arrivée <= date.Date).Select(x => (double)x.Poids_cam).Sum()
- co.Where(x => x.Date_consommation <= date.Date).Select(x => x.Qtité_consommée).Sum();
dates.Add(date);
stock.Add(stk);
return View();
}
ViewBag.date = dates;
ViewBag.stk = stock;
return View();
}
var stock=@Html.Raw(Json.Encode(ViewBag.stk));
var dates=@Html.Raw(Json.Encode(ViewBag.date));
var ctx = $("#bar_chart");
var bacChart = new Chart(ctx,{
type: 'bar',
data: {
labels: dates,
datasets: [{
label: "bar chart example",
data: stock,
}]
}
})
我没有找到问题出在哪里,谢谢你的帮助。