ember-cli-chartist
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -6,3 +6,5 @@ import Ember from 'ember'; | ||
// doesn't override undefined. | ||
var UNDEF; | ||
var UNDEF, | ||
// This is the structure that chartist is expecting | ||
defaultDataStructure = {labels: [], series: []}; | ||
@@ -44,4 +46,3 @@ export default Ember.Component.extend({ | ||
data: UNDEF, | ||
data: defaultDataStructure, | ||
options: UNDEF, | ||
@@ -74,21 +75,12 @@ responsiveOptions: UNDEF, | ||
// Do some checking on the provided–or not provided–data attribute. | ||
if (!data) { | ||
throw new Error('The "data" attribute is required on chartist-chart.'); | ||
} else { | ||
if (typeof data === 'string') { | ||
throw new Error('The value of the "data" attribute on chartist-chart should be an object, it\'s a string.'); | ||
} | ||
if (typeof data === 'string') { | ||
console.info('Chartist-chart: The value of the "data" attribute on should be an object, it\'s a string.'); | ||
this.set('data', defaultDataStructure); | ||
} | ||
// Make sure the type attribute has a quoted value. It's a common mistake | ||
// to forget to. | ||
if (!type) { | ||
throw new Error('If you\'re providing a "type" attribute on chartist-chart, make sure it\'s a string.'); | ||
} else { | ||
if (!Chartist[this.get('chartType')]) { | ||
throw new Error('Invalid "type" attribute to chartist-chart. It can be; "bar", "line", or "pie".'); | ||
} | ||
if (!type || !Chartist[this.get('chartType')]) { | ||
console.info('Chartist-chart: Invalid or missing "type" attribute, defaulting to "line".'); | ||
this.set('type', 'line'); | ||
} | ||
}.on('init') | ||
}); |
{ | ||
"name": "ember-cli-chartist", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Ember Addon for Chartist.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
# Chartist.js for Ember-CLI Projects | ||
[![Build Status](https://travis-ci.org/tylergaw/ember-cli-chartist.svg?branch=v0.2.2)](https://travis-ci.org/tylergaw/ember-cli-chartist) | ||
This is an ember-cli wrapper for [Chartist](https://github.com/gionkunz/chartist-js). | ||
@@ -4,0 +6,0 @@ It allows you to render Chartist charts in your templates using components. |
@@ -38,2 +38,11 @@ /* global Ember */ | ||
test('it should not error when the data property or attribute is not provided', function() { | ||
expect(1); | ||
var component = this.subject(); | ||
this.append(); | ||
equal(component._state, 'inDOM'); | ||
}); | ||
test('it can be a line chart', function() { | ||
@@ -40,0 +49,0 @@ expect(1); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
147423
172
2889