我正在尝试使用带有highchart的条形图显示报告。您可以在mycontroller中看到我有:
var q =
_iTrafficRepository.Get()
.AsEnumerable().GroupBy(i => i.SubmitDateTime.Date)
.Select(g => new {date= g.Key, count = g.Count()}).ToArray();
Highcharts chartTraffcBarDatetime = new Highcharts("chart1")
.SetSeries(new Series
{
Type = ChartTypes.Bar,
Name = "Browser share",
Data = new Data(q)
});
ViewBag.ChartTraffic = chartTraffc;
ViewBag.chartTraffcBarDatetime = chartTraffcBarDatetime;
return View();
在视图中我使用了这段代码:
DotNet.Highcharts.Highcharts chartTraffcBarDatetime = ViewBag.chartTraffcBarDatetime;
<div style="direction: ltr">@(chartTraffcBarDatetime)</div>
但结果是:
答案 0 :(得分:1)
要在视图中访问“chartTraffcBarDatetime”变量,您需要使用大括号@ {}而不是paranentheses @()......
试试这个:
DotNet.Highcharts.Highcharts chartTraffcBarDatetime = ViewBag.chartTraffcBarDatetime;
<div style="direction: ltr">@{chartTraffcBarDatetime}</div>