Skip to content

Commit

Permalink
fix charts
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Mar 4, 2021
1 parent d4d3d09 commit 7a5317d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
5 changes: 1 addition & 4 deletions addon/components/charts/-components/axis/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Component from '@ember/component';
import Component from '@glimmer/component';

/** @documenter yuidoc */
/**
Expand All @@ -10,9 +10,6 @@ import Component from '@ember/component';
@public
**/
class ChartAxis extends Component {
tagName = '';
chart = null;

args = {
/**
* The Axis Title
Expand Down
8 changes: 3 additions & 5 deletions addon/components/charts/-components/chart/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Chart from '@carbon/charts/chart';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { throttle } from '@ember/runloop';
Expand All @@ -17,7 +16,6 @@ import { defaultArgs } from '../../../../decorators';
@yield {Component} api.Axis <a href='-components/axis' >ChartAxis</a>
**/
class CarbonChart extends Component {
tagName = '';
data = {
labels: [],
datasets: []
Expand Down Expand Up @@ -65,10 +63,10 @@ class CarbonChart extends Component {


async setData() {
const labels = this.componentArgs.labels;
const labels = this.args.labels;
this.data.labels = Array.isArray(labels) ? labels : labels.split(',');
this.options.legendClickable = this.componentArgs.legendClickable;
this.options.containerResizable = this.componentArgs.resizable;
this.options.legendClickable = this.args.legendClickable;
this.options.containerResizable = this.args.resizable;
if (!this.data.datasets.length) return;
if (!this.options.axes.left) return;
if (!this.options.axes.bottom) return;
Expand Down
16 changes: 10 additions & 6 deletions addon/components/charts/-components/dataset/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultColors } from '@carbon/charts';
import Component from '@ember/component';
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { argsCompat } from 'carbon-components-ember/decorators';

Expand All @@ -13,7 +13,6 @@ import { argsCompat } from 'carbon-components-ember/decorators';
@public
**/
class CarbonChartDataSet extends Component {
tagName = '';
chart = null;
defaultColor = [defaultColors[0]];

Expand All @@ -34,21 +33,26 @@ class CarbonChartDataSet extends Component {
* @argument data
* @type number[]
*/
data: []
data: [],

/**
* @internal
*/
chart: null
};

@action
didUpdateArgs() {
if (this.oldDabel && this.oldDabel !== this.args.label) {
this.chart.removeDataset(this.oldLabel);
this.args.chart.removeDataset(this.oldLabel);
this.oldLabel = this.args.label;
}
this.chart.updateDataset(this.args.label, this.args.backgroundColors || this.defaultColor, this.args.data);
this.args.chart.updateDataset(this.args.label, this.args.backgroundColors || this.defaultColor, this.args.data);
}

willDestroy() {
super.willDestroy();
this.chart && this.chart.removeDataset(this.oldLabel);
this.args.chart && this.args.chart.removeDataset(this.oldLabel);
}
}

Expand Down
4 changes: 1 addition & 3 deletions addon/components/charts/bar/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SimpleBarChart } from '@carbon/charts';
import Component from '@ember/component';
import Component from '@glimmer/component';

/** @documenter yuidoc */

Expand All @@ -13,8 +13,6 @@ import Component from '@ember/component';
@yield {Component} api.Axis <a href='-components/axis' >ChartAxis</a>
**/
class CarbonBarChart extends Component {
tagName = '';

ChartClass = SimpleBarChart;
args = {
/**
Expand Down
5 changes: 2 additions & 3 deletions addon/components/charts/line/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LineChart} from '@carbon/charts';
import Component from '@ember/component';
import { LineChart } from '@carbon/charts';
import Component from '@glimmer/component';

/**
The CarbonLineChart
Expand All @@ -11,7 +11,6 @@ import Component from '@ember/component';
@yield {Component} api.Axis <a href='-components/axis' >ChartAxis</a>
**/
class CarbonLineChart extends Component {
tagName = '';
ChartClass = LineChart;
args = {
/**
Expand Down
1 change: 0 additions & 1 deletion addon/decorators/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { computed } from '@ember/object';
import GlimmerComponent from '@glimmer/component';

export function classPrefix(prefix) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.16",
"version": "0.3.17",
"name": "carbon-components-ember",
"keywords": [
"ember-addon"
Expand Down

0 comments on commit 7a5317d

Please sign in to comment.