From 540d00f13a75b1a8e74eeefca61571f79ace7614 Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Fri, 28 Aug 2009 07:23:07 +0000 Subject: [PATCH] Add a thin wrapper that directly supports the gviz API. This resolves issue 1. --- dygraph.js | 14 ++++++++++++++ tests/gviz.html | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dygraph.js b/dygraph.js index 2ba42c9..09a6684 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1184,3 +1184,17 @@ DateGraph.prototype.adjustRoll = function(length) { this.rollPeriod_ = length; this.drawGraph_(this.rawData_); }; + + +/** + * A wrapper around DateGraph that implements the gviz API. + * @param {Object} container The DOM object the visualization should live in. + */ +DateGraph.GVizChart = function(container) { + this.container = container; +} + +DateGraph.GVizChart.prototype.draw = function(data, options) { + this.container.innerHTML = ''; + this.date_graph = new DateGraph(this.container, data, null, options || {}); +} diff --git a/tests/gviz.html b/tests/gviz.html index 812ff3f..7942aa6 100644 --- a/tests/gviz.html +++ b/tests/gviz.html @@ -30,9 +30,10 @@ data.setCell(3, 2, 0); new google.visualization.LineChart( - document.getElementById('gviz')). draw(data, null); + document.getElementById('gviz')).draw(data, null); - new DateGraph(document.getElementById('dygraphs'), data, null, {}); + new DateGraph.GVizChart( + document.getElementById('dygraphs')).draw(data, null); } google.setOnLoadCallback(drawVisualization); -- 2.7.4