From: dsc Date: Tue, 17 Apr 2012 18:12:38 +0000 (-0700) Subject: Checkpoint on Data UI. X-Git-Url: http://git.lttlst.com:3516/?a=commitdiff_plain;h=471b1a3d020390625956d44c4ded1e5b97105b8e;p=kraken-ui.git Checkpoint on Data UI. --- diff --git a/data/graphs/ohai.json b/data/graphs/ohai.json index a38457a..e765428 100644 --- a/data/graphs/ohai.json +++ b/data/graphs/ohai.json @@ -1,41 +1 @@ -{ - "id": "ohai", - "slug": "ohai", - - "name": "ohai~", - "desc": "A graph for the testing of great justice.", - - "dataset": "/data/datasources/rc/rc_page_requests.csv", - "data" : { - "metrics" : [ - { - "source_id" : "rc_page_requests", - "source_col" : 1, - "label" : "All Wikipedias (+Mobile)", - "color" : "#E62F74" - }, { - "source_id" : "rc_page_requests", - "source_col" : 2, - "label" : "English", - "color" : "#244792" - } - ] - }, - - "width": "auto", - "height": 600, - - "parents": [ - "root" - ], - - "chartType": "dygraphs", - "options": { - "digitsAfterDecimal": 2, - "drawPoints": true, - "labelsKMB": true, - "logscale": true, - "pointSize": 1, - "strokeWidth": 4 - } -} +{"options":{"animatedZooms":true,"avoidMinZero":false,"axis":null,"axisLabelColor":"#666666","axisLabelFontSize":11,"axisLabelFormatter":null,"axisLabelWidth":50,"axisLineColor":"#AAAAAA","axisLineWidth":0.3,"axisTickSize":3,"colorSaturation":1,"colorValue":0.5,"colors":["#FF0097","#EF8158","#83BB32","#182B53","#4596FF","#553DC9","#AD3238","#00FFBC","#F1D950"],"connectSeparatedPoints":false,"customBars":false,"dateWindow":null,"delimiter":",","digitsAfterDecimal":2,"displayAnnotations":false,"drawPoints":true,"drawXAxis":true,"drawXGrid":true,"drawYAxis":true,"drawYGrid":true,"errorBars":false,"file":null,"fillAlpha":0.15,"fillGraph":false,"fractions":false,"gridLineColor":"#D8D8D8","gridLineWidth":0.3,"hideOverlayOnMouseOut":false,"highlightCircleSize":4,"includeZero":false,"interactionModel":null,"isZoomedIgnoreProgrammaticZoom":false,"labels":null,"labelsDiv":null,"labelsDivStyles":null,"labelsDivWidth":250,"labelsKMB":true,"labelsKMG2":false,"labelsSeparateLines":true,"labelsShowZeroValues":true,"legend":"always","logscale":true,"maxNumberWidth":30,"panEdgeFraction":null,"pixelsPerLabel":null,"pixelsPerXLabel":null,"pixelsPerYLabel":null,"pointSize":1,"rangeSelectorHeight":40,"rangeSelectorPlotFillColor":"#A7B1C4","rangeSelectorPlotStrokeColor":"#808FAB","rightGap":20,"rollPeriod":1,"showLabelsOnHighlight":true,"showRangeSelector":false,"showRoller":false,"sigFigs":null,"sigma":2,"stackedGraph":false,"stepPlot":false,"strokePattern":null,"strokeWidth":4,"ticker":null,"title":null,"titleHeight":18,"valueFormatter":null,"valueRange":null,"visibility":null,"wilsonInterval":true,"xAxisHeight":null,"xAxisLabelFormatter":null,"xAxisLabelWidth":55,"xLabelHeight":18,"xValueFormatter":null,"xValueParser":null,"xlabel":null,"y2label":null,"yAxisLabelFormatter":null,"yAxisLabelWidth":50,"yLabelWidth":18,"yValueFormatter":null,"ylabel":null},"slug":"ohai","name":"ohai~","desc":"A graph for the testing of great justice.","notes":"","width":"auto","height":250,"chartType":"dygraphs","parents":["root"],"id":"ohai","dataset":"/data/datasources/rc/rc_page_requests.csv","data":{"metrics":[{"source_id":"rc_page_requests","source_col":1,"label":"All Wikipedias (+Mobile)","color":"#E62F74"},{"source_id":"rc_page_requests","source_col":2,"label":"English","color":"#244792"}]}} \ No newline at end of file diff --git a/lib/dataset/dataset-model.co b/lib/dataset/dataset-model.co index 0cef0ad..47ae0e8 100644 --- a/lib/dataset/dataset-model.co +++ b/lib/dataset/dataset-model.co @@ -50,7 +50,7 @@ DataSet = exports.DataSet = BaseModel.extend do # {{{ return this if @ready and not opts.force @wait() @trigger 'load', this - Seq @metrics.pluck 'source_id' + Seq _.unique @metrics.pluck 'source_id' .parMap_ (next, source_id) -> DataSource.lookup source_id, next .seqEach_ (next, source) ~> diff --git a/lib/dataset/datasource-model.co b/lib/dataset/datasource-model.co index e06d0d5..57fed50 100644 --- a/lib/dataset/datasource-model.co +++ b/lib/dataset/datasource-model.co @@ -59,7 +59,7 @@ DataSource = exports.DataSource = BaseModel.extend do # {{{ @constructor.register this @metrics = new MetricList @attributes.metrics @on 'change:metrics', @onMetricChange, this - @on 'load-success', @onLoadSuccess, this + @load() canonicalize: (ds) -> @@ -91,31 +91,28 @@ DataSource = exports.DataSource = BaseModel.extend do # {{{ @loadCSV url default console.error "#this.load() Unknown Data Format!" - @trigger 'load-error', this, 'Unknown Data Format!' + @onLoadError null, 'Unknown Data Format!', new Error 'Unknown Data Format!' this loadJSON: (url) -> $.ajax do url : url dataType : 'json' - success : (@data) -> - @trigger 'load-success', this - error : (jqXHR, txtStatus, err) -> - @trigger 'load-error', this, txtStatus, err + success : @onLoadSuccess + error : @onLoadError this loadCSV: (url) -> $.ajax do url : url dataType : 'text' - success : (data) -> - @data = new CSVData data - @trigger 'load-success', this - error : (jqXHR, txtStatus, err) -> - @trigger 'load-error', this, txtStatus, err + success : (data) ~> @onLoadSuccess new CSVData data + error : @onLoadError this - onLoadSuccess: -> + onLoadSuccess: (@data) -> + console.log "#this.onLoadSuccess #{@data}" + @trigger 'load-success', this return if @ready @ready = true @trigger 'ready', this @@ -123,6 +120,7 @@ DataSource = exports.DataSource = BaseModel.extend do # {{{ onLoadError: (jqXHR, txtStatus, err) -> @_errorLoading = true console.error "#this Error loading data! -- #msg: #{err or ''}" + @trigger 'load-error', this, txtStatus, err getData: -> diff --git a/lib/dataset/metric-model.co b/lib/dataset/metric-model.co index b953a20..72e95de 100644 --- a/lib/dataset/metric-model.co +++ b/lib/dataset/metric-model.co @@ -9,6 +9,7 @@ DataSource = DataSourceList = null */ Metric = exports.Metric = BaseModel.extend do # {{{ urlRoot : '/metrics' + ready : false /** * Data source of the Metric. @@ -43,13 +44,15 @@ Metric = exports.Metric = BaseModel.extend do # {{{ initialize : -> BaseModel::initialize ... - @on 'change:source_id', @onUpdateSource, this - @onUpdateSource() + @on 'change:source_id', @lookupSource, this + @on 'change:source_col', @onUpdateSourceCol, this + @lookupSource() - onUpdateSource: -> + lookupSource: -> if source_id = @get 'source_id' @wait() + @updateId() DataSource.lookup source_id, @onSourceReady, this this @@ -60,12 +63,23 @@ Metric = exports.Metric = BaseModel.extend do # {{{ console.error "#this Error loading DataSource! #err" else @source = source + @updateId() unless @ready @ready = true @trigger 'ready', this this + onUpdateSourceCol: -> + @updateId() + this + + updateId: -> + if (source_id = @get('source_id')) and (source_col = @get('source_col')) + @id = "#source_id[#source_col]" + this + + /** * Check whether the metric has aiight-looking values so we don't * attempt to graph unconfigured crap.