Renames 'chart-library' to 'chart-type', as it makes sense that one library might...
authordsc <dsc@wikimedia.org>
Thu, 29 Mar 2012 09:12:20 +0000 (02:12 -0700)
committerdsc <dsc@wikimedia.org>
Thu, 29 Mar 2012 09:15:48 +0000 (02:15 -0700)
lib/chart/chart-type.co [moved from lib/chart/chart-library.co with 81% similarity]
lib/chart/dygraphs.co [moved from lib/chart/dygraphs-library.co with 56% similarity]
lib/chart/index.co
lib/main.co
lib/vis/vis-model.co
www/modules.yaml
www/presets/root.yaml

similarity index 81%
rename from lib/chart/chart-library.co
rename to lib/chart/chart-type.co
index 75c7a13..6a145f5 100644 (file)
@@ -18,14 +18,14 @@ class exports.ChartOption
     examples : null
     
     
-    (@library, @spec) ->
+    (@chartType, @spec) ->
         throw new Error('Each ChartOption requires a name!') unless @spec.name
         
         for k of @SPEC_KEYS
             v = @spec[k]
             @[k] = v if v?
         @tags or= []
-        @parse = @library.getParser @type
+        @parse = @lookup.getParser @type
     
     parse : Parsers.parseString
     
@@ -41,13 +41,14 @@ class exports.ChartOption
  * Map of known libraries by name.
  * @type Object
  */
-KNOWN_LIBRARIES = exports.KNOWN_LIBRARIES = {}
+KNOWN_CHART_TYPES = exports.KNOWN_CHART_TYPES = {}
 
 
 /**
- * @class Abstraction of a charting library, encapsulating its logic and options.
+ * @class Abstraction of a chart-type or charting library, encapsulating its
+ *  logic and options.
  */
-class exports.ChartLibrary extends EventEmitter
+class exports.ChartType extends EventEmitter
     /**
      * Ordered ChartOption objects.
      * @type ChartOption[]
@@ -66,12 +67,12 @@ class exports.ChartLibrary extends EventEmitter
      * @constructor
      * @param {String} name Library name.
      * @param {Array} options List of options objects, each specifying the
-     *  name, type, default, description (etc) of a chart library option.
+     *  name, type, default, description (etc) of a chart option.
      */
     (@name, options) ->
         @options_ordered = _.map options, (opt) ~> new ChartOption this, opt
         @options = _.synthesize @options_ordered, -> [it.name, it]
-        ChartLibrary.register this
+        ChartType.register this
     
     
     /**
@@ -116,7 +117,7 @@ class exports.ChartLibrary extends EventEmitter
     ### Parsers
     
     /**
-     * When implementing a ChartLibrary, you can add or override parsers
+     * When implementing a ChartType, you can add or override parsers
      * merely by subclassing.
      */
     this:: import ParserMixin::
@@ -138,16 +139,16 @@ class exports.ChartLibrary extends EventEmitter
     ### Class Methods
     
     /**
-     * Register a new library.
+     * Register a new chart type.
      */
-    @register = (library) ->
-        KNOWN_LIBRARIES[library.name] = library
+    @register = (chartType) ->
+        KNOWN_CHART_TYPES[chartType.name] = chartType
     
     /**
-     * Look up a library by name.
+     * Look up a chart type by name.
      */
-    @lookupLibrary = (name) ->
-        KNOWN_LIBRARIES[name]
+    @lookup = (name) ->
+        KNOWN_CHART_TYPES[name]
     
     
 
similarity index 56%
rename from lib/chart/dygraphs-library.co
rename to lib/chart/dygraphs.co
index f08468d..056bc39 100644 (file)
@@ -1,9 +1,9 @@
 _ = require 'kraken/util/underscore'
-{ ChartLibrary, ChartOption,
-} = require 'kraken/chart/chart-library'
+{ ChartType, ChartOption,
+} = require 'kraken/chart/chart-type'
 
 
-class exports.DygraphsLibrary extends ChartLibrary
+class exports.DygraphsChartType extends ChartType
     name : 'dygraphs'
     
     (options) ->
