3

I have created simple discrete BAR CHART using nvd3.js charting library. And am succeeded in running it through my browser(discretebarchart.html from NVD3 chart examples).Now I am trying to construct the same discrete bar chart with NODE.js. But i am unable to load the nvd3 library source modules in my nodejs server, since it isn't in NPM.

Can any one clarify me how to load NVD3 modules and generate NVD3 charts using Node js? There is no packages for NVD3 module in Node js. As Node js having packages for D3.js

d3 = npm install d3;

Your help regarding NVD3 and Node js would be great !

0

3 Answers 3

0

You have to download nv.d3.js and then include it in your project. You didn't say how you are serving pages with Node.js. If you are serving separate html files, you could include it in the relevant file with a typical script tag. This question suggests other node-like ways of pulling plain js files into a node project.

However, nvd3 appears to depend on the window object, which is where I'm currently stuck. Best of luck!

0

Now there is a package for NVD3: https://www.npmjs.com/package/nvd3

0

I use nvd3. I download the lib and then I added the lib to my assets folder and include the lib file in my routes file. Then i can use directly on my controller using

dashboardController:

 var app = angular.module('dashboard.controller',['nvd3','ui.bootstrap','ui.utils']);

routes file:

.state('app.dashboard', {
          url: '/dashboard',
          templateUrl: 'app/components/dashboard/dashboardView.html',
          data: {
            title: 'Dashboard',
          },       
          resolve: {
            deps: ['$ocLazyLoad', function ($ocLazyLoad) {
              return $ocLazyLoad.load([
                {
                  insertBefore: '#load_styles_before',
                  files: [
                    'assets/libs/nvd3/nv.d3.min.css',
                    'assets/libs/datatables/css/jquery.dataTables.css' ]
                },{
                  name: 'nvd3',
                  serie: true,
                  files: [
                    'assets/libs/d3/d3.min.js',
                    'assets/libs/nvd3/nv.d3.min.js',
                    'assets/libs/angular-nvd3/angular-nvd3.min.js',
                    'assets/libs/datatables/js/jquery.dataTables.js',
                    'assets/libs/bootstrap-datatables/bootstrap-datatables.js',
                    'app/components/dashboard/warning.js',
                    'assets/libs/moment/moment.min.js'                    
                  ]
                }
              ]).then(function () {
                return $ocLazyLoad.load('app/components/dashboard/dashboardController.js');
              });
            }]
          }
        })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.