0
렌더링 된지도 차트의 데이터 값을 업데이트하려고합니다. jquery 플러그인 인 jVectorMap을 사용합니다.AngularJs jquery plugin지도 차트 데이터 업데이트
문제는 데이터 집합을 업데이트하려고 할 때 이전 차트 바로 다음에 DOM에 새 차트가 추가된다는 것입니다.
Plunkr : http://plnkr.co/edit/eTyLpb3dAJf3AAmjrqDX?p=preview
app.directive('map', function() {
return {
restrict: 'EAC',
link: function(scope, element, attrs) {
scope.$watch("mapdata" , function(n,o){
$(element).width('auto')
$(element).height(400)
$(element).vectorMap({
backgroundColor: 'transparent',
regionStyle: {
initial: {
fill: '#cccccc'
}
},
series: {
regions: [{
values: scope.mapdata,
scale: ['#C8EEFF', '#0071A4'],
normalizeFunction: 'polynomial'
}]
},
});
});
}
};
});
또 다른 방법이 될 수있다 :
app.directive('map', function() {
return {
restrict: 'EAC',
link: function(scope, element, attrs) {
var chart = null;
var data = scope.datamap;
scope.$watch("data" , function(n,o){
if(!chart){
$(element).width('auto')
$(element).height(400)
chart = $(element).vectorMap({})
}else{
chart.vectorMap('set', 'colors', {us: '#000000'});
console.log(chart)
}
});
}
};
});
Plunkr : 나는 배경색이 아닌 상태의 색상을 변경할 수 있습니다이 방법으로 http://plnkr.co/edit/ib3Rgz?p=preview
.. .
잘 모르겠어요 ... 나는 plunkr 업데이트되었습니다 (http://plnkr.co/edit/ib3Rgz?p=preview), 다른 접근 방식을 시도 기반으로 이 기사 http://eric-schaefer.com/blog/2013/07/26/rendering-flot-charts-through-angular-js/ – Tropicalista
@jojo 옵션 2로 Plunkr을 게시 할 수 있습니까? – Jago