Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add chart-chartjs-financial dependency resolution fix #139

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/aomran/ember-cli-chart.svg)](https://travis-ci.org/aomran/ember-cli-chart)
[![Ember Observer Score](https://emberobserver.com/badges/ember-cli-chart.svg)](https://emberobserver.com/addons/ember-cli-chart)

This Ember CLI addon is a simple wrapper for [ChartJS](http://www.chartjs.org/) (v2.9).
This Ember CLI addon is a simple wrapper for [ChartJS](http://www.chartjs.org/) (v3.5).

### Compatibility

Expand Down
25 changes: 11 additions & 14 deletions addon/components/ember-chart.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* global Chart */
import Component from '@glimmer/component';
import { action } from '@ember/object';

export default class EmberChart extends Component {
import Chart from 'chart.js/auto';

import 'chartjs-adapter-luxon';
import 'chartjs-chart-financial';

export default class EmberChart extends Component {
constructor() {
super(...arguments);

this.plugins = this.plugins || [];
}

Expand All @@ -22,26 +24,21 @@ export default class EmberChart extends Component {

@action
updateChart() {
let { chart, animate } = this.chart;
let { data, options } = this.args;

if (chart) {
chart.data = data;
chart.options = options;
if (animate) {
chart.update();
} else {
chart.update(0);
}
if (this.chart) {
this.chart.data = data;
this.chart.options = options;

this.chart.update();

if (this.customLegendElement) {
this.customLegendElement.innerHTML = chart.generateLegend();
this.customLegendElement.innerHTML = this.chart.generateLegend();
}
}
}

willDestroy() {
this.chart.destroy();
}

}
38 changes: 0 additions & 38 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,5 @@
'use strict';

const FastbootTransform = require('fastboot-transform');

module.exports = {
name: require('./package').name,
options: {
nodeAssets: {
'chart.js': {
vendor: {
srcDir: 'dist',
include: ['Chart.js'],
processTree(input) {
return FastbootTransform(input);
}
}
}
}
},
included() {
this._super.included.apply(this, arguments);
this._ensureThisImport();

this.import('vendor/chart.js/Chart.js');
},
_ensureThisImport() {
if (!this.import) {
this._findHost = function findHostShim() {
let current = this;
let app;

do {
app = current.app || app;
} while (current.parent.parent && (current = current.parent));
return app;
};
this.import = function importShim(asset, options) {
let app = this._findHost();
app.import(asset, options);
};
}
}
};
Loading