Skip to content

Instantly share code, notes, and snippets.

@ahandsel
Last active December 9, 2020 06:56
Show Gist options
  • Save ahandsel/23bc4381f6f3c16790c942a7b1ecbc10 to your computer and use it in GitHub Desktop.
Save ahandsel/23bc4381f6f3c16790c942a7b1ecbc10 to your computer and use it in GitHub Desktop.

No Server Data Visualization: Build a Color-Coded Map Project!

Thank you for attending our Kintone x Color-Coded Map workshop!

Use the following CSV, JavaScript, & PDF files and CDN URLs for the hands-on section!

Download Links

Click here or the Download Zip button on the upper right corner for all the code, data, & slide you need for our workshop!

Getting your FREE Kintone Database

Step 1 - Sign Up for Kintone Developer Account (Website)

  • bit.ly/KDP_signup
    • ⚠ Do NOT use Safari
    • ⚡Accept Cookies First
    • ✅ Use Chrome & Firefox

Step 2 - Create a Kintone Subdomain (Environment)

  • bit.ly/K_DevLic
    • ⚡ Only use lowercase, numbers, & hyphens in your subdomain
    • ⚠ Do not use uppercase nor special characters

Quick video on the sign-up process:

https://youtu.be/Gzz8SbTuoFg https://youtu.be/Gzz8SbTuoFg

References

The CSV file's data is from the Highest Earnings By Country list on esportsearnings.com.
Top 100 countries' total earned prize money (in USD) & player count were extracted and we generated the Prize Money per Player figure.

