/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require_once($ADEI_ROOTDIR . "/classes/views/basehistogramview.php");

class COUNTView extends BASEHistogramView {
 var $title = "Count Records";
 
 function __construct(REQUEST $req  = NULL, $options) {
    parent::__construct($req, $options);
    $this->max_points = $this->GetOption('max_points', 1000000);
 }

 function GetOptions() {
    $chan = $this->GetDataVariants(array("x", "y"), VIEW::FORBID_MULTIPLE_GROUPS);
    $hist = $this->GetHistOptions();

    return array_merge(array(
        array("input" => array("label" => _("x"), "id" => "x_mult", "type" => "text", "size" => "3", "value" => "1")),
        array("select" => array("label" => _("*"), "id" => "x", "options" => $chan[0])), 
        array("xml"=>"<br/>"),
        array("input" => array("label" => _("y"), "id" => "y_mult", "type" => "text", "size" => "3", "value" => "1")),
        array("select" => array("label" => _("*"), "id" => "y", "options" => $chan[1])),
        array("xml"=>"<br/>"),
        array("input" => array("label" => _("From"), "id" => "count_min", "type" => "text", size => "8", "value" => "")),
        array("input" => array("label" => _("To"), "id" => "count_max", "type" => "text", size => "8", "value" => "")),
        array("xml"=>"<br/>"),
        array("input" => array("label" => _("Test"), "id" => "count_test", "type" => "text", "value" => "")),
        array("xml"=>"<br/>"),
    ), $hist);
 }

 function GetView() {
    global $TMP_PATH;

    $req = $this->req->CreateDataRequest();
    $x_mult = $req->GetProp("view_x_mult", 1);
    $y_mult = $req->GetProp("view_y_mult", 1);
    $min = $req->GetProp("view_count_min", false);
    $max = $req->GetProp("view_count_max", false);
    $test = $req->GetProp("view_count_test", false);
    
    if ($test) {
        $func = dsMathCreateFunction('$x,$y', $test);
    }

    $res = $this->GetData(array("x", "y"), NULL, VIEW::GET_RAW_DATA);

    $total = 0;
    $inrange = 0;
    $data = array();

    foreach($res['data'] as $t => $v) {
        $total++;

        $sum = $x_mult * $v[0] + $y_mult * $v[1];
        
        if ($test) {
            if (!$func($v[0], $v[1]))
                continue;
        } else {
            if (is_numeric($min)) {
                if ($sum < $min) continue;
            }

            if (is_numeric($max)) {
                if ($sum > $max) continue;
            }
        }
        
        $inrange++;
        array_push($data, $sum);
    }

    $info = array(
	array("title"=>_("Total"), "value" => $total),
	array("title"=>_("In Range"), "value" => $inrange),
    );

    if ($data) {
        $view = $this->GetHistView($data);
        $this->MergeViewInfo($view, $info, VIEW::MERGE_START);
    } else {
        $view = array("info" => $info);
    }
    return $view;
 }


};

?>