5e6ba8af
isisadmin
datalet doc update
|
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
|
<!--
@license
The MIT License (MIT)
Copyright (c) 2015 Dipartimento di Informatica - Università di Salerno - Italy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
|
ae17a8dc
Luigi Serra
Controllet and da...
|
26
27
28
29
30
31
32
33
34
|
<!--
* Created by :
* Luigi Serra - luigser@gmail.com
* Andrea Petta - andrpet@gmail.com
*
* Copyright (c) 2015 Dipartimento di Informatica - Università di Salerno - Italy
*
-->
|
a1f0799c
isisadmin
datalet global re...
|
35
|
<link rel="import" href="../base-ajax-json-jsonpath-datalet/base-ajax-json-jsonpath-datalet.html">
|
73bcce88
luigser
COMPONENTS
|
36
|
|
5e6ba8af
isisadmin
datalet doc update
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<!--
The `highcharts-datalet` uses the base-ajax-json-jsonpath-datalet as data retriving and selection mechanism. It defines the common properties
for all the highchart datalets : categories, series and series_type. Overmore override the transformData method
to create and populate categories and series array. Every specific highchart chart implementation (eg linechart, barchart, columnchart ...)
will use highcharts-datalet properties to create the appropriate chart.
Example :
<dom-module id="highcarts-chart-datalet">
<template>
...
<highcharts-datalet id="charts" data-url="{{dataUrl}}" fields="{{fields}}"></highcharts-datalet>
...
</template>
</dom-module>
@element highcharts-datalet
@status v0.1
@homepage
@group datalets
-->
|
73bcce88
luigser
COMPONENTS
|
59
|
<dom-module id="highcharts-datalet">
|
a1f0799c
isisadmin
datalet global re...
|
60
|
|
73bcce88
luigser
COMPONENTS
|
61
62
|
<template>
<div id="container" style="width:auto; height:auto;"></div>
|
a1f0799c
isisadmin
datalet global re...
|
63
|
<base-ajax-json-jsonpath-datalet data-url="{{dataUrl}}" fields="{{fields}}"></base-ajax-json-jsonpath-datalet>
|
73bcce88
luigser
COMPONENTS
|
64
|
</template>
|
a1f0799c
isisadmin
datalet global re...
|
65
|
|
5e6ba8af
isisadmin
datalet doc update
|
66
67
|
<script src="static/js/highcharts.js"></script>
<script src="static/js/exporting.js"></script>
|
a1f0799c
isisadmin
datalet global re...
|
68
|
|
73bcce88
luigser
COMPONENTS
|
69
70
|
<script>
var HighchartsBehavior = {
|
a1f0799c
isisadmin
datalet global re...
|
71
|
|
73bcce88
luigser
COMPONENTS
|
72
|
properties: {
|
a1f0799c
isisadmin
datalet global re...
|
73
|
|
73bcce88
luigser
COMPONENTS
|
74
75
76
77
|
categories: {
type: Array,
value: []
},
|
a1f0799c
isisadmin
datalet global re...
|
78
|
|
73bcce88
luigser
COMPONENTS
|
79
80
81
82
|
series: {
type: Array,
value: []
},
|
a1f0799c
isisadmin
datalet global re...
|
83
|
|
73bcce88
luigser
COMPONENTS
|
84
85
86
87
88
|
series_type:{
type: String,
value: "line"//spline,time
}
},
|
584d6ecd
Luigi Serra
Update components...
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/**
* Normalizes a number in agreement with javascript's conventions. Delete all NaN characters. Exception: number representing lat & long remain unchanged.
*/
jNumConverter: function(num) {
//lat-long
if(num.charAt(num.length-7) == "." && (num.match(/[\.,]/g) || []).length == 1)
return num;
var jNum = "";
for (var i = 0; i < num.length; i++) {
if(num[i].match(/[\.,]/g))
if (i == num.length - 3)
jNum += ".";
else
;
else if (!isNaN(num[i]))
jNum += num[i];
}
|
a1f0799c
isisadmin
datalet global re...
|
107
|
|
584d6ecd
Luigi Serra
Update components...
|
108
109
|
return jNum;
},
|
5e6ba8af
isisadmin
datalet doc update
|
110
111
112
113
114
115
116
|
/**
* Populate the categories and the series array.
*
* @method transformData
*
* @param {Event} e
*/
|
5bc002a2
isisadmin
datalet refactoring
|
117
|
transformData: function () {
|
a1f0799c
isisadmin
datalet global re...
|
118
119
120
121
122
123
124
125
|
this.properties.categories.value = this.data[0].data;
for (var i = 1; i < this.data.length; i++)
{
this.data[i].data.every(function (element, index, array) {
try {
|
584d6ecd
Luigi Serra
Update components...
|
126
127
|
var e = HighchartsBehavior.jNumConverter(element);
(isNaN(element)) ? array[index] = parseFloat(HighchartsBehavior.jNumConverter(element)) :
|
a1f0799c
isisadmin
datalet global re...
|
128
129
130
131
132
133
134
135
|
array[index] = parseFloat(element);
}catch(e){
//console.log("Parsing data error. Highchart-datalet.selectData");
}
return true;
});
this.properties.series.value.push(this.data[i]);
|
73bcce88
luigser
COMPONENTS
|
136
137
138
139
|
}
}
};
|
a1f0799c
isisadmin
datalet global re...
|
140
|
var HighchartsComponentBehavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonJsonPathBehavior, HighchartsBehavior);
|
73bcce88
luigser
COMPONENTS
|
141
142
143
144
145
146
147
|
HighchartsDatalet = Polymer({
is : 'highcharts-datalet'
});
</script>
</dom-module>
|