Adds d3-line test graph.
authorDavid Schoonover <dsc@wikimedia.org>
Wed, 20 Jun 2012 09:57:53 +0000 (02:57 -0700)
committerDavid Schoonover <dsc@wikimedia.org>
Wed, 20 Jun 2012 09:57:53 +0000 (02:57 -0700)
lib/chart/chart-type.co
lib/chart/type/d3/d3-line-chart-type.co
lib/chart/type/dygraphs.co
www/d3-test.jade

index b10a154..d66b435 100644 (file)
@@ -351,6 +351,16 @@ class exports.ChartType extends ReadyEmitter
         @pluck 'default'
     
     
+    
+    
+    /**
+     * Resizes the HTML viewport. Override to disable, etc.
+     */
+    resizeViewport: ->
+        size = @determineSize()
+        @getElementsForRole 'viewport' .css size
+        size
+    
     /**
      * Determines chart viewport size.
      * @return { width, height }
index ccf27a1..6446686 100644 (file)
@@ -29,6 +29,8 @@ class LineChartType extends ChartType
     
     -> super ...
     
+    
+    
     transform: ->
         dataset = @model.dataset
         options = @model.getOptions() import @determineSize()
index 7ae8e67..4d0113e 100644 (file)
@@ -91,15 +91,6 @@ class exports.DygraphsChartType extends ChartType
     
     
     /**
-     * Resizes the HTML viewport.
-     */
-    resizeViewport: ->
-        size = @determineSize()
-        @getElementsForRole 'viewport' .css size
-        size
-    
-    
-    /**
      * Transforms the domain objects into a hash of derived values using
      *  chart-type-specific keys.
      * @returns {Object} The derived chart options.
index 39fbc87..b9c1123 100644 (file)
@@ -7,17 +7,34 @@ append styles
     mixin css('/vendor/bootstrap-colorpicker/css/colorpicker.css')
     mixin css('/vendor/bootstrap-datepicker/css/datepicker.css')
     mixin css('graph.css')
+    // new for SVG
     mixin css('chart.css')
     mixin css('data.css')
     mixin css('isotope.css')
 
 block main-scripts
     script
-        d3 = require('d3')
+        root = this
+        
+        // import all the things, ugly JS-style
+        d3            = require('d3')
+        Seq           = require('seq')
+        Backbone      = require('backbone')
+        util          = require('kraken/util'); _ = util._; op = util.op
+        AppView       = require('kraken/app').AppView
+        base          = require('kraken/base'); BaseView = base.BaseView; BaseModel = base.BaseModel; BaseList = base.BaseList
+        ChartType     = require('kraken/chart').ChartType
+        data          = require('kraken/data'); DataSource = data.DataSource; DataSourceList = data.DataSourceList
+        _graph        = require('kraken/graph'); Graph = _graph.Graph; GraphList = _graph.GraphList; GraphEditView = _graph.GraphEditView
         LineChartType = require('kraken/chart/type/d3/d3-line-chart-type')
+        
+        // run on DOM-ready
         jQuery(function(){
-            setTimeout(function(){
-                ct = view.chartType = graph.chartType = new LineChartType(graph, view); 
-            }, 100);
+            root.app = new AppView(function(){
+                this.model = root.graph = new Graph({ id:'d3-test' }, { parse:true })
+                this.view  = root.view  = new GraphEditView({ model:this.model })
+                this.view.chartType = this.model.chartType = new LineChartType(this.model, this.view);
+            });
         });
-    script(src="/js/kraken/main-edit.js?"+version)
+    
+