Comparing version 0.0.1 to 0.0.2
var _ = require('underscore'), Backbone = require('backbone'); | ||
var Chart = require('../../'); | ||
var dz = [ | ||
{ key1: 2, key2: 45, key3: 311, time: 1367296690307 }, | ||
{ key1: 4, key2: 34, key3: 193, time: 1367296692807 }, | ||
{ key1: 1, key2: 93, key3: 101, time: 1367296693807 }, | ||
{ key2: 45, key3: 311, time: 1367296690307 }, | ||
{ key1: 4, key3: 193, time: 1367296692807 }, | ||
{ key1: 1, key2: 93, time: 1367296693807 }, | ||
{ key1: 8, key2: 12, key3: 204, time: 1367296691807 }, | ||
{ key1: 3, key2: 77, key3: 489, time: 1367296694807 } | ||
]; | ||
var dz = []; | ||
var chart = window.chart = new Chart({ | ||
@@ -11,0 +13,0 @@ data: dz, |
@@ -36,3 +36,4 @@ /** | ||
model: this.model, | ||
collection: this.model.plots | ||
collection: this.model.plots, | ||
data: this.model.get('data') | ||
})); | ||
@@ -39,0 +40,0 @@ } |
@@ -65,2 +65,4 @@ /** | ||
var value = point.get(keys[i]); | ||
if (value === undefined) continue; | ||
@@ -67,0 +69,0 @@ memo.min = memo.min === undefined ? value : Math.min(memo.min, value); |
@@ -19,2 +19,3 @@ /** | ||
this.parent = options.rootView; | ||
this.paper = false; | ||
this.subview('resizer', new Resizer({ | ||
@@ -34,6 +35,10 @@ model: this.model, | ||
this.$el.html(markup); | ||
if ( this.paper ) this.paper.remove(); | ||
this.paper = Raphael(this.$('.chart-svg')[0], json.vp_width, json.vp_height); | ||
this.assign('.chart-resizer', 'resizer'); | ||
if (json.draw_guides) this.renderGuides(json); | ||
this.renderData(json); | ||
if (this.collection.length) this.renderData(json); | ||
else { | ||
this.paper.text(json.vp_width/2,10,'no data received'); | ||
} | ||
return this; | ||
@@ -128,4 +133,7 @@ | ||
var key = plot.get('key'); | ||
var y_value = point.get(key); | ||
if (y_value === undefined) return; | ||
// get point for this plot ( [x,y].join(' ') ) | ||
var point_arr = [x_value, plot.toPixelY(point.get(key))]; | ||
var point_arr = [x_value, plot.toPixelY(y_value)]; | ||
var point_string = point_arr.join(' '); | ||
@@ -132,0 +140,0 @@ // create a key with array if not already there |
@@ -12,6 +12,8 @@ /** | ||
initialize: function() { | ||
initialize: function(options) { | ||
this.data = options.data; | ||
this.listenTo(this.model, 'change:vp_width', this.render); | ||
}, | ||
@@ -23,2 +25,7 @@ | ||
if (this.data.length <= 0) { | ||
this.$el.empty(); | ||
return; | ||
} | ||
this.$el.empty().css('width', this.model.get('vp_width')+'px'); | ||
@@ -25,0 +32,0 @@ |
@@ -42,2 +42,8 @@ /** | ||
render: function() { | ||
if (this.data.length <= 0) { | ||
this.$el.html('<div style="height:'+this.model.get('vp_height')+'px;"></div>'); | ||
return; | ||
} | ||
if (this.model.get('multi_y')) return this.renderMulti(); | ||
@@ -44,0 +50,0 @@ else return this.renderSingle(); |
{ | ||
"name": "charted", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Charts an entire collection of data. Single or multiple y-axes. Support for 64-bit integers. Auto-resizing axes.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
44106
1029