Intento crear un grafico de forma dinamica con el siguiente ciclo, los div me los crea dinamicamente pero el grafico no, los graficos se cargan segun el id del div creado:
Código Javascript
:
Ver originalvar k = 0;
var elementoDiv = "";
var chart = [];
$.each(Subtitles, function(index, val)
{
elementoDiv += "<div id=layout"+k+" class=F></div>";
$('div.col-md-8').eq(1).html(elementoDiv);
AmCharts.makeChart("layout"+k,
{
"type": "serial",
"pathToImages": "http://cdn.amcharts.com/lib/3/images/",
"categoryField": "category",
"columnWidth": 0.5 ,
"rotate": false,
"startDuration": 0,
"autoMargins": true,
"marginBottom": 70,
"marginLeft": 50,
"marginRight": 50,
"marginTop": 0,
"colors": [
"#BBD204","#DC606E"
],
"decimalSeparator": ",",
"categoryAxis": {
"gridPosition": "start",
"autoWrap": true,
"gridColor": "#FFFFFF",
"axisAlpha": 0,
"fontSize": 12,
},
"trendLines": [],
"graphs": [
{
"bullet": "none",
"balloonText": "[[title]] [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-1",
"labelOffset": -20,
"labelPosition": "bottom",
"labelText": "[[value]]",
"minBulletSize": 6,
"title": "6 a 7",
"type": "column",
"valueField": "column-1",
"fontSize": 14,
},
{
"bullet": "none",
"balloonText": "[[title]] [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-2",
"labelPosition": "bottom",
"labelOffset": -2,
"labelText": "[[value]]",
"title": "1 a 4",
"type": "column",
"valueField": "column-2",
"color": "#FFFFFF",
"fontSize": 14,
},
{
"id": "AmGraph-3","bullet": "round",
"bulletColor": "#003673",
"bulletSize": 10,
"labelText": "[[value]]",
"lineColor": "#088A08",
"title": "Neto",
"valueField": "column-3",
"color": "#FFFFFF",
"fontSize": 14,
"labelPosition": "bottom",
}
],
"valueAxes": [
{
"id": "ValueAxis-1",
"stackType": "regular",
"title": "",
"gridColor": "#000000",
"gridAlpha": 0,
"unit": "%",
"gridAlpha": 1,
"gridThickness": 0,
"minorGridAlpha": 1,
"labelFrequency": 1,
}
],
"balloon": {},
"legend": {
"useGraphSettings": true,
"align": "right",
"position": "top",
"fontSize": 14,
},
"titles": [
{
"id": "Title-1",
"size": 12,
"text": "titulo",
}
],
"dataProvider": [
{
"category": "201607 (N°242)",
"column-1": "38.84",
"column-2": "-42.56",
"column-3": "-3.72"
},
{
"category": "201608 (N°8)",
"column-1": "12.50",
"column-2": "-62.50",
"column-3": "-50.00"
},
]
}
);
k++;
});