Skip to content

Commit f57a954

Browse files
committed
GH ACTION Autorun Tue Apr 7 13:08:42 UTC 2026
1 parent bd5c400 commit f57a954

File tree

20 files changed

+14892
-0
lines changed

20 files changed

+14892
-0
lines changed

data/traffic/2026-04-07 13:08:31_porto.html

Lines changed: 4682 additions & 0 deletions
Large diffs are not rendered by default.

data/traffic/2026-04-07 13:08:31_porto_files/google_map-binding-2.7.8/google_map.js

Lines changed: 590 additions & 0 deletions
Large diffs are not rendered by default.

data/traffic/2026-04-07 13:08:31_porto_files/htmlwidgets-1.6.4/htmlwidgets.js

Lines changed: 901 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Chart JSON
3+
*
4+
* creates the required JSON that feeds a Google DataTable
5+
*
6+
* @param cols
7+
* The column headings
8+
* @param rows
9+
* Rows of data
10+
**/
11+
function chartJson(cols, rows) {
12+
return ('{' + cols + ',' + rows + '}');
13+
}
14+
15+
16+
function isChartsLoaded() {
17+
if (typeof google.visualization === undefined) {
18+
return false;
19+
} else {
20+
return true;
21+
}
22+
}
23+
24+
/**
25+
* Chart Type
26+
*
27+
* Returns a chart object
28+
*
29+
* @param type
30+
* String specifying the type of chart (e.g. 'line', 'pie', ...)
31+
* @param node
32+
* document.element 'div' node
33+
*
34+
**/
35+
function chartType(type, node) {
36+
if (type === 'area') {
37+
return (new google.visualization.AreaChart(node));
38+
} else if (type === 'bar') {
39+
return (new google.visualization.BarChart(node));
40+
} else if (type == 'bubble') {
41+
return (new google.visualization.BubbleChart(node));
42+
} else if (type == 'candlestick') {
43+
return (new google.visualization.CandlestickChart(node));
44+
} else if (type == 'column') {
45+
return (new google.visualization.ColumnChart(node));
46+
} else if (type === 'combo') {
47+
return (new google.visualization.ComboChart(node));
48+
} else if (type === 'histogram') {
49+
return (new google.visualization.Histogram(node));
50+
} else if (type === 'line') {
51+
return (new google.visualization.LineChart(node));
52+
} else if (type === 'pie') {
53+
return (new google.visualization.PieChart(node));
54+
} else if (type === 'scatter') {
55+
return (new google.visualization.ScatterChart(node));
56+
}
57+
}
58+
59+
/**
60+
* Chart Options
61+
*
62+
* set the options for a chart
63+
*
64+
* @param mapObject
65+
* map object containing the option data
66+
**/
67+
function chartOptions(mapObject) {
68+
var options = {'title': 'Marker location: ' + mapObject.getPosition().toString(),
69+
// 'chartArea' : {'left': '5%', 'width' : '80%'},
70+
// 'legend' : 'bottom',
71+
'width': 400,
72+
'height': 150};
73+
74+
return (options);
75+
}
76+
77+
78+
/**
79+
* drawChart
80+
*
81+
* @param mapObject
82+
* map object that contains the data for the chart
83+
*
84+
* @return node
85+
* div node containing the chart
86+
**/
87+
function chartObject(mapObject) {
88+
89+
//var js = chartJson(mapObject.chart_cols, mapObject.info_window),
90+
var js = JSON.parse(mapObject.info_window);
91+
// js needs to be a Javascript Object literal
92+
93+
var data = new google.visualization.arrayToDataTable(js),
94+
//data = new google.visualization.DataTable(js),
95+
//options = chartOptions(mapObject),
96+
node = document.createElement('div'),
97+
98+
// get a chart object
99+
chart = chartType(mapObject.chart_type, node),
100+
options = JSON.parse(mapObject.chart_options);
101+
102+
chart.draw(data, options);
103+
return (node);
104+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
function add_geolocation(map_id) {
3+
4+
if(!HTMLWidgets.shinyMode) return;
5+
6+
//var infoWindow = new google.maps.InfoWindow;
7+
// Try HTML5 geolocation.
8+
var eventInfo;
9+
10+
if (navigator.geolocation) {
11+
navigator.geolocation.getCurrentPosition(function(position) {
12+
13+
console.log( position );
14+
15+
eventInfo = {
16+
lat: position.coords.latitude,
17+
lon: position.coords.longitude,
18+
accuracy: position.coords.accuracy,
19+
altitude: position.coords.altitude,
20+
altitudeAccuracy: position.coords.altitudeAccuracy,
21+
heading: position.coords.heading,
22+
speed: position.coords.speed,
23+
timestamp: position.timestamp,
24+
randomValue: Math.random()
25+
};
26+
27+
console.log( eventInfo );
28+
29+
//infoWindow.setPosition(pos);
30+
//infoWindow.setContent('Location found.');
31+
//infoWindow.open(map);
32+
//map.setCenter(pos);
33+
34+
event_return_type = window.googleway.params[1].event_return_type;
35+
eventInfo = event_return_type === "list" ? eventInfo : JSON.stringify(eventInfo);
36+
37+
console.log( eventInfo );
38+
39+
Shiny.onInputChange(map_id + "_geolocation", eventInfo);
40+
41+
}, function() {
42+
//handleLocationError(true, infoWindow, map.getCenter());
43+
});
44+
} else {
45+
// Browser doesn't support Geolocation
46+
//handleLocationError(false, infoWindow, map.getCenter());
47+
}
48+
}
49+
50+
/*
51+
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
52+
infoWindow.setPosition(pos);
53+
infoWindow.setContent(browserHasGeolocation ?
54+
'Error: The Geolocation service failed.' :
55+
'Error: Your browser doesn\'t support geolocation.');
56+
infoWindow.open(map);
57+
}
58+
*/
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
2+
function add_legend(map_id, layer_id, legendValues) {
3+
4+
'use strict';
5+
6+
var i = 0;
7+
8+
for (i = 0; i < legendValues.length; i++) {
9+
if (legendValues[i].type === "category") {
10+
add_legend_category(map_id, layer_id, legendValues[i]);
11+
} else {
12+
if (legendValues[i].legend.colour.length === 1) {
13+
add_legend_category(map_id, layer_id, legendValues[i]);
14+
} else {
15+
add_legend_gradient(map_id, layer_id, legendValues[i]);
16+
}
17+
}
18+
}
19+
}
20+
21+
function add_legend_gradient(map_id, layer_id, legendValues) {
22+
// fill gradient
23+
'use strict';
24+
var legendContent,
25+
legendTitle,
26+
tickContainer,
27+
labelContainer = document.createElement("div"),
28+
legendColours = document.createElement('div'),
29+
jsColours = [],
30+
colours = '',
31+
i = 0,
32+
legendTextColour = '#828282',
33+
style = '',
34+
isUpdating = false;
35+
36+
37+
if (window[map_id + 'legend' + layer_id + legendValues.colourType] == null) {
38+
window[map_id + 'legend' + layer_id + legendValues.colourType] = document.createElement("div");
39+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('id', map_id + 'legend' + layer_id + legendValues.colourType);
40+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('class', 'legend');
41+
} else {
42+
isUpdating = true;
43+
44+
while (window[map_id + 'legend' + layer_id + legendValues.colourType].hasChildNodes()) {
45+
window[map_id + 'legend' + layer_id + legendValues.colourType].removeChild(window[map_id + 'legend' + layer_id + legendValues.colourType].lastChild);
46+
}
47+
}
48+
49+
legendContent = document.createElement("div"),
50+
legendTitle = document.createElement("div"),
51+
tickContainer = document.createElement("div"),
52+
labelContainer = document.createElement("div"),
53+
legendColours = document.createElement('div'),
54+
55+
legendContent.setAttribute('class', 'legendContent');
56+
57+
legendTitle.setAttribute('class', 'legendTitle');
58+
legendTitle.innerHTML = legendValues.title;
59+
window[map_id + 'legend' + layer_id + legendValues.colourType].appendChild(legendTitle);
60+
61+
tickContainer.setAttribute('class', 'tickContainer');
62+
labelContainer.setAttribute('class', 'labelContainer');
63+
64+
if (legendValues.css !== null) {
65+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('style', legendValues.css);
66+
}
67+
68+
for (i = 0; i < legendValues.legend.colour.length; i++) {
69+
jsColours.push(legendValues.legend.colour[i]);
70+
}
71+
72+
colours = '(' + jsColours.join() + ')';
73+
74+
style = 'display: inline-block; height: ' + jsColours.length * 20 + 'px; width: 15px;';
75+
style += 'background: ' + jsColours[1] + ';';
76+
style += 'background: -webkit-linear-gradient' + colours + ';';
77+
style += 'background: -o-linear-gradient' + colours + ';';
78+
style += 'background: -moz-linear-gradient' + colours + ';';
79+
style += 'background: linear-gradient' + colours + ';';
80+
81+
legendColours.setAttribute('style', style);
82+
legendContent.appendChild(legendColours);
83+
84+
for (i = 0; i < legendValues.legend.colour.length; i++) {
85+
86+
var legendValue = 'text-align: left; color: ' + legendTextColour + '; font-size: 12px; height: 20px;',
87+
divTicks = document.createElement('div'),
88+
divVal = document.createElement('div');
89+
90+
divTicks.setAttribute('style', legendValue);
91+
divTicks.innerHTML = '-';
92+
tickContainer.appendChild(divTicks);
93+
94+
divVal.setAttribute('style', legendValue);
95+
divVal.innerHTML = legendValues.legend.variable[i];
96+
labelContainer.appendChild(divVal);
97+
}
98+
99+
legendContent.appendChild(tickContainer);
100+
legendContent.appendChild(labelContainer);
101+
102+
window[map_id + 'legend' + layer_id + legendValues.colourType].appendChild(legendContent);
103+
104+
if (isUpdating === false) {
105+
placeControl(map_id, window[map_id + 'legend' + layer_id + legendValues.colourType], legendValues.position);
106+
}
107+
}
108+
109+
function generateColourBox(colourType, colour) {
110+
'use strict';
111+
112+
if (colourType === "fill_colour") {
113+
return ('height: 20px; width: 15px; background: ' + colour);
114+
} else {
115+
// http://jsfiddle.net/UES6U/2/
116+
return ('height: 20px; width: 15px; background: linear-gradient(to bottom, white 25%, ' + colour + ' 25%, ' + colour + ' 45%, ' + 'white 45%)');
117+
}
118+
}
119+
120+
function add_legend_category(map_id, layer_id, legendValues) {
121+
122+
'use strict';
123+
124+
var legendContent,
125+
legendTitle,
126+
colourContainer,
127+
tickContainer,
128+
labelContainer,
129+
legendColours,
130+
colourBox = '',
131+
//colourAttribute = '',
132+
i = 0,
133+
legendTextColour = '#828282',
134+
isUpdating = false;
135+
136+
// catch undefined OR null
137+
// https://stackoverflow.com/questions/2647867/how-to-determine-if-variable-is-undefined-or-null
138+
if (window[map_id + 'legend' + layer_id + legendValues.colourType] == null) {
139+
window[map_id + 'legend' + layer_id + legendValues.colourType] = document.createElement("div");
140+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('id', map_id + 'legend' + layer_id + legendValues.colourType);
141+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('class', 'legend');
142+
143+
} else {
144+
isUpdating = true;
145+
146+
while (window[map_id + 'legend' + layer_id + legendValues.colourType].hasChildNodes()) {
147+
window[map_id + 'legend' + layer_id + legendValues.colourType].removeChild(window[map_id + 'legend' + layer_id + legendValues.colourType].lastChild);
148+
}
149+
}
150+
151+
legendContent = document.createElement("div");
152+
legendTitle = document.createElement("div");
153+
colourContainer = document.createElement("div");
154+
tickContainer = document.createElement("div");
155+
labelContainer = document.createElement("div");
156+
legendColours = document.createElement('div');
157+
158+
legendContent.setAttribute('class', 'legendContent');
159+
legendContent.setAttribute('id', 'legendContentId' + map_id + layer_id);
160+
161+
legendTitle.setAttribute('class', 'legendTitle');
162+
legendTitle.innerHTML = legendValues.title;
163+
window[map_id + 'legend' + layer_id + legendValues.colourType].appendChild(legendTitle);
164+
165+
colourContainer.setAttribute('class', 'labelContainer');
166+
colourContainer.setAttribute('id', 'colourContainerId' + map_id + layer_id);
167+
168+
tickContainer.setAttribute('class', 'tickContainer');
169+
tickContainer.setAttribute('id', 'tickContainerId' + map_id + layer_id);
170+
171+
labelContainer.setAttribute('class', 'labelContainer');
172+
labelContainer.setAttribute('id', 'labelContainerId' + map_id + layer_id);
173+
174+
if (legendValues.css !== null) {
175+
window[map_id + 'legend' + layer_id + legendValues.colourType].setAttribute('style', legendValues.css);
176+
}
177+
178+
for (i = 0; i < legendValues.legend.colour.length; i++) {
179+
180+
var tickVal = 'text-left: center; color: ' + legendTextColour + '; font-size: 12px; height: 20px;',
181+
divCol = document.createElement('div'),
182+
divTicks = document.createElement('div'),
183+
divVal = document.createElement('div');
184+
185+
//colourBox = 'height: 20px; width: 15px; background: ' + legendValues.legend.colour[i];
186+
colourBox = generateColourBox(legendValues.colourType, legendValues.legend.colour[i]);
187+
divCol.setAttribute('style', colourBox);
188+
colourContainer.appendChild(divCol);
189+
190+
divTicks.setAttribute('style', tickVal);
191+
divTicks.innerHTML = '-';
192+
tickContainer.appendChild(divTicks);
193+
194+
divVal.setAttribute('style', tickVal);
195+
divVal.innerHTML = legendValues.legend.variable[i];
196+
labelContainer.appendChild(divVal);
197+
}
198+
199+
legendContent.appendChild(colourContainer);
200+
legendContent.appendChild(tickContainer);
201+
legendContent.appendChild(labelContainer);
202+
203+
window[map_id + 'legend' + layer_id + legendValues.colourType].appendChild(legendContent);
204+
205+
if (isUpdating === false) {
206+
placeControl(map_id, window[map_id + 'legend' + layer_id + legendValues.colourType], legendValues.position);
207+
}
208+
209+
}
210+
211+
212+
function clear_legend(map_id, layer_id){
213+
214+
// find reference to this layer in the legends
215+
var id = map_id + 'legend' + layer_id + 'fill_colour';
216+
var objIndex = findById(window[map_id + 'legendPositions'], id, "index" );
217+
218+
if(objIndex != null) {
219+
removeControl(map_id, id, window[map_id + 'legendPositions'][objIndex].position);
220+
window[map_id + 'legendPositions'].splice(objIndex, 1);
221+
window[id] = null;
222+
}
223+
224+
id = map_id + 'legend' + layer_id + 'stroke_colour';
225+
objIndex = findById(window[map_id + 'legendPositions'], id, "index" );
226+
227+
if(objIndex != null) {
228+
removeControl(map_id, id, window[map_id + 'legendPositions'][objIndex].position);
229+
window[map_id + 'legendPositions'].splice(objIndex, 1);
230+
window[id] = null;
231+
}
232+
}
233+

0 commit comments

Comments
 (0)