Country Continent Country Code Total Earned Prize Money ($) Number of Players Prize Money per Player Latitude Longitude
Viet Nam Asia vn 3729291.93 961 3881 14.0583 108.2772
Venezuela South America ve 145017.24 100 1450 6.4238 -66.5897
Uzbekistan Asia uz 470176.68 38 12373 41.3775 64.5853
Uruguay South America uy 164199.77 47 3494 -32.5228 -55.7658
United States North America us 144126987.5 16967 8495 37.0902 -95.7129
United Kingdom Europe gb 19598345.92 3102 6318 55.3781 -3.436
United Arab Emirates Asia ae 325593.39 128 2544 23.4241 53.8478
Ukraine Europe ua 15439422.04 901 17136 48.3794 31.1656
Turkey Asia tr 3357954.53 630 5330 38.9637 35.2433
Tunisia Africa tn 218308.21 41 5325 33.8869 9.5375
Thailand Asia th 6270051.6 958 6545 15.87 100.9925
Taiwan Asia tw 10421853.11 862 12090 23.6978 120.9605
Switzerland Europe ch 1607943.9 353 4555 46.8182 8.2275
Sweden Europe se 38011781.16 2489 15272 60.1282 18.6435
Spain Europe es 5519985.01 1493 3697 40.4637 -3.7492
South Africa Africa za 866860.84 455 1905 -30.5595 22.9375
Slovenia Europe si 816771.73 90 9075 46.1512 14.9955
Slovakia Europe sk 1978486.34 212 9332 48.669 19.699
Singapore Asia sg 3742315.07 597 6269 1.3521 103.8198
Serbia Europe rs 879756.04 225 3910 44.0165 21.0059
Saudi Arabia Asia sa 2010015.01 157 12803 23.8859 45.0792
Russian Federation Europe ru 26540077.16 3486 7613 61.524 105.3188
Romania Europe ro 3558278.36 362 9830 45.9432 24.9668
Qatar Asia qa 21317.54 9 2369 25.3548 51.1839
Puerto Rico North America pr 260828.9 35 7452 18.2208 -66.5901
Portugal Europe pt 1547330.12 674 2296 39.3999 -8.2245
Poland Europe pl 13567588.79 1759 7713 51.9194 19.1451
Philippines Asia ph 8325112.89 556 14973 12.8797 121.774
Peru South America pe 1970755.03 275 7166 -9.19 -75.0152
Panama North America pa 41518.88 31 1339 8.538 -80.7821
Pakistan Asia pk 4242627.74 151 28097 30.3753 69.3451
Norway Europe no 7550022.05 861 8769 60.472 8.4689
Nicaragua North America ni 28813.51 4 7203 12.8654 -85.2072
New Zealand Oceania nz 1832382.92 242 7572 -40.9006 174.886
Netherlands Europe nl 8991843.57 1221 7364 52.1326 5.2913
Morocco Africa ma 108837.66 51 2134 31.7917 -7.0926
Montenegro Europe me 118288.62 11 10754 42.7087 19.3744
Mongolia Asia mn 309684.59 86 3601 46.8625 103.8467
Moldova Europe md 204940.27 28 7319 47.4116 28.3699
Mexico North America mx 2421798.04 427 5672 23.6345 -102.5528
Malta Europe mt 137970.39 252 548 35.9375 14.3754
Malaysia Asia my 9821548.96 621 15816 4.2105 101.9758
Macedonia Europe mk 1042441.88 41 25425 41.6086 21.7453
Macao Asia mo 1520073.84 28 54288 22.1987 113.5439
Luxembourg Europe lu 35052.01 23 1524 49.8153 6.1296
Lithuania Europe lt 948955.74 253 3751 55.1694 23.8813
Lebanon Asia lb 4400532.73 57 77202 33.8547 35.8623
Latvia Europe lv 686889.73 213 3225 56.8796 24.6032
Kyrgyzstan Asia kg 466515.88 45 10367 41.2044 74.7661
Kuwait Asia kw 73588.46 66 1115 29.3117 47.4818
Kosovo Europe xk 20693.96 9 2299 42.6026 20.903
Korea Asia kr 91103599.24 3907 23318 35.9078 127.7669
Kazakhstan Asia kz 2175190.18 545 3991 48.0196 66.9237
Jordan Asia jo 6581467.27 61 107893 30.5852 36.2384
Japan Asia jp 8609776.56 1382 6230 36.2048 138.2529
Italy Europe it 2994845.32 736 4069 41.8719 12.5674
Israel Asia il 3233406.33 182 17766 31.0461 34.8516
Ireland Europe ie 749373.93 166 4514 53.4129 -8.2439
Iraq Asia iq 109336.97 47 2326 33.2232 43.6793
Iran Asia ir 169593.83 102 1663 32.4279 53.688
Indonesia Asia id 2037925.22 632 3225 -0.7893 113.9213
India Asia in 732258.89 562 1303 20.5937 78.9629
Iceland Europe is 160497.63 104 1543 64.9631 -19.0208
Hungary Europe hu 932899.26 402 2321 47.1625 19.5033
Hong Kong Asia hk 2992983.29 321 9324 22.3964 114.1095
Greece Europe gr 1617765.41 357 4532 39.0742 21.8243
Gibraltar Europe gi 126204.51 1 126205 36.1377 -5.3454
Germany Europe de 26003839.34 4134 6290 51.1657 10.4515
Georgia Asia ge 63431 67 947 42.3154 43.3569
France Europe fr 28701805.68 3654 7855 46.2276 2.2137
Finland Europe fi 25113620.1 1489 16866 61.9241 25.7482
Ethiopia Africa et 23669.95 1 23670 9.145 40.4897
Estonia Europe ee 3992436.75 196 20370 58.5953 25.0136
Egypt Africa eg 156626.6 62 2526 26.8206 30.8025
Ecuador South America ec 22984.01 28 821 -1.8312 -78.1834
Dominican Republic North America do 395139.03 52 7599 18.7357 -70.1627
Denmark Europe dk 36009364.26 1508 23879 56.2639 9.5018
Czech Republic Europe cz 2143412.03 587 3651 49.8175 15.473
Cuba North America cu 75148.55 9 8350 21.5218 -77.7812
Croatia Europe hr 919180.93 168 5471 45.1 15.2
Costa Rica North America cr 39393.14 39 1010 9.7489 -83.7534
Colombia South America co 269963.16 131 2061 4.5709 -74.2973
China Asia cn 110099248.4 4441 24792 35.8617 104.1954
Chile South America cl 876639.45 381 2301 -35.6751 -71.543
Canada North America ca 27875154.85 2739 10177 56.1304 -106.3468
Cambodia Asia kh 43146.26 66 654 12.5657 104.991
Bulgaria Europe bg 7569052.63 329 23006 42.7339 25.4858
Brazil South America br 19430803.56 2551 7617 -14.235 -51.9253
Bosnia and Herzegovina Europe ba 1026912.89 37 27754 43.9159 17.6791
Bolivia South America bo 236571.64 12 19714 -16.2902 -63.5887
Belgium Europe be 2979334.43 505 5900 50.5039 4.4699
Belarus Europe by 2154033.21 275 7833 53.7098 27.9534
Bahrain Asia bh 71557.6 8 8945 25.9304 50.6378
Azerbaijan Asia az 81151.58 89 912 40.1431 47.5769
Austria Europe at 3749642.46 511 7338 47.5162 14.5501
Australia Oceania au 16796589.61 2198 7642 -25.2744 133.7751
Armenia Asia am 224960.72 26 8652 40.0691 45.0382
Argentina South America ar 3202331.29 579 5531 -38.4161 -63.6167
Algeria Africa dz 73040.04 40 1826 28.0339 1.6596
Albania Europe al 38621.6 22 1756 41.1533 20.1683
// Order matters when inserting CDN URLs into Kintone App settings
https://www.amcharts.com/lib/4/core.js
https://www.amcharts.com/lib/4/maps.js
https://cdn.amcharts.com/lib/4/geodata/worldLow.js
https://www.amcharts.com/lib/4/themes/animated.js
(function () {
'use strict';
// Kintone event triggered after the record list page is displayed.
kintone.events.on('app.record.index.show', function (event) {
// Retrieve & configure the space element below the record list's header
var spaceDiv = kintone.app.getHeaderSpaceElement();
spaceDiv.style.height = '500px';
spaceDiv.style.marginLeft = '25px';
spaceDiv.style.marginRight = '25px';
spaceDiv.style.border = 'solid';
spaceDiv.style.borderColor = '#ED7B84';
// Apply amCharts Themes for automatic animation
am4core.useTheme(am4themes_animated);
// Create map instance
var chart = am4core.create(spaceDiv, am4maps.MapChart);
// Set map definition
chart.geodata = am4geodata_worldLow;
// Set projection
chart.projection = new am4maps.projections.Miller();
// Create map polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
// Exclude Antarctica
polygonSeries.exclude = ['AQ'];
// Make map load polygon (like country names) data from GeoJSON
polygonSeries.useGeodata = true;
polygonSeries.calculateVisualCenter = true;
polygonSeries.mapPolygons.template.tooltipPosition = 'fixed';
//Set min & max fill color
polygonSeries.heatRules.push({
'property': 'fill',
'target': polygonSeries.mapPolygons.template,
'min': am4core.color('#e5f5e0'),
'max': am4core.color('#31a354'),
'logarithmic': true
});
// Set tooltip with data to be displayed when hovered over
var polygonTemplate = polygonSeries.mapPolygons.template;
polygonTemplate.tooltipText = '{name}: ${value}';
// Create JSON object from Kintone records & pass it onto amCharts
var polygonData = event.records.map(function (record) {
return {
// Country Code default field code = Text_0
// Prize Money per Player default field code = Number_1
'id': record.Text_0.value.toUpperCase(),
'value': Number(record.Number_1.value)
}
});
polygonSeries.data = polygonData;
// - - - - - Extra Functionality - - - - -
// Enable export
chart.exporting.menu = new am4core.ExportMenu();
chart.exporting.menu.align = 'left';
chart.exporting.menu.verticalAlign = 'top';
chart.exporting.backgroundColor = am4core.color('#f00', 0);
// Create a zoom control
var zoomControl = new am4maps.ZoomControl();
chart.zoomControl = zoomControl;
zoomControl.slider.height = 100;
// Add Home button to reset zoom
var home = chart.chartContainer.createChild(am4core.Button);
home.label.text = 'Home';
home.align = 'right';
home.events.on('hit', function (ev) {
chart.goHome();
});
// Disable mouse wheel zooming
chart.chartContainer.wheelable = false;
});
})();

Thank you for attending our workshop!

Your Feedback Please

Please fill out this quick survey for a chance to win $25 Amazon Gift Card:

Next Step

For those wanting more visualization projects:

  • Try linking to different amChart libraries, and reuse the code we used in the workshop!

For those wanting to create projects on Kintone and want to retrieve & store data from public APIs:

For those wanting to use Kintone as a back-end database:

Where to Get Help?

(function () {
'use strict';
var url = "https://xkcd.com/327/info.0.json";
kintone.events.on('app.record.index.show', function (event) {
kintone.proxy(url, 'GET', {}, {}, function (success) {
var jsonResponse = JSON.parse(success);
console.log(jsonResponse);
window.open(jsonResponse.img, "", "width=800, height=200, top=200");
}, function (error) {
console.log(error);
});
return event;
});
})();
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment