ember-cli-highcharts
Advanced tools
Comparing version 0.0.7 to 0.1.0
/** | ||
All credit to ahmadsoe for this excellent emblem-highcharts addon | ||
This is a direct fork of his work, just expanded and cleaned up for more universal use in ember-cli apps | ||
https://github.com/ahmadsoe/ember-highcharts | ||
All credit to ahmadsoe for this excellent emblem-highcharts addon | ||
This is a direct fork of his work, just expanded and cleaned up for more universal use in ember-cli apps | ||
https://github.com/ahmadsoe/ember-highcharts | ||
**/ | ||
@@ -12,82 +12,81 @@ | ||
const { | ||
computed, | ||
get, | ||
set, | ||
merge, | ||
on, | ||
observer, | ||
run | ||
computed, | ||
get, | ||
set, | ||
merge, | ||
on, | ||
observer, | ||
run | ||
} = Ember; | ||
export default Ember.Component.extend({ | ||
classNames: ['highcharts-wrapper'], | ||
content: undefined, | ||
mode: undefined, | ||
chartOptions: undefined, | ||
chart: null, | ||
theme: undefined, | ||
callback: undefined, | ||
classNames: ['highcharts-wrapper'], | ||
content: undefined, | ||
mode: undefined, | ||
chartOptions: undefined, | ||
chart: null, | ||
theme: undefined, | ||
callback: undefined, | ||
buildOptions: computed('chartOptions', 'content.@each.isLoaded', function() { | ||
let chartOptions = Ember.$.extend(true, {}, get(this, 'theme'), get(this, 'chartOptions')); | ||
let chartContent = get(this, 'content.length') ? get(this, 'content') : [{ | ||
id : 'noData', | ||
data : 0, | ||
color : '#aaaaaa' | ||
}]; | ||
buildOptions: computed('chartOptions', 'content.@each.isLoaded', function() { | ||
let chartOptions = Ember.$.extend(true, {}, get(this, 'theme'), get(this, 'chartOptions')); | ||
let chartContent = get(this, 'content.length') ? get(this, 'content') : [{ | ||
id : 'noData', | ||
data : 0, | ||
color : '#aaaaaa' | ||
}]; | ||
let defaults = { series: chartContent }; | ||
let defaults = { series: chartContent }; | ||
return merge(defaults, chartOptions); | ||
}), | ||
return merge(defaults, chartOptions); | ||
}), | ||
contentDidChange: observer('content.@each.isLoaded', function() { | ||
if (!(get(this, 'content') && get(this, 'chart'))) { | ||
return; | ||
} | ||
contentDidChange: observer('content.@each.isLoaded', function() { | ||
if (!(get(this, 'content') && get(this, 'chart'))) { | ||
return; | ||
} | ||
let chart = get(this, 'chart'); | ||
let noData = chart.get('noData'); | ||
let chart = get(this, 'chart'); | ||
let noData = chart.get('noData'); | ||
if (noData != null) { | ||
noData.remove(); | ||
} | ||
if (noData != null) { | ||
noData.remove(); | ||
} | ||
return get(this, 'content').forEach((series, idx) => { | ||
if (chart.series[idx]) { | ||
return chart.series[idx].setData(series.data); | ||
} else { | ||
return chart.addSeries(series); | ||
} | ||
}); | ||
}), | ||
return get(this, 'content').forEach((series, idx) => { | ||
if (chart.series[idx]) { | ||
return chart.series[idx].setData(series.data); | ||
} else { | ||
return chart.addSeries(series); | ||
} | ||
}); | ||
}), | ||
drawAfterRender() { | ||
run.scheduleOnce('afterRender', this, 'draw'); | ||
}, | ||
drawAfterRender() { | ||
run.scheduleOnce('afterRender', this, 'draw'); | ||
}, | ||
draw() { | ||
let completeChartOptions = [ get(this, 'buildOptions'), get(this, 'callback') ]; | ||
let mode = get(this, 'mode'); | ||
draw() { | ||
let completeChartOptions = [ get(this, 'buildOptions'), get(this, 'callback') ]; | ||
let mode = get(this, 'mode'); | ||
if (typeof mode === 'string' && !!mode) { | ||
completeChartOptions.unshift(mode); | ||
} | ||
if (typeof mode === 'string' && !!mode) { | ||
completeChartOptions.unshift(mode); | ||
} | ||
let $element = this.$(); | ||
window.console.log(completeChartOptions); | ||
let chart = $element.highcharts.apply($element, completeChartOptions).highcharts(); | ||
let $element = this.$(); | ||
let chart = $element.highcharts.apply($element, completeChartOptions).highcharts(); | ||
set(this, 'chart', chart); | ||
}, | ||
set(this, 'chart', chart); | ||
}, | ||
_renderChart: on('didInsertElement', function() { | ||
this.drawAfterRender(); | ||
setDefaultHighChartOptions(this.container); | ||
}), | ||
_renderChart: on('didInsertElement', function() { | ||
this.drawAfterRender(); | ||
setDefaultHighChartOptions(this.container); | ||
}), | ||
_destroyChart: on('willDestroyElement', function() { | ||
this._super(); | ||
get(this, 'chart').destroy(); | ||
}) | ||
_destroyChart: on('willDestroyElement', function() { | ||
this._super(); | ||
get(this, 'chart').destroy(); | ||
}) | ||
}); |
'use strict'; | ||
/* | ||
This blueprint is run automatically via ember install:addon ember-cli-highcharts | ||
Runs afterInstall hook to addBowerPackage dependency to our project for highcharts-release | ||
Reference: http://johnotander.com/ember/2014/12/14/creating-an-emberjs-addon-with-the-ember-cli/ | ||
This blueprint is run automatically via ember install:addon ember-cli-highcharts | ||
Runs afterInstall hook to addBowerPackage dependency to our project for highcharts-release | ||
Reference: http://johnotander.com/ember/2014/12/14/creating-an-emberjs-addon-with-the-ember-cli/ | ||
*/ | ||
module.exports = { | ||
normalizeEntityName: function() { | ||
//tbh, not sure why I need this, but it's here | ||
}, | ||
normalizeEntityName: function() { | ||
//tbh, not sure why I need this, but it's here | ||
}, | ||
afterInstall: function(options) { | ||
//add Bower Package for highcharts-release | ||
//@todo: highstock, highmaps? | ||
return this.addBowerPackageToProject('highcharts-release'); | ||
} | ||
afterInstall: function(options) { | ||
//add Bower Package for highcharts-release | ||
return this.addBowerPackageToProject('highcharts-release'); | ||
} | ||
}; |
118
index.js
@@ -1,2 +0,2 @@ | ||
/* jshin t node: true */ | ||
/* jshin t node: true */ | ||
'use strict'; | ||
@@ -7,61 +7,61 @@ | ||
module.exports = { | ||
name: 'ember-cli-highcharts', | ||
blueprintsPath: function() { | ||
return path.join(__dirname, 'blueprints'); | ||
}, | ||
name: 'ember-cli-highcharts', | ||
blueprintsPath: function() { | ||
return path.join(__dirname, 'blueprints'); | ||
}, | ||
included: function(app) { | ||
this._super.included(app); | ||
var _highcharts = app.options.highcharts || { | ||
include: true, | ||
modules: { | ||
/* //Don't need to specify these defaults since they are false | ||
'broken-axis': false, | ||
'data': false, | ||
'canvas-tools': false, | ||
'drilldown': false, | ||
'exporting': false, | ||
'funnel': false, | ||
'heatmap': false, | ||
'no-data-to-display': false, | ||
'solid-gauge': false, | ||
'treemap': false | ||
*/ | ||
}, | ||
adapters: { | ||
/* //Don't need to specify false defaults | ||
'standalone-framework': false | ||
*/ | ||
} | ||
}; | ||
//highcharts + modules | ||
if(_highcharts.include) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/highcharts.js'); | ||
if(_highcharts.modules) { | ||
for(var module in _highcharts.modules) { | ||
var includeModule = _highcharts.modules[module]; | ||
if(includeModule) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/modules/' + module + '.js'); | ||
} | ||
} | ||
} | ||
if(_highcharts.adapters) { | ||
for(var adapter in _highcharts.adapter) { | ||
var includeAdapter = _highcharts.adapters[adapter]; | ||
if(includeAdapter) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/adapters/' + adapter + '.js'); | ||
} | ||
} | ||
} | ||
} | ||
//include shim | ||
this.app.import('vendor/ember-cli-highcharts/shim.js', { | ||
type: 'vendor', | ||
exports: { 'highcharts': ['default'] } | ||
}); | ||
} | ||
included: function(app) { | ||
this._super.included(app); | ||
var _highcharts = app.options.highcharts || { | ||
include: true, | ||
modules: { | ||
/* //Don't need to specify these defaults since they are false | ||
'broken-axis': false, | ||
'data': false, | ||
'canvas-tools': false, | ||
'drilldown': false, | ||
'exporting': false, | ||
'funnel': false, | ||
'heatmap': false, | ||
'no-data-to-display': false, | ||
'solid-gauge': false, | ||
'treemap': false | ||
*/ | ||
}, | ||
adapters: { | ||
/* //Don't need to specify false defaults | ||
'standalone-framework': false | ||
*/ | ||
} | ||
}; | ||
//highcharts + modules | ||
if(_highcharts.include) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/highcharts.js'); | ||
if(_highcharts.modules) { | ||
for(var module in _highcharts.modules) { | ||
var includeModule = _highcharts.modules[module]; | ||
if(includeModule) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/modules/' + module + '.js'); | ||
} | ||
} | ||
} | ||
if(_highcharts.adapters) { | ||
for(var adapter in _highcharts.adapter) { | ||
var includeAdapter = _highcharts.adapters[adapter]; | ||
if(includeAdapter) { | ||
this.app.import(app.bowerDirectory + '/highcharts-release/adapters/' + adapter + '.js'); | ||
} | ||
} | ||
} | ||
} | ||
//include shim | ||
this.app.import('vendor/ember-cli-highcharts/shim.js', { | ||
type: 'vendor', | ||
exports: { 'highcharts': ['default'] } | ||
}); | ||
} | ||
}; |
{ | ||
"name": "ember-cli-highcharts", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "The default blueprint for ember-cli addons.", | ||
@@ -5,0 +5,0 @@ "directories": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
34314
27
1490
1