我非常新的angularjs和海军报图。 我想点击的事件添加到我的堆积条形图所以,一旦我点击它显示的类别信息的堆栈,但我不知道如果我这样做是正确的。 请帮忙看看
我已经画出我的angularjs指示图
看到http://jsfiddle.net/6h1gL2sh/10/这里
App.directive('chart', function () {
return {
restrict: 'EA',
link: function (scope, elem, attrs) {
var chart = null,
options = {
series: {
stack: true,
bars: {
show: true,
clickable: true,
barWidth: 0.1,
align: "center"
}
},
axisLabels: {
show: true
},
xaxis: {
axisLabel: 'Products',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 5,
mode: "categories",
tickLength: 0
},
yaxis: {
axisLabel: 'Pass/Fail Count',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelPadding: 5
},
grid: {
hoverable: true,
clickable: true
}
}
var data = scope[attrs.ngModel];
scope.$watch(attrs.ngModel, function (v) {
if (!chart) {
chart = $.plot(elem, v, options);
elem.show();
} else {
chart.setData(v);
chart.setupGrid();
chart.draw();
}
});
$(elem).bind("plotclick", function (event, pos, item) {
scope.$apply(function () {
if (item) {
scope.dis = item.series.xaxis.categories[item.dataIndex].label
}
});
});
}
};
});