Skip to content

Commit 5ee83fd

Browse files
committed
Added World Map to the Geo Location panel on the HTML report.
Area and bar charts are still available for this panel. Closes allinurl#524
1 parent d7c7dac commit 5ee83fd

11 files changed

+377
-22
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Makefile.in
9797
/src/facss.h
9898
/src/hoganjs.h
9999
/src/tpls.h
100+
/src/countries110m.h
101+
/src/topojsonjs.h
100102

101103
# intermediate resources
102104
/resources/css/app.css.tmp
@@ -107,3 +109,5 @@ Makefile.in
107109
/resources/js/d3.v?.min.js.tmp
108110
/resources/js/hogan.min.js.tmp
109111
/resources/tpls.html.tmp
112+
/resources/countries-110m.json.tmp
113+
/resources/js/topojson.v3.min.js.tmp

Makefile.am

+24
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ dist_noinst_DATA = \
99
resources/css/fa.min.css \
1010
resources/js/app.js \
1111
resources/js/charts.js \
12+
resources/countries-110m.json \
1213
resources/js/d3.v7.min.js \
14+
resources/js/topojson.v3.min.js \
1315
resources/js/hogan.min.js
1416

1517
noinst_PROGRAMS = bin2c
@@ -21,7 +23,9 @@ BUILT_SOURCES = \
2123
src/facss.h \
2224
src/appcss.h \
2325
src/d3js.h \
26+
src/topojsonjs.h \
2427
src/hoganjs.h \
28+
src/countries110m.h \
2529
src/chartsjs.h \
2630
src/appjs.h
2731

@@ -31,14 +35,18 @@ CLEANFILES = \
3135
src/facss.h \
3236
src/appcss.h \
3337
src/d3js.h \
38+
src/topojsonjs.h \
3439
src/hoganjs.h \
40+
src/countries110m.h \
3541
src/chartsjs.h \
3642
src/appjs.h \
3743
resources/tpls.html.tmp \
44+
resources/countries-110m.json.tmp \
3845
resources/css/bootstrap.min.css.tmp \
3946
resources/css/fa.min.css.tmp \
4047
resources/css/app.css.tmp \
4148
resources/js/d3.v7.min.js.tmp \
49+
resources/js/topojson.v3.min.js.tmp \
4250
resources/js/hogan.min.js.tmp \
4351
resources/js/charts.js.tmp \
4452
resources/js/app.js.tmp
@@ -51,6 +59,14 @@ if HAS_SEDTR
5159
else
5260
./bin2c $(srcdir)/resources/tpls.html src/tpls.h tpls
5361
endif
62+
# countries.json
63+
src/countries110m.h: bin2c$(EXEEXT) $(srcdir)/resources/countries-110m.json
64+
if HAS_SEDTR
65+
cat $(srcdir)/resources/countries-110m.json | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/countries-110m.json.tmp
66+
./bin2c $(srcdir)/resources/countries-110m.json.tmp src/countries110m.h countries_json
67+
else
68+
./bin2c $(srcdir)/resources/countries-110m.json src/countries110m.h countries_json
69+
endif
5470
# Bootstrap
5571
src/bootstrapcss.h: bin2c$(EXEEXT) $(srcdir)/resources/css/bootstrap.min.css
5672
if HAS_SEDTR
@@ -83,6 +99,14 @@ if HAS_SEDTR
8399
else
84100
./bin2c $(srcdir)/resources/js/d3.v7.min.js src/d3js.h d3_js
85101
endif
102+
# topojson.js
103+
src/topojsonjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/topojson.v3.min.js
104+
if HAS_SEDTR
105+
cat $(srcdir)/resources/js/topojson.v3.min.js | sed "s/^[[:space:]]*//" | sed "/^$$/d" | tr -d "\r\n" > $(srcdir)/resources/js/topojson.v3.min.js.tmp
106+
./bin2c $(srcdir)/resources/js/topojson.v3.min.js.tmp src/topojsonjs.h topojson_js
107+
else
108+
./bin2c $(srcdir)/resources/js/topojson.v3.min.js src/topojsonjs.h topojson_js
109+
endif
86110
# Hogan.js
87111
src/hoganjs.h: bin2c$(EXEEXT) $(srcdir)/resources/js/hogan.min.js
88112
if HAS_SEDTR

resources/countries-110m.json

+1
Large diffs are not rendered by default.

resources/css/app.css

+16
Original file line numberDiff line numberDiff line change
@@ -1144,3 +1144,19 @@ html.dark.purple,
11441144
.dark.purple .line1 {
11451145
stroke: #d048b6;
11461146
}
1147+
.country {
1148+
fill: #ccc;
1149+
stroke: #fff;
1150+
stroke-width: 0.5px;
1151+
}
1152+
.country:hover {
1153+
fill: #b3b3b3;
1154+
}
1155+
.dark .country {
1156+
fill: #ccc;
1157+
stroke: #222;
1158+
stroke-width: 0.5px;
1159+
}
1160+
.dark .legend-svg text {
1161+
fill: #FFF;
1162+
}

resources/js/app.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,16 @@ GoAccess.Charts = {
10941094
return arr.join(' ');
10951095
},
10961096

1097+
getWMap: function (panel, plotUI, data) {
1098+
var chart = WorldMap(d3.select("#chart-" + panel));
1099+
chart.width($("#chart-" + panel).getBoundingClientRect().width);
1100+
chart.height(400);
1101+
chart.metric(plotUI['d3']['y0']['key']);
1102+
chart.opts(plotUI);
1103+
1104+
return chart;
1105+
},
1106+
10971107
getAreaSpline: function (panel, plotUI, data) {
10981108
var dualYaxis = plotUI['d3']['y1'];
10991109

@@ -1186,6 +1196,9 @@ GoAccess.Charts = {
11861196
case 'bar':
11871197
chart = this.getVBar(panel, plotUI, data);
11881198
break;
1199+
case 'wmap':
1200+
chart = this.getWMap(panel, plotUI, data);
1201+
break;
11891202
}
11901203

11911204
return chart;
@@ -1196,7 +1209,7 @@ GoAccess.Charts = {
11961209
d3.select('#chart-' + panel + '>.chart-tooltip-wrap')
11971210
.remove();
11981211
// remove svg
1199-
d3.select('#chart-' + panel).select('svg')
1212+
d3.select('#chart-' + panel).selectAll('svg')
12001213
.remove();
12011214
// add chart to the document
12021215
d3.select("#chart-" + panel)

0 commit comments

Comments
 (0)