Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It is possible to add a directives to code generated by <code>d3</code>, only thing you need to ensure is that you call the <a href="http://docs.angularjs.org/api/ng.%24compile"><code>$compile</code></a> service on the content after it has been rendered.</p> <p>For the given example, it would look something like this:</p> <pre class="lang-js prettyprint-override"><code> .directive('barChart', function($compile){ // inject $compile var chart = d3.custom.barChart(); return { restrict: 'E', replace: true, template: '&lt;div class="chart"&gt;&lt;/div&gt;', scope:{ height: '=height', data: '=data', hovered: '&amp;hovered' }, link: function(scope, element, attrs) { var chartEl = d3.select(element[0]); chart.on('customHover', function(d, i){ scope.hovered({args:d}); }); scope.$watch('data', function (newVal, oldVal) { chartEl.datum(newVal).call(chart); $compile(element.contents())(scope); // &lt;-- call to $compile }); scope.$watch('height', function(d, i){ chartEl.call(chart.height(scope.height)); $compile(element.contents())(scope); // &lt;-- call to $compile }) } } </code></pre> <p>And in the <code>d3</code>'s drawing function:</p> <pre class="lang-js prettyprint-override"><code> bars.enter().append('rect') .classed('bar', true) .attr('myPopover', 'Text to show') // &lt;-- Adding an attribute here. .attr({x: chartW, width: barW, y: function(d, i) { return y1(d); }, height: function(d, i) { return chartH - y1(d); } }) .on('mouseover', dispatch.customHover); </code></pre> <p><a href="http://plnkr.co/edit/5KYvxi?p=preview"><kbd>Demo</kbd></a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload