Dom
Dom

Reputation: 404

How to include chart js annotations in ember?

I am trying to include this annotation in my project in ember, this is th link to the plugin https://www.npmjs.com/package/chartjs-plugin-annotation. I tried

npm i chartjs-plugin-annotation

but still no luck, i tried this also

npm i chartjs-plugin-annotation --save

Is there another way to incude this plugin in ember?

Upvotes: 1

Views: 448

Answers (2)

Ramil Gilfanov
Ramil Gilfanov

Reputation: 602

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'

Upvotes: 0

ykaragol
ykaragol

Reputation: 6221

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.

Upvotes: 3

Related Questions