Skip to content
Browse files

add destroy() method to get chart out of a loop and remove dom elems,…

… fix non-summary graph view range bug
  • Loading branch information...
1 parent c53e2f3 commit 02b62be9a7b548bfe211b08e85afa86cddecf40e @boorad committed Jan 12, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 js/d3.tsline.js
View
17 js/d3.tsline.js
@@ -148,8 +148,15 @@ function d3_tsline(id) {
self.update_view_calcs = function() {
var max_elem = self.data[0].length - self.view_span;
- var start = Math.round(self.slider.x * (max_elem / self.slider.max_x));
- var end = start + self.view_span;
+ var start = 0, end = 0;
+
+ if( self.show_summary ) {
+ start = Math.round(self.slider.x * (max_elem / self.slider.max_x));
+ end = start + self.view_span;
+ } else {
+ end = self.data[0].length || 0;
+ start = end - self.view_span;
+ }
if( self.scrolling ) start--;
if( start < 0 ) start = 0;
@@ -665,6 +672,12 @@ function d3_tsline(id) {
self.draw_view();
};
+ self.destroy = function() {
+ self.stop_scroll;
+ d3.select(self.selector + " .view, " + self.selector + " .summary")
+ .remove();
+ };
+
// call constructor (after all functions have been loaded)
self.init();

0 comments on commit 02b62be

Please sign in to comment.
Something went wrong with that request. Please try again.