From cbaeb0b773cc6401943250edcdac82c6a9a71ca8 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Sun, 13 Jun 2010 12:37:50 +0100 Subject: Build charts based on a downloaded list of available rrd files --- jrrd.js | 63 ++++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'jrrd.js') diff --git a/jrrd.js b/jrrd.js index 85f5ebc..f4c3665 100644 --- a/jrrd.js +++ b/jrrd.js @@ -457,31 +457,56 @@ jrrd.Chart.prototype.draw = function() { }; -jrrd.Chart.fromRecipe = function(template, recipe) { +jrrd.collectdChartFactory = function(rrdUrlList, recipes, templateFactory) { /** - * A factory function to generate a I{Chart} from a recipe + * A factory function to generate a list of I{Chart} from a list of recipes + * and a list of available rrd files in collectd path format. * - * @param template: A I{jQuery} containing the element in which the chart is - * drawn. - * @param A recipe I{Object} eg - * {title: '', data: [rrdUrl, rrdDs, label, unit], options: {}} - * @return: A I{Chart} instance + * @param rrdUrlList: A list of rrd download paths + * @param recipes: A list of recipe objects + * @param templateFactory: A callable which generates an html template for a + * chart. **/ - template.find('.title').text(recipe['title']); - var c = new jrrd.Chart(template.find('.chart'), recipe['options']); + var rrdUrlBlob = rrdUrlList.join('\n') + + var charts = []; var dataDict = {}; - var ds, label, rrd, unit; - for(var i=0; i 0) { + template = templateFactory(); + template.find('.title').text(recipe['title']); + c = new jrrd.Chart(template.find('.chart'), recipe['options']); + for(j=0; j