Asp.net 带有Angularjs的amCharts在图表的值字段中显示未定义的对象
我对angularjs和amcharts都是新手。我试图做的是从一个控制器(asp.net内核)发送一些json格式的数据。数据被发送到angularjs控制器,然后假设该控制器使用amCharts创建基本图表 在图表的类别字段中,我得到的是“未定义”而不是国家名称。代码似乎运行良好,但我就是找不到错误。下面是我的代码 以下是我从中发送以asp.net core编写的数据的类和控制器。Asp.net 带有Angularjs的amCharts在图表的值字段中显示未定义的对象,asp.net,angularjs,asp.net-mvc,undefined,amcharts,Asp.net,Angularjs,Asp.net Mvc,Undefined,Amcharts,我对angularjs和amcharts都是新手。我试图做的是从一个控制器(asp.net内核)发送一些json格式的数据。数据被发送到angularjs控制器,然后假设该控制器使用amCharts创建基本图表 在图表的类别字段中,我得到的是“未定义”而不是国家名称。代码似乎运行良好,但我就是找不到错误。下面是我的代码 以下是我从中发送以asp.net core编写的数据的类和控制器。 public class tempCountry { public string
public class tempCountry
{
public string Country { get; set; }
public int Visits { get; set; }
}
[HttpGet]
public IActionResult Charts_Json()
{
List<tempCountry> tempCountry = new List<chartController.tempCountry>();
tempCountry tObj = new tempCountry();
tObj.Country = "Pakistan";
tObj.Visits = 500;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "Japan";
tObj.Visits = 1000;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "India";
tObj.Visits = 3000;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "Austrailia";
tObj.Visits = 4000;
tempCountry.Add(tObj);
return Json(tempCountry);
}
@section scripts {
<script src="~/js/amcharts/amcharts.js"></script>
<script src="~/js/amcharts/serial.js"></script>
<script src="~/lib/angular/angular.js"></script>
<script src="~/js/mainApp.js"></script>
}
<p>this is the chart view page</p>
<body>
<div ng-app="main">
<div ng-controller="myController">
</div>
</div>
<div id="chartdiv" style="width:640px; height: 480px;">
</div>
</body>
}))
以下是视图代码(MVC asp.net核心)。
public class tempCountry
{
public string Country { get; set; }
public int Visits { get; set; }
}
[HttpGet]
public IActionResult Charts_Json()
{
List<tempCountry> tempCountry = new List<chartController.tempCountry>();
tempCountry tObj = new tempCountry();
tObj.Country = "Pakistan";
tObj.Visits = 500;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "Japan";
tObj.Visits = 1000;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "India";
tObj.Visits = 3000;
tempCountry.Add(tObj);
tObj = new tempCountry();
tObj.Country = "Austrailia";
tObj.Visits = 4000;
tempCountry.Add(tObj);
return Json(tempCountry);
}
@section scripts {
<script src="~/js/amcharts/amcharts.js"></script>
<script src="~/js/amcharts/serial.js"></script>
<script src="~/lib/angular/angular.js"></script>
<script src="~/js/mainApp.js"></script>
}
<p>this is the chart view page</p>
<body>
<div ng-app="main">
<div ng-controller="myController">
</div>
</div>
<div id="chartdiv" style="width:640px; height: 480px;">
</div>
</body>
@节脚本{
}
这是图表视图页面
下面是我得到的输出的屏幕截图
图表.类别Feild=“国家”
categoryFeild
不是有效的amCharts属性
如果你是这样拼写这个属性的,
您可以在amCharts网站上编辑,并使用categoryFeild重新生成相同的未定义的列名
请尝试用类别字段
替换类别字段
图表.类别Feild=“国家”
categoryFeild
不是有效的amCharts属性
如果你是这样拼写这个属性的,
您可以在amCharts网站上编辑,并使用categoryFeild重新生成相同的未定义的列名
请尝试用类别字段
替换类别字段
天哪,我真的很惊讶!这是个错误!无论如何!谢谢你的帮助!天哪,我真的很惊讶!这是个错误!无论如何!谢谢你的帮助!