/[Frey]/trunk/static/Frey/jQuery/flot/dataset_checkboxes.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/static/Frey/jQuery/flot/dataset_checkboxes.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 869 - (hide annotations)
Tue Dec 16 23:03:21 2008 UTC (15 years, 6 months ago) by dpavlin
File MIME type: application/javascript
File size: 1022 byte(s)
select checkboxes for different columns in sponge
1 dpavlin 869 /* from example at http://people.iola.dk/olau/flot/examples/turning-series.html */
2    
3     // hard-code color indices to prevent them from shifting as
4     // countries are turned on/off
5     var i = 0;
6     $.each(datasets, function(key, val) {
7     val.color = i;
8     ++i;
9     });
10    
11     // insert checkboxes
12     var choiceContainer = $("#choices");
13     $.each(datasets, function(key, val) {
14     choiceContainer.append('<br/><input type="checkbox" name="' + key +
15     '" checked="checked" >' + val.label + '</input>');
16     });
17     choiceContainer.find("input").click(plotAccordingToChoices);
18    
19    
20     function plotAccordingToChoices() {
21     var data = [];
22    
23     choiceContainer.find("input:checked").each(function () {
24     var key = $(this).attr("name");
25     if (key && datasets[key])
26     data.push(datasets[key]);
27     });
28    
29     if (data.length > 0)
30     $.plot($("#placeholder"), data, options);
31     }
32    
33     plotAccordingToChoices();
34    

  ViewVC Help
Powered by ViewVC 1.1.26