1
|
<!DOCTYPE html
|
2
|
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
<html>
|
5
|
<?php
|
6
|
|
7
|
require_once('controller.php');
|
8
|
$controller = new Controller(false);
|
9
|
|
10
|
if(!isset($_GET['com'])) {
|
11
|
echo "no command given";
|
12
|
return;
|
13
|
}
|
14
|
if($_GET['com'] != "query"){
|
15
|
echo "unknown command code";
|
16
|
return;
|
17
|
}
|
18
|
|
19
|
//make the query
|
20
|
if(!isset($_GET['persistent'])){
|
21
|
|
22
|
$persistent="true";
|
23
|
}
|
24
|
else
|
25
|
{
|
26
|
$persistent="false";
|
27
|
}
|
28
|
$selectedData = json_encode($_GET['data']);
|
29
|
$resp = $controller->makeQuery('chart',$persistent);
|
30
|
|
31
|
//echo "selected ".json_encode($_GET['data'],JSON_NUMERIC_CHECK);
|
32
|
//each filter to be included get its data and build the json object for the javascript
|
33
|
//echo "will include ".count($_GET['data']['incfilters'])." filters";
|
34
|
|
35
|
$myData = json_decode($_GET['data']);
|
36
|
|
37
|
if(isset($myData->incfilters))
|
38
|
$myfilters = $myData->incfilters;
|
39
|
else
|
40
|
$myfilters = array();
|
41
|
|
42
|
|
43
|
for($i=0;$i<count($myfilters);$i++){
|
44
|
if(isset($myfilters[$i]->values) && $myfilters[$i]->values=='all'){
|
45
|
$temp = $controller->getFilterData($myData->table,$myfilters[$i]->name);
|
46
|
if(!is_array($temp)){
|
47
|
$temp = json_decode($temp);
|
48
|
}
|
49
|
//print_r($temp->data);
|
50
|
$myfilters[$i]->values = $temp->data;
|
51
|
}
|
52
|
}
|
53
|
|
54
|
?>
|
55
|
<head>
|
56
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
57
|
<title>chart</title>
|
58
|
<!-- Include JQuery Core-->
|
59
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
60
|
<script type="text/javascript" src="./js/jquery-ui-1.9.1.custom/js/jquery-ui-1.9.1.custom.js"></script>
|
61
|
|
62
|
<!-- HighCharts -->
|
63
|
<script src="./js/Highcharts-4.0.1/js/highcharts.js" type="text/javascript"></script>
|
64
|
<script src="./js/Highcharts-4.0.1/js/modules/exporting.js" type="text/javascript"></script>
|
65
|
|
66
|
|
67
|
|
68
|
<script src="./js/themes9.js" type="text/javascript"></script>
|
69
|
<!--Styles-->
|
70
|
<link rel="stylesheet" href="//code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
|
71
|
<link type="text/css" href="./js/jquery/css/start/jquery-ui-1.8.20.custom.css" />
|
72
|
<link type="text/css" href="./js/highcharts.css" rel="stylesheet" />
|
73
|
<link rel="stylesheet" href="js/filters.css" />
|
74
|
|
75
|
<!--
|
76
|
<script src="http://code.highcharts.com/highcharts.js"></script>
|
77
|
<script src="http://code.highcharts.com/modules/data.js"></script>
|
78
|
<script src="http://code.highcharts.com/modules/exporting.js"></script>
|
79
|
-->
|
80
|
|
81
|
|
82
|
<script type='text/javascript'>
|
83
|
var chart;
|
84
|
var chart2;
|
85
|
var chartData;
|
86
|
var chartData2;
|
87
|
var chartDataFromServer;
|
88
|
var selectedData;
|
89
|
var filterData;
|
90
|
var myFilter;
|
91
|
//----------------- inits --------------------//
|
92
|
var wflag = <?php if(isset($_GET['w']) && $_GET['w']!='' && $_GET['w'][strlen($_GET['w'])-1] == '%'){ echo "true"; }
|
93
|
else{ echo "false"; }?>
|
94
|
|
95
|
var mywidth = <?php if(isset($_GET['w']) && $_GET['w']!=''){
|
96
|
if($_GET['w'][strlen($_GET['w'])-1] == '%'){
|
97
|
echo substr($_GET['w'],0,strlen($_GET['w'])-1);
|
98
|
|
99
|
}else{
|
100
|
if($_GET['w'][strlen($_GET['w'])-1] == 'x'){
|
101
|
echo substr($_GET['w'],0,strlen($_GET['w'])-2);
|
102
|
}else echo $_GET['w'];
|
103
|
}
|
104
|
}else echo '700'; ?>;
|
105
|
|
106
|
var hflag = <?php if(isset($_GET['h']) && $_GET['h']!='' && $_GET['h'][strlen($_GET['h'])-1] == '%'){ echo "true"; }
|
107
|
else{ echo "false"; }?>
|
108
|
|
109
|
var myheight = <?php if(isset($_GET['h']) && $_GET['h']!=''){
|
110
|
if($_GET['h'][strlen($_GET['h'])-1] == '%'){
|
111
|
echo substr($_GET['h'],0,strlen($_GET['h'])-1);
|
112
|
}else{
|
113
|
if($_GET['w'][strlen($_GET['h'])-1] == 'x'){
|
114
|
echo substr($_GET['h'],0,strlen($_GET['h'])-2);
|
115
|
} else echo $_GET['h'];
|
116
|
}
|
117
|
}else echo '500'; ?>;
|
118
|
|
119
|
//----------------- document ready --------------------//
|
120
|
$('document').ready(function(){
|
121
|
chartDataFromServer = <?php echo $resp ?>;
|
122
|
selectedData = $.parseJSON(<?php echo $selectedData;?>);
|
123
|
filterData = <?php echo json_encode($myfilters);?>;
|
124
|
|
125
|
renderChart();
|
126
|
renderfilters();
|
127
|
controlsforfilters();
|
128
|
});
|
129
|
|
130
|
function renderChart(){
|
131
|
|
132
|
if(selectedData['in'] != undefined && selectedData['in'].length>0){
|
133
|
if(chartDataFromServer[0].plotOptions != undefined && chartDataFromServer[0].plotOptions.series != undefined){
|
134
|
chartDataFromServer[0].plotOptions.series.events = new Object();
|
135
|
chartDataFromServer[0].plotOptions.series.events.checkboxClick = function(event){if(event.checked == true) this.show(); else this.hide();};
|
136
|
}
|
137
|
if(chartDataFromServer[1].plotOptions != undefined && chartDataFromServer[1].plotOptions.series != undefined){
|
138
|
chartDataFromServer[1].plotOptions.series.events = new Object();
|
139
|
chartDataFromServer[1].plotOptions.series.events.checkboxClick = function(event){if(event.checked == true) this.show(); else this.hide();};
|
140
|
}
|
141
|
chartData = chartDataFromServer[0];
|
142
|
chartData2 = chartDataFromServer[1];
|
143
|
setSelections();
|
144
|
}
|
145
|
else{
|
146
|
if(chartDataFromServer.plotOptions != undefined && chartDataFromServer.plotOptions.series != undefined){
|
147
|
chartDataFromServer.plotOptions.series.events = new Object();
|
148
|
chartDataFromServer.plotOptions.series.events.checkboxClick = function(event){if(event.checked == true) this.show(); else this.hide();};
|
149
|
}
|
150
|
chartData = chartDataFromServer;
|
151
|
}
|
152
|
var formatter = chartData.xAxis.labels.formatter;
|
153
|
if(selectedData['emp'] == undefined)
|
154
|
selectedData['emp'] = new Array();
|
155
|
else{
|
156
|
chartData.xAxis.plotLines = new Array();
|
157
|
for(var e=0;e<selectedData['emp'].length;e++){
|
158
|
var line = new Object();
|
159
|
line.value = chartData['xAxis']['categories'].indexOf(selectedData['emp'][e]);
|
160
|
line.width = 1;
|
161
|
line.color = 'red';
|
162
|
line.dashStyle = 'dash';
|
163
|
line.zIndex = 100;
|
164
|
chartData.xAxis.plotLines.push(line);
|
165
|
}
|
166
|
}
|
167
|
|
168
|
if(selectedData['bands'] != undefined){
|
169
|
chartData['xAxis']['plotBands'] = new Array();
|
170
|
for(var b=0;b<selectedData['bands'].length;b++){
|
171
|
var band = new Object();
|
172
|
band.color = '#FCFFC5';
|
173
|
var from = chartData.xAxis.categories.indexOf(selectedData['bands'][b][0]);
|
174
|
var to = chartData.xAxis.categories.indexOf(selectedData['bands'][b][1]);
|
175
|
band.from = from;
|
176
|
band.to = (to==-1)? chartData.xAxis.categories.length:to;
|
177
|
band.zIndex = -100;
|
178
|
chartData.xAxis.plotBands.push(band);
|
179
|
}
|
180
|
}
|
181
|
|
182
|
if(selectedData['xStyle'] != undefined){
|
183
|
chartData.xAxis.labels = labelsforx(selectedData['xStyle'],selectedData['emp']);
|
184
|
}
|
185
|
else{
|
186
|
var temp = new Object(); temp['r'] = '-'; temp['s'] = '-'; temp['l'] = '-';
|
187
|
chartData.xAxis.labels = labelsforx(temp,selectedDatap['emp']);
|
188
|
}
|
189
|
|
190
|
//headers!!!!
|
191
|
if(typeof selectedData['title'] != 'undefined' && selectedData['title']!=''){
|
192
|
chartData.title = new Object();
|
193
|
chartData.title.text = selectedData['title'];
|
194
|
chartData.title.align = 'center';
|
195
|
}
|
196
|
else{
|
197
|
chartData.title.text = null;
|
198
|
}
|
199
|
if(selectedData['subtitle']!=''){
|
200
|
chartData.subtitle = new Object();
|
201
|
chartData.subtitle.text = selectedData['subtitle'];
|
202
|
}
|
203
|
else{
|
204
|
chartData.subtitle = null;
|
205
|
}
|
206
|
|
207
|
|
208
|
if(selectedData['fields'].length == 1 && selectedData['fields'][0]['type'] == 'pie'){
|
209
|
chartData.xAxis.title.text = null;
|
210
|
chartData.yAxis[0].title.text = null;
|
211
|
$("#zoommessage").hide();
|
212
|
}
|
213
|
|
214
|
//chartData.xAxis.title.text = selectedData['xaxis']['name'];
|
215
|
var today = new Date();
|
216
|
var dd = today.getDate();
|
217
|
var mm = today.getMonth()+1; //January is 0!
|
218
|
|
219
|
var yyyy = today.getFullYear();
|
220
|
chartData.credits.text = "from OpenAIRE via HighCharts (date: " + dd + "/" + mm + "/" + yyyy +")";
|
221
|
|
222
|
if(selectedData['stacking']!=undefined){
|
223
|
chartData['plotOptions']['column']['stacking'] = selectedData['stacking'];
|
224
|
chartData['plotOptions']['area']['stacking'] = selectedData['stacking'];
|
225
|
chartData['plotOptions']['areaspline']['stacking'] = selectedData['stacking'];
|
226
|
}
|
227
|
//TODO ERI: HERE WE CHANGE THE LABEL FOR PIE CHARTS
|
228
|
//WE CAN ADD EITHER THE PERCENTAGE OF THE NUMERIC VALUE
|
229
|
//THERE IS THE SAME FOR EACH CHART TYPE
|
230
|
|
231
|
chartData.plotOptions['pie']['dataLabels']['formatter'] = function() {
|
232
|
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 2) +' %'+'<br>'+ '( '+this.y+' Items )';
|
233
|
};
|
234
|
|
235
|
if(chartData.series.length > 4){
|
236
|
chartData.legend.layout = 'horizontal';
|
237
|
chartData.legend.align = 'center';
|
238
|
chartData.legend.verticalAlign = 'bottom';
|
239
|
chartData.legend.x = null;
|
240
|
chartData.legend.y = null;
|
241
|
chartData.legend.floating = false;
|
242
|
//chartData.legend.itemStyle = new Object();
|
243
|
//chartData.legend.itemStyle.margin = "4px";
|
244
|
}
|
245
|
|
246
|
if(selectedData['type'] == 'scatter'){
|
247
|
if(selectedData['color'] == 'yes')
|
248
|
chartData.tooltip.formatter = function() { return '<b>'+ this.series.name +'</b><br/>'+ chartData['xAxis']['title']['text']+ ': '+ this.x +'<br/>'+ chartData['yAxis'][0]['title']['text']+': '+ this.y ;};
|
249
|
else if(selectedData['group'] != '')
|
250
|
chartData.tooltip.formatter = function() { return '<b>'+ this.point.name +'</b><br/>'+ chartData['xAxis']['title']['text']+ ': '+ this.x +'<br/>'+ chartData['yAxis'][0]['title']['text']+': '+ this.y ;};
|
251
|
else
|
252
|
chartData.tooltip.formatter = function() { return chartData['xAxis']['title']['text']+ ': '+ this.x +'<br/>'+ chartData['yAxis'][0]['title']['text']+': '+ this.y ;};
|
253
|
chartData['chart']['type'] = 'scatter';
|
254
|
}
|
255
|
else {
|
256
|
chartData.tooltip.percentageDecimals = 1;
|
257
|
chartData.tooltip.valueDecimals = 1;
|
258
|
if(selectedData['fields'][0]['type'] != 'pie'){
|
259
|
//chartData.tooltip.headerFormat = '<span style="font-size:10px">{point.key}</span><table>';
|
260
|
//chartData.tooltip.pointFormat = '<tr><td style="color:{series.color};padding:0">{series.name}:</td>'+'<td style="padding:0"><b>{point.y}</b></td></tr>';
|
261
|
//chartData.tooltip.footerFormat = '</table>';
|
262
|
chartData.tooltip.shared = true;
|
263
|
chartData.tooltip.useHTML = true;
|
264
|
}
|
265
|
//else
|
266
|
chartData.tooltip.formatter = function() {
|
267
|
if(selectedData['fields'][0]['type']!='pie'){
|
268
|
/*//var ind = chart.xAxis[0].categories.indexOf(this.x);
|
269
|
var str = '';
|
270
|
if(this.point.config.name)
|
271
|
str += '<b>'+ this.point.config.name +'</b><br/>';
|
272
|
//str += this.x + '<br />';
|
273
|
//var myseries = chart.series;
|
274
|
//for(var i=0;i<myseries.length;i++){
|
275
|
// str += myseries[i].name + ":" + numberWithCommas(myseries[i].data[ind].y) + "<br />";
|
276
|
//}
|
277
|
str += this.series.name + ': '+ '<b>' + numberWithCommas(this.y) + '</b><br/>';
|
278
|
str += chart.xAxis[0].axisTitle.textStr + ": <b>" + this.x + '</b>';
|
279
|
return str;*/
|
280
|
var s = '<b>'+ this.x +'</b>';
|
281
|
|
282
|
$.each(this.points, function(i, point) {
|
283
|
s += '<br/><span style="color:'+point.series.color+'">'+ point.series.name +'</span>: '+
|
284
|
numberWithCommas(point.y);
|
285
|
});
|
286
|
|
287
|
return s;
|
288
|
}
|
289
|
else{
|
290
|
var name;
|
291
|
if(selectedData['fieldsheaders'].length >0)
|
292
|
name = selectedData['fieldsheaders'][0];
|
293
|
else if(selectedData['yaxisheaders'].length>0)
|
294
|
name = selectedData['yaxisheaders'][0];
|
295
|
else
|
296
|
name = "number";
|
297
|
return '<b>'+ this.point.config.name +'</b>: ' + Highcharts.numberFormat(this.percentage, 2) +' %<br/>(' + name + ": " + numberWithCommas(this.y) +")";
|
298
|
}
|
299
|
};
|
300
|
if(selectedData['fields'].length==1)
|
301
|
chartData['chart']['type'] = selectedData['fields'][0]['type'];
|
302
|
|
303
|
}
|
304
|
if('theme' in selectedData){
|
305
|
highchartsOptions = Highcharts.setOptions(themes[selectedData['theme']][1]);
|
306
|
}
|
307
|
else
|
308
|
highchartsOptions = Highcharts.setOptions(themes[0][1]);
|
309
|
|
310
|
|
311
|
// alert('document width ' + $(document).width() + 'and height ' + $(document).height() ' and chart width' + chartData.chart.width);
|
312
|
|
313
|
|
314
|
|
315
|
if(mywidth>0)
|
316
|
{
|
317
|
if(wflag)
|
318
|
chartData.chart.width = mywidth * $(document).width() /100;
|
319
|
else
|
320
|
chartData.chart.width = mywidth;
|
321
|
}
|
322
|
else{
|
323
|
chartData.chart.width = 90 * $(document).width() / 100;
|
324
|
|
325
|
}
|
326
|
|
327
|
if(myheight>0){
|
328
|
if(hflag)
|
329
|
chartData.chart.height = myheight * $(document).height() /100;
|
330
|
else
|
331
|
chartData.chart.height = myheight;
|
332
|
}
|
333
|
else
|
334
|
{chartData.chart.height = 80 * $(document).height() /100;
|
335
|
}
|
336
|
|
337
|
|
338
|
chartData.exporting = JSON.parse( '{ "url" : "<?php echo $export_server ?>" }');
|
339
|
|
340
|
chart = new Highcharts.Chart(chartData, function(chart){
|
341
|
var series = chart.series;
|
342
|
var i=0;
|
343
|
for(; i<series.length; i++){
|
344
|
if( series[i].legendItem && series[i].checkbox) {
|
345
|
series[i].checkbox.style.marginLeft = '18px';
|
346
|
}
|
347
|
}
|
348
|
});
|
349
|
|
350
|
|
351
|
//chart.setSize(mywidth, myheight, false);
|
352
|
//alert(JSON.stringify(chartData));
|
353
|
if(selectedData['in'] != undefined && selectedData['in'].length>0){
|
354
|
if(chartData.xAxis.labels != undefined) chartData2.xAxis.labels = chartData.xAxis.labels
|
355
|
if(chartData.title != undefined) {chartData2.title = new Object(); chartData2.title.text = chartData.title.text;}
|
356
|
if(chartData.subtitle != undefined) {chartData2.subtitle = new Object(); chartData2.subtitle.text = chartData.subtitle.text;}
|
357
|
chartData2.xAxis.title.text = chartData.xAxis.title.text;
|
358
|
chartData2.yAxis[0].title.text = chartData.yAxis[0].title.text;
|
359
|
chartData2.credits.text = chartData.credits.text;
|
360
|
chartData2.plotOptions['pie']['dataLabels']['formatter'] = chartData.plotOptions['pie']['dataLabels']['formatter'];
|
361
|
chartData2.tooltip = chartData.tooltip;
|
362
|
chartData2['chart']['type'] = chartData['chart']['type'];
|
363
|
chartData2['chart']['renderTo'] = 'chart2';
|
364
|
chartData2['xAxis']['plotLines'] = chartData['xAxis']['plotLines'];
|
365
|
chartData2['xAxis']['plotBands'] = chartData['xAxis']['plotBands'];
|
366
|
if(chartData['chart']['height'] != undefined)
|
367
|
chartData2['chart']['height'] = chartData['chart']['height'];
|
368
|
if(chartData['chart']['width'] != undefined)
|
369
|
chartData2['chart']['width'] = chartData['chart']['width'];
|
370
|
if(selectedData['xStyle'] != undefined){
|
371
|
chartData2.xAxis.labels = labelsforx(selectedData['xStyle'],selectedData['emp']);
|
372
|
}
|
373
|
else{
|
374
|
var temp = new Object(); temp['r'] = '-'; temp['s'] = '-'; temp['l'] = '-';
|
375
|
chartData2.xAxis.labels = labelsforx(temp,selectedData['emp']);
|
376
|
}
|
377
|
if(selectedData['stacking']!=undefined){
|
378
|
chartData2['plotOptions']['column']['stacking'] = selectedData['stacking'];
|
379
|
chartData2['plotOptions']['area']['stacking'] = selectedData['stacking'];
|
380
|
chartData2['plotOptions']['areaspline']['stacking'] = selectedData['stacking'];
|
381
|
}
|
382
|
|
383
|
if(chartData2.series.length > 4)
|
384
|
chartData2.legend = chartData.legend;
|
385
|
//chartData2.plotOptions.column.pointWidth = 30;
|
386
|
chart2 = new Highcharts.Chart(chartData2, function(chart2){
|
387
|
var series = chart2.series;
|
388
|
var i=0;
|
389
|
for(; i<series.length; i++){
|
390
|
if( series[i].legendItem && series[i].checkbox) {
|
391
|
series[i].checkbox.style.marginLeft = '18px';
|
392
|
}
|
393
|
}
|
394
|
});
|
395
|
|
396
|
}
|
397
|
//exporting: { enabled: false }
|
398
|
|
399
|
//chartData['plotOptions']['exporting']['enabled']='false';
|
400
|
|
401
|
//credits();
|
402
|
}
|
403
|
|
404
|
|
405
|
function setSelections(){
|
406
|
var str = "<input type='radio' name='sel' checked value='not'/>"+selectedData['in'][0]['text']+"   <input type='radio' name='sel' value='cumulate'/>Cumulative" ;
|
407
|
$("#selections").empty().append(str);
|
408
|
|
409
|
$("input[name='sel']").live("click",function(){
|
410
|
if($(this).val() == "cumulate"){
|
411
|
$("#chart").hide();
|
412
|
$("#chart2").show();
|
413
|
}
|
414
|
else{
|
415
|
$("#chart2").hide();
|
416
|
$("#chart").show();
|
417
|
}
|
418
|
});
|
419
|
}
|
420
|
|
421
|
function controlsforfilters(){
|
422
|
$("a.all").live("click",function(){
|
423
|
$(this).siblings('.filterForm').find('input').attr("checked","checked");
|
424
|
newValues($(this).siblings('.filterForm').find('input')[0]);
|
425
|
return false;
|
426
|
});
|
427
|
|
428
|
$("a.none").live("click",function(){
|
429
|
$(this).siblings('.filterForm').find('input').removeAttr("checked");
|
430
|
newValues($(this).siblings('.filterForm').find('input')[0]);
|
431
|
return false;
|
432
|
});
|
433
|
|
434
|
$(".formContainer input").live("click",function(){
|
435
|
newValues(this);
|
436
|
});
|
437
|
}
|
438
|
|
439
|
function newValues(obj){
|
440
|
var field = $(obj).parent().attr('id');
|
441
|
var myfilters = selectedData['filters'];
|
442
|
var thisfilter;
|
443
|
for(var i=0;i<selectedData['incfilters'].length;i++){
|
444
|
if(selectedData['incfilters'][i]['name'] == field){
|
445
|
thisfilter = selectedData['incfilters'][i];
|
446
|
break;
|
447
|
}
|
448
|
}
|
449
|
|
450
|
//change the url params
|
451
|
//if is it checked
|
452
|
if($(obj).is(":checked")){
|
453
|
$(obj).parents(".filter").find("a.none").show();
|
454
|
var flag = false;
|
455
|
var i;
|
456
|
for(i=0;i<myfilters.length;i++){
|
457
|
if(myfilters[i]['name'] == field){
|
458
|
flag=true;
|
459
|
break;
|
460
|
}
|
461
|
}
|
462
|
//if there is already such a filter delete all values and insert all the checked
|
463
|
if(flag){
|
464
|
myfilters[i].values = new Array();
|
465
|
$(obj).parent().find("input:checked").each(function(){
|
466
|
myfilters[i].values.push($(this).val());
|
467
|
});
|
468
|
//myfilters[i].values.push($(obj).val());
|
469
|
}
|
470
|
//if there is no such filter
|
471
|
else{
|
472
|
//create one
|
473
|
var newfilter = new Object();
|
474
|
newfilter.name = field;
|
475
|
newfilter.values = new Array();
|
476
|
var ch = $(obj).parent().find("input:checked");
|
477
|
$(ch).each(function(){
|
478
|
newfilter.values.push($(this).val());
|
479
|
});
|
480
|
//newfilter.values[0] = $(obj).val();
|
481
|
myfilters.push(newfilter);
|
482
|
}
|
483
|
}
|
484
|
//if it was unchecked
|
485
|
else{
|
486
|
//there should be already such a filter
|
487
|
var flag = false;
|
488
|
var i;
|
489
|
for(i=0;i<myfilters.length;i++){
|
490
|
if(myfilters[i]['name'] == field){
|
491
|
flag=true;
|
492
|
break;
|
493
|
}
|
494
|
}
|
495
|
//remove the value
|
496
|
if($(obj).parent().find("input:checked").length == 0){
|
497
|
$(obj).parents(".filter").find("a.none").hide();
|
498
|
myfilters[i].values = new Array();
|
499
|
}
|
500
|
else{
|
501
|
var j;
|
502
|
for(j=0;j<myfilters[i].values.length;j++){
|
503
|
if(myfilters[i].values[j] == $(obj).val()){
|
504
|
myfilters[i].values.splice(j,1);
|
505
|
break;
|
506
|
}
|
507
|
}
|
508
|
}
|
509
|
|
510
|
|
511
|
//if no more values, add the values in the incfilter list and if it is all remove the filter
|
512
|
if(myfilters[i].values.length == 0){
|
513
|
if(thisfilter.values[0]=="all")
|
514
|
myfilters.splice(i,1);
|
515
|
else
|
516
|
myfilters[i].values = thisfilter.values;
|
517
|
}
|
518
|
}
|
519
|
//ajax call to get the new data
|
520
|
$.ajax({
|
521
|
type: "GET",
|
522
|
url: "ajaxRouter9.php",
|
523
|
data: "com=query&type=chart&data="+encodeURIComponent(JSON.stringify(selectedData)),
|
524
|
success: function(resp){
|
525
|
// we have the response
|
526
|
chartDataFromServer = JSON.parse(resp);
|
527
|
renderChart();
|
528
|
},
|
529
|
error: function(e){
|
530
|
alert('Error: ' + e);
|
531
|
}
|
532
|
});
|
533
|
|
534
|
}
|
535
|
|
536
|
|
537
|
function labelsforx(style, emp){
|
538
|
var st = Object();
|
539
|
st.justify = null;
|
540
|
st.style = Array();
|
541
|
st.style['font-size'] = '10px';
|
542
|
st.formatter = null;
|
543
|
|
544
|
if(style['r'] != null && style['r'] != "-"){
|
545
|
st.rotation = style['r'];
|
546
|
st.y =25;
|
547
|
}
|
548
|
if(style['s'] != null && style['s'] != "-")
|
549
|
st.step = style['s'];
|
550
|
if(style['l'] != null && style['l'] != "-")
|
551
|
st.staggerLines = style['l'];
|
552
|
|
553
|
if(style['ft'] != null && style['ft'] != "-"){
|
554
|
if(style['wt'] != null && style['wt'] != "-")
|
555
|
st.formatter = function(){
|
556
|
eflag = false;
|
557
|
for(var e=0;e<emp.length;e++){
|
558
|
if(this.value == emp[e]){
|
559
|
eflag = true;
|
560
|
break;
|
561
|
}
|
562
|
}
|
563
|
|
564
|
if (typeof this.value == 'string' || this.value instanceof String){
|
565
|
var ar = this.value.split(" ");
|
566
|
var str = '';
|
567
|
if(ar.length == 1){
|
568
|
if(eflag) return '<span style="fill:red;">' + this.value.substr(0,selectedData['xStyle']['ft']) + '</span>';
|
569
|
else return this.value.substr(0,selectedData['xStyle']['ft']);
|
570
|
}
|
571
|
for(var i=0;i<ar.length;i++) {
|
572
|
str +=ar[i].substr(0,selectedData['xStyle']['wt'])+' ';
|
573
|
}
|
574
|
if(eflag) return '<span style="fill:red;">' + str.substr(0,selectedData['xStyle']['ft']) + '</span>';
|
575
|
else return str.substr(0,selectedData['xStyle']['ft']);
|
576
|
}
|
577
|
else
|
578
|
if(eflag) return '<span style="fill:red;">' + this.value + '</span>';
|
579
|
};
|
580
|
else
|
581
|
st.formatter = function(){
|
582
|
eflag = false;
|
583
|
for(var e=0;e<emp.length;e++){
|
584
|
if(this.value == emp[e]){
|
585
|
eflag = true;
|
586
|
break;
|
587
|
}
|
588
|
}
|
589
|
|
590
|
if (typeof this.value == 'string' || this.value instanceof String){
|
591
|
if(this.value.length>selectedData['xStyle']['ft'])
|
592
|
if(eflag) return '<span style="fill:red;">' + this.value.substr(0,selectedData['xStyle']['ft']) + "..." + '</span>';
|
593
|
else return this.value.substr(0,selectedData['xStyle']['ft']) + "...";
|
594
|
else
|
595
|
if(eflag) return '<span style="fill:red;">' + this.value + '</span>';
|
596
|
else return this.value;
|
597
|
}
|
598
|
else return this.value;
|
599
|
};
|
600
|
}
|
601
|
else if(style['wt'] != null && style['wt'] != "-")
|
602
|
st.formatter = function(){
|
603
|
eflag = false;
|
604
|
for(var e=0;e<emp.length;e++){
|
605
|
if(this.value == emp[e]){
|
606
|
eflag = true;
|
607
|
break;
|
608
|
}
|
609
|
}
|
610
|
if (typeof this.value == 'string' || this.value instanceof String){
|
611
|
var ar = this.value.split(" ");
|
612
|
var str = '';
|
613
|
if(ar.length == 1)
|
614
|
if(eflag) return '<span style="fill:red;">' + this.value + '</span>';
|
615
|
else return this.value;
|
616
|
for(var i=0;i<ar.length;i++) {
|
617
|
str +=ar[i].substr(0,selectedData['xStyle']['wt'])+' ';
|
618
|
}
|
619
|
if(eflag) return '<span style="fill:red;">' + str + '</span>';
|
620
|
else return str
|
621
|
}
|
622
|
else
|
623
|
if(eflag) return '<span style="fill:red;">' + this.value + '</span>';
|
624
|
};
|
625
|
else{
|
626
|
st.formatter = function(){
|
627
|
for(var e=0;e<emp.length;e++){
|
628
|
if(this.value == emp[e]){
|
629
|
return '<span style="fill:red;">' + this.value + '</span>';
|
630
|
}
|
631
|
}
|
632
|
return this.value;
|
633
|
};
|
634
|
}
|
635
|
return st;
|
636
|
}
|
637
|
|
638
|
function isInt(n) {
|
639
|
return typeof n === 'number' && n % 1 == 0;
|
640
|
}
|
641
|
|
642
|
function numberWithCommas(num){
|
643
|
if(isInt(num)){
|
644
|
var array = num.toString().split('');
|
645
|
var index = -3;
|
646
|
var len = array.length;
|
647
|
while((len + index) > 0){
|
648
|
array.splice(index, 0 , ',');
|
649
|
index -= 4;
|
650
|
}
|
651
|
return array.join('');
|
652
|
}
|
653
|
else
|
654
|
return Math.round(num*100)/100;
|
655
|
}
|
656
|
|
657
|
function credits(){
|
658
|
var today = new Date();
|
659
|
var dd = today.getDate();
|
660
|
var mm = today.getMonth()+1; //January is 0!
|
661
|
var yyyy = today.getFullYear();
|
662
|
var cr = document.getElementById("credits");
|
663
|
cr.innerHTML = "from OpenAIRE via HighCharts (date: " + dd + "/" + mm + "/" + yyyy +")";
|
664
|
}
|
665
|
|
666
|
function renderfilters(){
|
667
|
var container = document.getElementById("filters");
|
668
|
if(filterData!=null){
|
669
|
var len = filterData.length;
|
670
|
for(var i=0;i<len;i++){
|
671
|
//checkboxes
|
672
|
if(filterData[i].values != undefined){
|
673
|
var str = "<div class='filter'><div class='filterHeader'><p>"+filterData[i].showname+"</p><input type='hidden' value='"+filterData[i].name+"' class='filtername'/></div><a class='all' href='#'>select all</a><a class='none' href='#' style='display:none;float:right'>clear</a><div class='filterForm'><div class='formContainer'><form id='"+filterData[i].name+"' class='filterform'>";
|
674
|
for(var v=0;v<filterData[i].values.length;v++){
|
675
|
str+="<input type='checkbox' value='"+filterData[i].values[v]+"' name='form"+filterData[i].name+"'>"+filterData[i].values[v]+"<br>";
|
676
|
}
|
677
|
str += "</form></div></div></div>";
|
678
|
$(container).append(str);
|
679
|
}
|
680
|
//slider
|
681
|
else{
|
682
|
var str = "<div class='filter'><div class='filterHeader'><p>"+filterData[i].showname+"</p><input type='hidden' value='"+filterData[i].name+"' class='filtername'/></div>";
|
683
|
str += "<div class='filter-slider'><div class='slider-container'><div id='slider"+filterData[i].name+"' class='ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all' aria-disabled='false'></div></div>";
|
684
|
|
685
|
str += "<span class='price-tip slider-user-min'><span id='userMin"+filterData[i].name+"'>"+filterData[i]['min']+"</span></span>";
|
686
|
str += "<span class='price-tip slider-user-max'><span id='userMax"+filterData[i].name+"'>"+filterData[i]['max']+"</span></span>";
|
687
|
str += "<span class='min' style='display:none'><span id='productMin"+filterData[i].name+"'>"+filterData[i]['min']+"</span></span>";
|
688
|
str += "<span class='max' style='display:none'><span id='productMax"+filterData[i].name+"'>"+filterData[i]['max']+"</span></span>";
|
689
|
str += "</div></div>";
|
690
|
$(container).append(str);
|
691
|
myFilter = filterData[i];
|
692
|
$(function(){
|
693
|
$("#slider"+myFilter.name).slider({
|
694
|
step: 1,
|
695
|
range: true,
|
696
|
min: parseInt(myFilter['min']),
|
697
|
max: parseInt(myFilter['max']),
|
698
|
values: [parseInt(myFilter['min']), parseInt(myFilter['max'])],
|
699
|
change: function(event, ui){
|
700
|
$(this).parent().parent().find('.slider-user-min').find('span').html(ui.values[0]);
|
701
|
$(this).parent().parent().find('.slider-user-max').find('span').html(ui.values[1]);
|
702
|
slidermove(myFilter.name,ui.values[0],ui.values[1]);
|
703
|
}
|
704
|
});
|
705
|
});
|
706
|
}
|
707
|
}
|
708
|
}
|
709
|
else{
|
710
|
$(container).css("width","0px");
|
711
|
}
|
712
|
}
|
713
|
|
714
|
function slidermove(field,min,max){
|
715
|
var myfilters = selectedData['filters'];
|
716
|
var len = myfilters.length;
|
717
|
for(var i=0;i<len;i++){
|
718
|
if(myfilters[i]['name'] == field){
|
719
|
myfilters[i]['min'] = min;
|
720
|
myfilters[i]['max'] = max;
|
721
|
break;
|
722
|
}
|
723
|
}
|
724
|
|
725
|
|
726
|
//ajax call to get the new data
|
727
|
$.ajax({
|
728
|
type: "GET",
|
729
|
url: "ajaxRouter9.php",
|
730
|
data: "com=query&type=chart&data="+encodeURIComponent(JSON.stringify(selectedData)),
|
731
|
success: function(resp){
|
732
|
// we have the response
|
733
|
chartDataFromServer = JSON.parse(resp);
|
734
|
renderChart();
|
735
|
},
|
736
|
error: function(e){
|
737
|
alert('Error: ' + e);
|
738
|
}
|
739
|
});
|
740
|
}
|
741
|
</script>
|
742
|
</head>
|
743
|
<body>
|
744
|
<div id="filters"></div>
|
745
|
<div id="charts-main" style="margin-right:10px;float:left">
|
746
|
<div id='chart' style="width:95%;height:95%;margin:auto;"></div>
|
747
|
<div id='chart2' style="width:95%;height:95%;margin:auto;display:none;"><!-- SECTION FOR THE GRAPHIC --></div>
|
748
|
|
749
|
<div id="selections" style="width:95%;height:5%;margin:auto;text-align:center;font-family:Verdana;font-size:small;color:#000"></div>
|
750
|
<!-- <div id='credits'></div>
|
751
|
<div id='zoommessage'>select an area to zoom in</div>
|
752
|
-->
|
753
|
</div>
|
754
|
</body>
|
755
|
</html>
|
756
|
|