[Chartjs]-How to include chart js annotations in ember?

3👍

You can include it as bower dependency with bower install command.

After including it to the project,In ember-cli-build.js file, use app.import to add it to build as following (please check the path):

app.import('bower_components\chartjs-plugin-annotation\chartjs-plugin-annotation.min.js');

If you don’t want to use bower and if you prefer npm, then have a look at broccoli family. It is a bit long way.

0👍

add npm package

ember install ember-auto-import

ember-cli-build.js

/* eslint-env node */
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
  let app = new EmberApp(defaults, {
    autoImport: {
      alias: {
        'chartjs-plugin-datalabels': 'chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.js',
      },
    }
  });
  return app.toTree();
};

import in component-name.js

import 'chartjs-plugin-datalabels'

Leave a comment