Created
November 11, 2013 13:01
-
-
Save svasva/7412856 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cx.ChartBoxComponent = Ember.Component.extend | |
init: -> | |
groupingUnits = [ | |
['minute',[5, 10, 15, 30]] | |
['hour',[1, 2, 3, 4, 6, 8, 12]] | |
['day',[1,2,3]] | |
['week',[1,2]] | |
['month',[1, 3, 6]] | |
['year',null] | |
] | |
Ember.run.later -> $('#chart').highcharts 'StockChart', | |
rangeSelector: | |
buttons : [ | |
{ type : 'hour', count : 6, text : '6h' } | |
{ type : 'day', count : 1, text : '1D' } | |
{ type : 'day', count : 2, text : '2D' } | |
{ type : 'week', count : 1, text : '1W' } | |
{ type : 'month', count : 1, text : '1M' } | |
{ type : 'all', count : 1, text : 'All' } | |
] | |
selected : 2 | |
inputEnabled : false | |
tooltip: { valueDecimals: 8 } | |
series: [ | |
type: 'candlestick' | |
name: 'Exchange rate' | |
data: [] | |
dataGrouping: { units: groupingUnits } | |
] | |
updater: (-> | |
series = $('#chart').highcharts().series[0] | |
item = @get 'items.lastObject' | |
point = _.find(series.points, (p) -> p.category == parseInt(item.get('id'))) | |
return if point | |
pointData = [ | |
parseInt(item.get 'id'), | |
item.get('o'), | |
item.get('h'), | |
item.get('l'), | |
item.get('c') | |
] | |
console.log pointData | |
Ember.run.later -> series.addPoint(pointData, true, false, false) | |
# console.log series.data | |
).observes('[email protected]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment