我找到了这个 Angular Directive(指令) Directive
但是当我创建两个相同的图表时它崩溃了,并且我无法添加图表。
问题是该指令生成随机 id 。
有没有办法直接在作用域中写入?
谢谢!
更新(1)
我有一个图表数组: 例如
$scope.charts = [
{
name:"Simple Pie Chart",
image:"/theme2/assets/img/widget2.png",
"struct":{
"type": "pie",
"balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>",
"titleField": "category",
"valueField": "column-1",
"allLabels": [],
"balloon": {},
"titles": [],
"data": [
{
"category": "category 1",
"column-1": 8
},
{
"category": "category 2",
"column-1": 6
},
{
"category": "category 3",
"column-1": 2
}
]
}
}
当用户选择其中一个图表时,我将其添加到变量中 ->
$scope.items.push(data.item); //chart selected
然后在 html 中我用
显示选定的图表
Directive :
<div ng-repeat="graph in items">
<amchart ng-model="graph" >
</amchart>
</div>
最佳答案
我猜 ng-repeat
正在崩溃,因为重复的项目......而不是图表
尝试 ng-repeat="graph in items track by $index"
这将允许您在转发器中拥有重复的对象。
关于javascript - Amcharts Angular Directive(指令),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35404825/