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

defaultDataStructure can be overidden #28

Merged
merged 5 commits into from
Mar 28, 2015
Merged
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sudo: false

cache:
directories:
- node_modules
- "/home/travis/.local"

before_install:
- "npm config set spin false"
Expand Down
15 changes: 9 additions & 6 deletions app/components/chartist-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import Ember from 'ember';

// This is a custom "undefined", just a safety measure to make sure someone else
// doesn't override undefined.
var UNDEF,
// This is the structure that chartist is expecting
defaultDataStructure = {labels: [], series: []};
var UNDEF;

export default Ember.Component.extend({
chart: UNDEF,

// This is the structure that chartist is expecting, it can be overidden in
// your components which extend this one.
defaultDataStructure: { labels: [], series: [] },

classNameBindings: ['ratio'],
classNames: ['ct-chart'],

Expand Down Expand Up @@ -42,17 +44,18 @@ export default Ember.Component.extend({
return this.get('type').capitalize();
}.property('type'),

data: defaultDataStructure,
data: null,
options: UNDEF,
responsiveOptions: UNDEF,
updateOnData: true,

// This is where the business happens. This will only run if checkForReqs
// doesn't find any problems.
renderChart: function () {
var data = this.get('data') || this.get('defaultDataStructure');
var chart = new Chartist[this.get('chartType')](
this.get('element'),
this.get('data'),
data,
this.get('options'),
this.get('responsiveOptions')
);
Expand Down
10 changes: 5 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"ember-resolver": "~0.1.11",
"loader.js": "stefanpenner/loader.js#1.0.1",
"ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.1.3",
"ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2",
"ember-qunit": "0.1.8",
"ember-qunit-notifications": "0.0.4",
"qunit": "~1.15.0"
"ember-qunit": "~0.3.0",
"ember-qunit-notifications": "~0.0.7",
"qunit": "~1.17.1"
},
"devDependencies": {
"chartist": "~0.5.0"
"chartist": "~0.7.3"
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
"ember-cli-esnext": "0.1.1",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.1.2",
"ember-cli-qunit": "~0.3.9",
"ember-cli-sass": "3.0.3",
"ember-data": "1.0.0-beta.12",
"ember-export-application-global": "^1.0.0",
"express": "^4.8.5",
"glob": "^4.0.5"
"glob": "~4.0.5",
"rimraf": "~2.2.8"
},
"keywords": [
"ember-addon",
Expand Down
25 changes: 25 additions & 0 deletions tests/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ import {

setResolver(resolver);


// This is to save PhantomJS from itself, because PhantomJS < 2.0 doesn't have
// Function.prototype.bind for _reasons_
if (!Function.prototype.bind) {
Function.prototype.bind = function(oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}

var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
FNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof FNOP && oThis? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
};

FNOP.prototype = this.prototype;
fBound.prototype = new FNOP();

return fBound;
};
}


document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>');

QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'});
Expand Down
Loading