Angular.js directives for d3.js and nvd3.js
View the Project on GitHub cmaurer/angularjs-nvd3-directives
Events exposed by nvd3.js and d3.js are re-emitted from the directives as scope events ($scope.$emit). Events are re-emitted with the same names as the underlying framework with the addition on ‘.directive’. Using duplicate names overrides existing events.
If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. To register multiple listeners for the same event type, the type may be followed by an optional namespace, such as “click.foo” and “click.bar” From d3.js wiki
To capture exposed events, add a listener for the event(s) of interest using scope $on
method.
The directives will re-emit an event usingt the events original name, plus .directive
on the end.
For example, all nvd3 tooltipShow
events are re-emitted as tooltipShow.directive
. Hovering over the chart will cause the tooltipShow event to fire.
$scope.$on('tooltipShow.directive', function(angularEvent, event){
angularEvent.targetScope.$parent.event = event;
angularEvent.targetScope.$parent.$digest();
});
<div ng-controller="ExampleCtrl">
<nvd3-line-chart
data="exampleData"
id="exampleId"
interactive="true"
xAxisTickFormat="xAxisTickFormatFunction()"
showXAxis="true"
showYAxis="true">
<svg></svg>
</nvd3-line-chart>
<div><b>Point Data</b>
<div ng-repeat="point in event.point">
<div ng-bind="point"></div>
</div>
</div>
</div>
Core * render_start * render_end
Lines * Element Mouseover Tooltip * Element Mouseout Tooltip * Element Click Tooltip
Stacked * Area Click Toggle * Tooltip Show * Tooltip Hide
Interactive Layer * Element Mouseout * Element Mousemove
Discrete Bar * Element Mouseover Tooltip * Element Mouseout Tooltip
Multibar * Element Mouseover Tooltip * Element Mouseout Tooltip * Element Click
Pie * Element Mouseover Tooltip * Element Mouseout Tooltip
Scatter * Element Mouseover Tooltip * Element Mouseout Tooltip
Bullet * Element Mouseover Tooltip * Element Mouseout Tooltip
Legend * State Change Legend * Legend Click
tooltipShow.directive
$scope.$on('tooltipShow.directive', function(angularEvent, event){
});
tooltipHide.directive
$scope.$on('tooltipHide.directive', function(angularEvent, event){
});
beforeUpdate.directive
$scope.$on('beforeUpdate.directive', function(angularEvent, event){
});
stateChange.directive
$scope.$on('stateChange.directive', function(angularEvent, event){
});
changeState.directive
$scope.$on('changeState.directive', function(angularEvent, event){
});
elementMouseover.tooltip.directive
$scope.$on('elementMouseover.tooltip.directive', function(angularEvent, event){
});
elementMouseout.tooltip.directive
$scope.$on('elementMouseout.tooltip.directive', function(angularEvent, event){
});
elementClick.directive
$scope.$on('elementClick.directive', function(angularEvent, event){
});
areaClick.toggle.directive
$scope.$on('areaClick.directive', function(angularEvent, event){
});
elementMouseout.directive
$scope.$on('elementMouseout.directive', function(angularEvent, event){
});
elementMousemove.directive
$scope.$on('elementMousemove.directive', function(angularEvent, event){
});
stateChange.legend.directive
$scope.$on('stateChange.legend.directive', function(angularEvent, event){
});
legendClick.directive
$scope.$on('legendClick.directive', function(angularEvent, event){
});