Move busui to seperate repository
[bus.git] / report_dimensionalTrend.php
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<div class="owa_reportSectionContent">
        
        <div id="trend-chart"></div>
        <div id="trend-title" class="owa_reportHeadline"></div>
        <div id="report-tabs">
                
                <?php foreach ($tabs as $k => $tab): ?>
                <div id="tab_<?php $this->out($k); ?>">
                        
                                <div id="<?php $this->out($k); ?>_trend-metrics" style="height:auto;width:auto;<?php if( $this->get( 'pie' ) ) {echo 'float:right';}?>"></div>
                                <?php if ( $this->get('pie' ) ): ?>     
                                <div id="pie" style="min-width:300px;"></div>
                                <?php endif;?>
                                <div class="spacer" style="clear:both; height:20px;"></div>
                                <?php if (!$this->get('hideGrid')):?>
                                <div id="<?php $this->out($k); ?>_dimension-grid"></div>
                                <?php endif;?>
                        
                </div>
                <?php endforeach; ?>
        </div>
</div>
 
<script type="text/javascript">
                
        // add tabs     
        
        <?php foreach ($tabs as $k => $tab): ?>
        
        // adding tab for <?php $this->out($k, false);?>
        
        
        var tab = new OWA.report.tab('tab_<?php $this->out($k, false);?>');
        tab.setLabel('<?php $this->out($tab['tab_label']);?>'); 
        // create trend and aggregate data resultSetExplorer objects
        var trendurl = '<?php echo $this->makeApiLink(array('do' => 'getResultSet', 
                                                                                                                                'metrics' => $tab['metrics'], 
                                                                                                                                'dimensions' => 'date', 
                                                                                                                                'sort' => 'date',
                                                                                                                                'format' => 'json',
                                                                                                                                'constraints' => $constraints
                                                                                                                                ),true);?>';
                                                                                                                                  
        var trend = new OWA.resultSetExplorer('trend-chart');
        trend.setDataLoadUrl(trendurl);
        trend.options.sparkline.metric = 'visits';
        <?php if ($trendTitle):?>
        trend.asyncQueue.push(['renderTemplate', '<?php echo $trendTitle;?>', {d: trend}, 'replace', 'trend-title']);
        <?php endif;?>
        trend.asyncQueue.push(['makeAreaChart', [{x: 'date', y: '<?php echo $trendChartMetric; ?>'}], 'trend-chart']);
        trend.options.metricBoxes.width = '150px';
        trend.asyncQueue.push(['makeMetricBoxes' , '<?php $this->out($k, false);?>_trend-metrics']);
        // add rse to tab
        tab.addRse('trend', trend);
        // dimensonal data object
        var dimurl = '<?php echo $this->makeApiLink(array('do' => 'getResultSet', 
                                                                                                                                'metrics' => $tab['metrics'], 
                                                                                                                                'dimensions' => $dimensions, 
                                                                                                                                'sort' => $tab['sort'],
                                                                                                                                'resultsPerPage' => $resultsPerPage,
                                                                                                                                'format' => 'json',
                                                                                                                                'constraints' => $constraints
                                                                                                                                ),true);?>';
                                                                                                                                  
        var dim = new OWA.resultSetExplorer('<?php $this->out($k, false);?>_dimension-grid');
        dim.setDataLoadUrl(dimurl);
        <?php if (!empty($dimensionLink)):?>
        var link = '<?php echo $this->makeLink($dimensionLink['template'], true);?>';
        var values = <?php if (is_array($dimensionLink['valueColumns'])) { 
                                        $values = "[";
                                        $i = 0;
                                        $count = count($dimensionLink['valueColumns']);
                                        foreach ($dimensionLink['valueColumns'] as $v) {
                                                $values .= "'$v'";
                                                if ($i < $count) {
                                                        $values .= ', ';
                                                }
                                                $i++;
                                        }
                                        $values .= "]";
                                        echo $values; 
                                } else {
                                        echo "['".$dimensionLink['valueColumns']."']";
                                }
                                ?>;
        dim.addLinkToColumn('<?php echo $dimensionLink['linkColumn'];?>', link, values);
        <?php endif; ?>
        
        <?php if (isset($gridFormatters) && ! empty($gridFormatters) ):?>
        <?php foreach ($gridFormatters as $col => $formatter): ?>
        dim.options.grid.columnFormatters['<?php $this->out($col); ?>'] = <?php $this->out($formatter, false);?>;
        <?php endforeach;?>
        <?php endif;?>
        
        <?php if (!empty($excludeColumns)):?>
        dim.options.grid.excludeColumns = [<?php echo $excludeColumns;?>];
        <?php endif; ?>
        dim.asyncQueue.push(['refreshGrid']);
        // add dim object to tab
        tab.addRse('dim', dim);
        // add tab
        OWA.items['<?php echo $dom_id;?>'].addTab( tab );
        <?php endforeach;?>
        // create report tabs
        OWA.items['<?php echo $dom_id;?>'].createTabs();
        
</script>
 
<?php require_once('js_report_templates.php');?>