Sory my bad english.
I'm trying make a grafic with Morris.js, i'm using the line Chart and wanna make it with dynamic data, but when I will convert my array to a JsonString, it's broke my aplication, I already try some sollutions on internet like this and
others, but not sucess
when I convert the Array to Json the console show :
VM13133:1 Uncaught SyntaxError: Unexpected end of JSONinput(…)
executeMorrisGrafics @
dashboard_1Mensal.controller.js:44initController @
dashboard_1Mensal.controller.js:26(anonymous function) @
dashboard_1Mensal.controller.js:16
my code is this
[...]
function executeMorrisGrafics(startDate, endDate){
RequestService.getReturnMalingResult(startDate, endDate).then(function(data){
var array = [];
for(var i=0;i<data.listLineChartEmailSms.length;i++){
array.push({
y: data.listLineChartEmailSms[i.toString()].y,
a: data.listLineChartEmailSms[i.toString()].a,
b: data.listLineChartEmailSms[i.toString()].b
});
}
dataJson = array; //dataJson is a global Var
});
console.log(dataJson);//working until here
var result = JSON.parse(dataJson.toString());//here is the problem
Morris.Line({
element: 'grafic-LineChart1',
data: result,
xkey: 'y',
ykeys: ['a', 'b'],
labels: ['Series A', 'Series B']
});
[...]
Thank you