Scatterplot (plugin version): small fixes, move dataset out of config, namespace hbrs templates

This commit is contained in:
Carl Eberhard
2013-11-19 10:19:22 -05:00
parent b2cffd410c
commit 018f5187e8
6 changed files with 26 additions and 225 deletions
@@ -10,14 +10,10 @@ var ScatterplotView = Backbone.View.extend({
//TODO: should be a view on visualization(revision) model
defaults : {
dataset : {
},
metadata : {
dataLines : undefined
},
ajaxFn : null,
pagination : {
currPage : 0,
perPage : 3000
@@ -48,6 +44,7 @@ var ScatterplotView = Backbone.View.extend({
initialize : function( attributes ){
this.config = _.extend( _.clone( this.defaults ), attributes.config || {});
this.dataset = attributes.dataset;
//console.debug( this + '.config:', this.config );
},
@@ -65,7 +62,7 @@ var ScatterplotView = Backbone.View.extend({
//console.debug( 'currPage', this.config.pagination.currPage );
var view = this;
//TODO: very tied to datasets - should be generalized eventually
xhr = jQuery.getJSON( '/api/datasets/' + this.config.dataset.id, {
xhr = jQuery.getJSON( '/api/datasets/' + this.dataset.id, {
data_type : 'raw_data',
provider : 'dataset-column',
limit : this.config.pagination.perPage,
@@ -151,7 +148,7 @@ var ScatterplotView = Backbone.View.extend({
},
renderLineInfo : function( data ){
var totalLines = this.config.dataset.metadata_data_lines || 'an unknown number of',
var totalLines = this.dataset.metadata_data_lines || 'an unknown number of',
lineStart = ( this.config.pagination.currPage * this.config.pagination.perPage ),
lineEnd = lineStart + data.length;
return $( '<p/>' ).addClass( 'scatterplot-data-info' )
@@ -168,9 +165,9 @@ var ScatterplotView = Backbone.View.extend({
}
//TODO: cache numPages/numLines in config
var view = this,
dataLines = this.config.dataset.metadata_data_lines,
dataLines = this.dataset.metadata_data_lines,
numPages = ( dataLines )?( Math.ceil( dataLines / this.config.pagination.perPage ) ):( undefined );
//console.debug( 'data:', this.config.dataset.metadata_data_lines, 'numPages:', numPages );
//console.debug( 'data:', this.dataset.metadata_data_lines, 'numPages:', numPages );
// prev next buttons
var $prev = makePage$Li( 'Prev' ).click( function(){
@@ -207,9 +204,9 @@ var ScatterplotView = Backbone.View.extend({
}
//TODO: cache numPages/numLines in config
var view = this,
dataLines = this.config.dataset.metadata_data_lines,
dataLines = this.dataset.metadata_data_lines,
numPages = ( dataLines )?( Math.ceil( dataLines / this.config.pagination.perPage ) ):( undefined );
//console.debug( 'data:', this.config.dataset.metadata_data_lines, 'numPages:', numPages );
//console.debug( 'data:', this.dataset.metadata_data_lines, 'numPages:', numPages );
// page numbers (as separate control)
//var $paginationContainer = $( '<div/>' ).addClass( 'pagination-container' ),