asp.net - amCharts with Angularjs showing undefined object in the value field of the chart -
i new both angularjs , amcharts. trying sending data in json controller (asp.net core). data sent angularjs controller suppose create basic chart using amcharts.
in category field of chart getting "undefined" written instead of names of countries. code seems running fine cannot find error. following code.
the following class , controller sending data written in asp.net core.
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); }
the following angularjs controller.
var myapp = angular.module("main", []);
myapp.controller("mycontroller", function ($scope,$http) {
$http({ method: "get", url: "/chart/charts_json" }).then(function mysuccess(response) { chartdata = response.data; var chart = new amcharts.amserialchart(); chart.dataprovider = response.data; chart.categoryfeild = "country"; var graph = new amcharts.amgraph(); graph.valuefield = "visits"; chart.addgraph(graph); chart.write('chartdiv'); });
});
the following view code (mvc asp.net core).
@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 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>
the following screenshot of output getting enter image description here
chart.categoryfeild = "country";
categoryfeild
not valid amcharts property.
if literally how spelling property, can edit column chart on amcharts website , reproduce same undefined
column names generating using categoryfeild.
instead, please try replacing categoryfeild
categoryfield
.
https://docs.amcharts.com/3/javascriptstockchart/amserialchart#categoryfield
Comments
Post a Comment