Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15607 anikendra 1
<?php 
2
	$brands = array();
3
	$map = array();
4
	$dates = array();
5
	foreach ($brand_preferences as $key => $value) {
6
		$brands[$value['brand_preferences']['brand']] = $value['brand_preferences']['brand'];
7
		$dates[$value[0]['date']] = $value[0]['date'];
8
		$map[$value[0]['date']][$value['brand_preferences']['brand']] = $value[0]['count'];
9
	}
10
?>
11
 
12
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
13
 
14
<script type="text/javascript">
15
google.load('visualization', '1', {packages: ['corechart', 'line']});
16
google.setOnLoadCallback(drawAxisTickColors);
17
 
18
function drawAxisTickColors() {
19
      var data = new google.visualization.DataTable();
20
      data.addColumn('date', 'Date');
21
      <?php foreach ($brands as $key => $value):?>
22
      	data.addColumn('number', '<?php echo $value;?>');
23
      <?php endforeach;?>
24
 
25
      data.addRows([
26
      <?php foreach ($dates as $key => $date):?>
27
      	[new Date('<?php echo $date;?>'),
28
      	<?php foreach ($brands as $key => $brand) :?>
29
      		<?php if(isset($map[$date][$brand])):?>
30
      			<?php echo $map[$date][$brand];?>,
31
  			<?php else:?>
32
  				0,
33
			<?php endif;?>
34
      	<?php endforeach;?>
35
      	],
36
      <?php endforeach;?>      
37
      ]);
38
 
39
      var options = {
40
        hAxis: {
41
          title: 'Date',
42
          textStyle: {
43
            color: '#01579b',
44
            fontSize: 20,
45
            fontName: 'Arial',
46
            bold: true,
47
            italic: true
48
          },
49
          titleTextStyle: {
50
            color: '#01579b',
51
            fontSize: 16,
52
            fontName: 'Arial',
53
            bold: false,
54
            italic: true
55
          }
56
        },
57
        vAxis: {
58
          title: 'Count',
59
          textStyle: {
60
            color: '#1a237e',
61
            fontSize: 24,
62
            bold: true
63
          },
64
          titleTextStyle: {
65
            color: '#1a237e',
66
            fontSize: 24,
67
            bold: true
68
          }
69
        },
70
        colors: ['#a52714', '#097138']
71
      };
72
      var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
73
      chart.draw(data, options);
74
    }
75
</script>
76
 
77
<div class="table-responsive">
78
	<table id="example" class="display table table-striped" cellspacing="0" width="100%">
79
	    <thead>
80
	        <tr>
81
	            <th>Date</th>
82
	            <?php foreach ($brands as $key => $brand):?>
83
	            <th><?php echo ucfirst($brand);?></th>	
84
	            <?php endforeach;?>
85
	        </tr>
86
	    </thead>
87
	    <tfoot>
88
	        <tr>
89
	            <th>Date</th>
90
	            <?php foreach ($brands as $key => $brand):?>
91
	            <th><?php echo ucfirst($brand);?></th>	
92
	            <?php endforeach;?>
93
	        </tr>
94
	    </tfoot>
95
	    <tbody>
96
	    	<?php foreach ($dates as $key => $date):?>
97
	      	<tr>
98
	      		<td><?php echo $date;?></td>
99
	      		<?php foreach ($brands as $key => $brand) :?>
100
	      			<td>
101
		      		<?php if(isset($map[$date][$brand])):?>
102
		      			<?php echo $map[$date][$brand];?>
103
		  			<?php else:?>
104
 
105
					<?php endif;?>
106
					</td>
107
	      		<?php endforeach;?>
108
	      	</tr>
109
	      <?php endforeach;?>      
110
		</tbody>
111
	</table>            
112
</div>
113
 
114
<div id="chart_div" style="width: 1200px; height: 900px"><div>
115
 
116
<script type="text/javascript" src="//cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
117
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.7/css/jquery.dataTables.css"></link>
118
<script type="text/javascript">
119
$(document).ready(function() {
120
    $('#example').DataTable();
121
} );
122
</script>