getColors: ->
return [] unless @ready
- @metrics.onlyOk().pluck 'color'
+ @metrics.onlyOk().invoke 'getColor'
# }}}
} = require 'kraken/util'
{ BaseModel, BaseList,
} = require 'kraken/base'
+ProjectColors = require 'kraken/data/project-colors'
DataSource = DataSourceList = null
+
+
+
+
/**
* @class
*/
@load()
+ # toJSON: ->
+ # json = Metric.__super__.toJSON ...
+ # json.color or= ProjectColors.lookup(json.label) or 'black'
+ # json
+
+
getDateColumn: ->
@source.getDateColumn()
col = @get 'source_col'
@source.getColumnName col if @source and col > 0
+ getColor: ->
+ @get('color') or ProjectColors.lookup(@get('label')) or 'black'
+
load: (opts={}) ->
source_id = @get 'source_id'
--- /dev/null
+/**
+ * @fileOverview Applies consistent coloring to language/project Metrics with a null `color` field.
+ */
+
+
+PROJECT_COLORS = exports.PROJECT_COLORS =
+ 'target' : '#cccccc'
+ 'total' : '#182B53'
+ 'all projects' : '#182B53'
+ 'world' : '#182B53'
+ 'commons' : '#d73027'
+ 'north america' : '#4596FF'
+ 'english' : '#4596FF'
+ 'asia pacific' : '#83BB32'
+ 'japanese' : '#83BB32'
+ 'china' : '#AD3238'
+ 'chinese' : '#AD3238'
+ 'europe' : '#FF0097'
+ 'german' : '#FF0097'
+ 'dutch' : '#EF8158'
+ 'french' : '#1A9380'
+ 'italian' : '#FF87FF'
+ 'portuguese' : '#B64926'
+ 'swedish' : '#5DD2A4'
+ 'russian' : '#FA0000'
+ 'latin america' : '#FFB719'
+ 'spanish' : '#FFB719'
+ 'middle east' : '#00675B'
+ 'india' : '#553DC9'
+
+PROJECT_TESTS = ( { pat://\b#{project.replace(/ /g, '[ _-]')}\b//i, project, color } for project, color in PROJECT_COLORS )
+
+
+lookupColor = exports.lookup = (label) ->
+ for project, {pat, color} in PROJECT_TESTS
+ return color if pat.test label
+
'click .load-button' : 'load'
'click .save-button' : 'save'
'click .done-button' : 'done'
+ 'keypress .graph-name' : 'onNameKeypress'
'keypress .graph-details input[type="text"]' : 'onKeypress'
'keypress .chart-options .value' : 'onKeypress'
'submit form.graph-details' : 'onDetailsSubmit'
onKeypress: (evt) ->
$(evt.target).submit() if evt.keyCode is 13
+ onNameKeypress: (evt) ->
+ @$ 'form.graph-details' .submit() if evt.keyCode is 13
+
onDetailsSubmit: ->
console.log "#this.onDetailsSubmit!"
details = @$ 'form.graph-details' .formData()
- chart-type
- index
- data:
+ - project-colors
- metric-model
- metric-edit-view
- datasource-model