javascript - Integrating Angular-js with D3 library -


I am trying to create a demo app to integrate with it, I defined it on

Method is implemented:

Project Structure

Main app .js

  'strict use'; // The name of the app is Angelor 3 Angeller. Modules ('Anxicardi 3', ['Anti Dzire Controllers', 'Engineering 3 Directives']); // Setup dependency injection angular.module ('d3Service', []); // This is the service method for obtaining the D3 library angular. Module ('Someone D3 Controllers', []); Angular Module ('angel d3di andeve', ['d3 service']); // Pass D3 service for D3 Directive  

index.html

   

Controller. Js is

  'strict experiment'; Controller ('Democron', ['$ Scope', Function ($ Range) {$ scope.title = "DemoCtrl"; $ scope.data = [{Name: "Greg", Score: 98}, {Name: "Erie ", Score: 96}, {name:" loser ", score: 48}] $ scope.d3OnClick = function ({warning (" item.name ");};}]);  
  • The problem can not be displayed on the screen, what is the reason?

    Please explain the solution code, because I'm new to angular, if you want any other part of the code, please ask

    What I really miss, if If you look at the code, then I have commented index.html in d3Service.js as the DemoController and any {{Title}} can not be displayed.

  • If you are not getting the desired output, please check the browser for any errors. I executed your code and it was working as expected, you can check this Bela.

    I have created a sample instruction

      angular.module ('angularD3.directives'). Directive ('d3bars', [function] {return (limited: 'ea', replace: true, scope: {data: "="}, link: function (scope, hedgehog, ethers) {var svg = d3 Select (ele [0]) .append ('svg' '. Style (' width ',' 100% '); angular for pre (scope.data, function (item, index) {svg.append (' rect ') .attr (' height ', 20) .attr (' width ', item score) .attr (' x ', 0) .attr (' y ', 20 * index) .attr (' fill ', item .color);})}}}}});  

    If {{title}} is being displayed this way, then there is a chance that the script is not loading properly

    In any other In the case of Dde, go back.


    Comments