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
* 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[]
* @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
/**
### 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::
### 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]
_ = 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) ->
-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
{ _, op,
} = require 'kraken/util'
-{ ChartLibrary, DygraphsLibrary,
+{ ChartType, DygraphsChartType,
} = require 'kraken/chart'
{ BaseView, BaseModel, BaseList,
} = require 'kraken/base'
# 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
_ = require 'kraken/util/underscore'
Cascade = require 'kraken/util/cascade'
-{ ChartLibrary,
+{ ChartType,
} = require 'kraken/chart'
{ BaseModel, BaseView, BaseList,
} = require 'kraken/base'
/**
* The chart type backing this graph.
- * @type ChartLibrary
+ * @type ChartType
*/
- library : null
+ chartType : null
/**
* List of graph parents.
dataset : '/data/non_mobile_pageviews_by.timestamp.language.csv'
width : 'auto'
height : 320
- library : 'dygraphs'
+ chartType : 'dygraphs'
parents : <[ root ]>
options : {}
}
@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}"
* @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
- base
- chart:
- - chart-library
- - dygraphs-library
+ - chart-type
+ - dygraphs
- index
- template:
- graph.jade
# 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