index fe6f0b8..6709cab 100644 (file)
@@ -1,3 +1,3 @@
-library  = require 'kraken/chart/chart-library'
-dygraphs = require 'kraken/chart/dygraphs-library'
-exports import library import dygraphs
+chart_type  = require 'kraken/chart/chart-type'
+dygraphs = require 'kraken/chart/dygraphs'
+exports import chart_type import dygraphs
index fe468c1..2098f7e 100644 (file)
@@ -3,7 +3,7 @@ Backbone = require 'backbone'
 
 { _, op,
 } = require 'kraken/util'
-{ ChartLibrary, DygraphsLibrary,
+{ ChartType, DygraphsChartType,
 } = require 'kraken/chart'
 { BaseView, BaseModel, BaseList,
 } = require 'kraken/base'
@@ -29,7 +29,7 @@ main = ->
     # for opt of root.CHART_OPTIONS_SPEC
     #     opts[opt.name] = opt.default
     
-    dyglib = new DygraphsLibrary CHART_OPTIONS_SPEC
+    dyglib = new DygraphsChartType CHART_OPTIONS_SPEC
     
     # TODO: create a preset manager
     # Remove chart options from data so we don't have to deepcopy
index 1ec02e8..0ff9361 100644 (file)
@@ -2,7 +2,7 @@ Seq = require 'seq'
 
 _ = require 'kraken/util/underscore'
 Cascade = require 'kraken/util/cascade'
-{ ChartLibrary,
+{ ChartType,
 } = require 'kraken/chart'
 { BaseModel, BaseView, BaseList,
 } = require 'kraken/base'
@@ -25,9 +25,9 @@ VisModel = exports.VisModel = BaseModel.extend do # {{{
     
     /**
      * The chart type backing this graph.
-     * @type ChartLibrary
+     * @type ChartType
      */
-    library : null
+    chartType : null
     
     /**
      * List of graph parents.
@@ -55,7 +55,7 @@ VisModel = exports.VisModel = BaseModel.extend do # {{{
             dataset : '/data/non_mobile_pageviews_by.timestamp.language.csv'
             width   : 'auto'
             height  : 320
-            library : 'dygraphs'
+            chartType : 'dygraphs'
             parents : <[ root ]>
             options : {}
         }
@@ -78,7 +78,7 @@ VisModel = exports.VisModel = BaseModel.extend do # {{{
         
         @parents = new VisList
         # TODO: Load on-demand
-        @library = ChartLibrary.lookupLibrary @get('library')
+        @chartType = ChartType.lookup @get('chartType')
         
         # unless @id or @get('id') or @get('slug')
         #     @set 'slug', "unsaved_graph_#{@cid}"
@@ -190,7 +190,7 @@ VisModel = exports.VisModel = BaseModel.extend do # {{{
      * @returns {Boolean} Whether the value for option `k` is the graph default or not.
      */
     isDefaultOption: (k) ->
-        @library.isDefault k, @getOption k
+        @chartType.isDefault k, @getOption k
     
     /**
      * Whether the value for option `k` differs from that of its parent graphs.
index 0199df8..99cb4f0 100644 (file)
@@ -58,8 +58,8 @@ dev:
                 - index
             - base
             - chart:
-                - chart-library
-                - dygraphs-library
+                - chart-type
+                - dygraphs
                 - index
             - template:
                 - graph.jade
index bfb9783..e324d29 100644 (file)
@@ -1,13 +1,13 @@
 # The root graph, holding defaults inherited by all graphs.
 
-id      : root
-slug    : root
-dataset : '/data/non_mobile_pageviews_by.timestamp.language.csv'
-width   : 'auto'
-height  : 400
-library : 'dygraphs'
-parents : []
-options : 
+id        : root
+slug      : root
+dataset   : '/data/non_mobile_pageviews_by.timestamp.language.csv'
+width     : 'auto'
+height    : 400
+chartType : 'dygraphs'
+parents   : []
+options   : 
     animatedZooms                   : true
     avoidMinZero                    : false
     axis                            : null