~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/plugins/distributions/plot_dist_common.js

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2009-10-26 14:30:00 UTC
  • mfrom: (1.1.13 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20091026143000-wzwt6cryjnwce23k
Tags: 0.5.2-1
* new upstream release
  closes: #551306 (added support for the new dynamic help system)
* Add "DM-Upload-Allowed: yes" in control
* bump standards version to 3.8.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// globals
 
2
var options;
 
3
 
 
4
 
 
5
 
 
6
function printout () {
 
7
        doPrintout (true);
 
8
}
 
9
 
 
10
function preview () {
 
11
        preprocess ();
 
12
        calculate ();
 
13
        doPrintout (false);
 
14
}
 
15
 
 
16
 
 
17
function getContRangeParameters () {
 
18
        options['n'] = getValue ("n");
 
19
        options['min'] = getValue ("min");
 
20
        options['max'] = getValue ("max");
 
21
}
 
22
 
 
23
 
 
24
function getDiscontRangeParameters () {
 
25
        options['min'] = getValue ("min");
 
26
        options['max'] = getValue ("max");
 
27
        options['n'] = options['max'] - options['min'] + 1;
 
28
}
 
29
 
 
30
function doPrintout (final) {
 
31
        fun = getValue ("function");
 
32
        log = (getValue ("log") == 1);
 
33
        log_option = "";
 
34
        if (fun == "d") {
 
35
                is_density = true;
 
36
                label = "density";
 
37
                tail_option = "";
 
38
                tail_label = "";
 
39
                if (log) log_option = ", log=TRUE";
 
40
        } else {
 
41
                is_density = false;
 
42
                label = "distribution";
 
43
                if (getValue("lower") == "1") {
 
44
                        tail_option = ", lower.tail = TRUE";
 
45
                        tail_label = ", \"Tail\",\"Lower\"";
 
46
                } else {
 
47
                        tail_option = ", lower.tail = FALSE";
 
48
                        tail_label = ", \"Tail\",\"Upper\"";
 
49
                }
 
50
                if (log) log_option = ", log.p=TRUE";
 
51
        }
 
52
        if (log) log_label = ', "Scale", "logarithmic"';
 
53
        else log_label = ', "Scale", "normal"';
 
54
 
 
55
        options = array ();
 
56
        options['is_density'] = is_density;
 
57
        options['label'] = label;
 
58
        options['tail_option'] = tail_option;
 
59
        options['tail_label'] = tail_label;
 
60
        options['log_option'] = log_option;
 
61
        options['log_label'] = log_label;
 
62
 
 
63
        getParameters ();
 
64
 
 
65
        if (final) {
 
66
                doHeader (); 
 
67
echo ('\n');
 
68
echo ('rk.graph.on ()\n');
 
69
        }
 
70
 
 
71
echo ('try ({\n');
 
72
echo (' curve ('); doFunCall (); echo (', from=' + options['min'] + ', to=' + options['max'] + ', n=' + options['n'] + getValue ("plotoptions.code.printout") + ')\n');
 
73
        
 
74
        plot_adds = getValue ("plotoptions.code.calculate");
 
75
        if (!empty (plot_adds)) { 
 
76
echo ('\n');
 
77
                printIndented ("\t", plot_adds);
 
78
        } 
 
79
echo ('})\n');
 
80
        if (final) { 
 
81
echo ('rk.graph.off ()\n');
 
82
}
 
83
}
 
84