MONTY
I R L Y M ! ! !

      
ჯგუფი: Members
წერილები: 18740
წევრი No.: 88005
რეგისტრ.: 2-April 09
|
#58807296 · 24 Jan 2022, 21:20 · · პროფილი · პირადი მიმოწერა · ჩატი
QUOTE | var main_data = country_data; var countryArray = null; countryArray = new Array(); var table = ""; var chart_type = ""; var countryArray = []; var sorted_countryArray = []; var networkArray = []; var sorted_networkArray = []; var chart_container = "country_container"; functi0n drawtable(data, divid, tableid, type) { $('#' + divid).html('<div><div class="tablebody"><table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="' + tableid + '"><tr><td colspan="2"><div class="loading">Loading . .. . </div></td></tr></table></div></div>'); if (type == "country") { var columns = [ {"width": "15%", "title": "Rank", "targets": 0, "visible": true, "searchable": false, "orderable": true}, {"width": "15%", "title": "IPv6 %", "targets": 1, "visible": true, "searchable": false, "orderable": true}, {"width": "15%", "title": "Country", "targets": 2, "visible": true, "searchable": true, "orderable": true}, {"targets": 3, "visible": true, "searchable": false, "orderable": false} ]; var order = [1, "desc"]; } if (type == "networks") { var columns = [ {"width": "15%", "title": "Rank", "targets": 0, "visible": true, "searchable": false, "orderable": true}, {"width": "15%", "title": "IPv6 %", "targets": 1, "visible": true, "searchable": false, "orderable": true}, {"width": "15%", "title": "Network", "targets": 2, "visible": true, "searchable": true, "orderable": true}, {"targets": 3, "visible": true, "searchable": false, "orderable": false} ]; var order = [0, "asc"]; }
var table = $('#' + tableid).dataTable({ "data": data, 'filter': true, "order": [order], "paging": false, "autoWidth": false, "info": true, columns: columns, initComplete: functi0n(settings, json) { $('div.loading').parent().remove(); }, rowCallback: functi0n(row, data) { $('td:eq(3)', row).hide(); }, drawCallback: functi0n(settings) { $('#country_data_table').find('*').removeClass('select trChart'); $('#asn_data_table').find('*').removeClass('select trChart'); $('#country_data_table tr').attr("title", "Click on the bar to view the graph"); } }); $('#myInputTextField').keyup(functi0n() { table.fnFilter(this.value); }); return table; }
functi0n maxKey(a) { var max, k; // don't set max=0, because keys may have values < 0 for (var key in a) { if (a.hasOwnProperty(key)) { max = (key); break; } } //get any key for (var key in a) { if (a.hasOwnProperty(key)) { if ((k = (key)) > max) max = k; } } return max; }
functi0n maxValue(data) { //var data = JSON.parse(a);
var maxProp = null var maxValue = -1 for (var prop in data) { if (data.hasOwnProperty(prop)) { var value = data[prop] if (value > maxValue) { maxProp = prop maxValue = value } } } return maxValue; }
$(document).ready(functi0n() { for (i in country_data) { var sorted_countries = []; //sum = maxValue(country_data[i]); sorted_countries.push(country_data[i][maxKey(country_data[i])]); sorted_countries.push(i); sorted_countryArray.push(sorted_countries); } sorted_countryArray.sort(functi0n(a, b) { return b[0] - a[0]; }); var index = 0; for (i in sorted_countryArray) { var countries = []; index++; countries.push(index); console.log("index=" + sorted_countryArray[i][0]); countries.push(sorted_countryArray[i][0].toFixed(1) + "%"); countries.push(sorted_countryArray[i][1]); //countries.push(index); countries.push('<div id="country_container' + index + '" class="area-chart"></div>'); countryArray.push(countries); } for (i in asn_data) { var sorted_networks = []; if (i > 0) { } else {
sorted_networks.push(asn_data[i][maxKey(asn_data[i])]); //sorted_networks.push(sum); sorted_networks.push(i); sorted_networkArray.push(sorted_networks); } } var index = 0; for (i in sorted_networkArray) { var networks = []; index++; networks.push(index); networks.push(sorted_networkArray[i][0].toFixed(1) + "%"); networks.push(sorted_networkArray[i][1]); //networks.push(index); networks.push('<div id="country_container' + index + '" class="area-chart"></div>'); networkArray.push(networks); }
chart_type = document.location.toString().split("#")[1];
if (chart_type == "networks") { $(".ipv6btn").children().first().addClass("selected"); main_data = asn_data; chart_container = "country_container"; //options.plotOptions.area.fillColor = "#2c6f97"; // options.plotOptions.area.lineColor = "#479fd3"; // options.navigation.menuItemHoverStyle.background = "#2c6f97"; $(".boxshadow").removeClass("green"); drawtable(networkArray, 'country_data_div', 'country_data_table', "networks"); } else { chart_type = "countries" drawtable(countryArray, 'country_data_div', 'country_data_table', "country"); }
$(".ipv6btn a").click(functi0n() { $('#country_data_table').remove(); $('#country_data_table_wrapper').remove(); $(".ipv6btn a").removeClass("selected"); $(this).addClass("selected");
chart_type = this.href.split("#")[1];
if (chart_type == "networks") { main_data = asn_data; chart_container = "country_container"; options.plotOptions.area.fillColor = "#2c6f97"; options.plotOptions.area.lineColor = "#479fd3"; //options.navigation.menuItemHoverStyle.background = "#2c6f97"; $(".boxshadow").removeClass("green"); drawtable(networkArray, 'country_data_div', 'country_data_table', "networks"); } if (chart_type == "countries") { main_data = country_data; chart_container = "country_container"; //options.plotOptions.area.fillColor = "red"; //options.plotOptions.area.lineColor = "#97c409"; //options.navigation.menuItemHoverStyle.background = "#5d6d2e"; $("#country_data_div").show(); $("#asn_data_div").hide(); $(".boxshadow").addClass("green"); drawtable(countryArray, 'country_data_div', 'country_data_table', "country"); } });
$('#country_data_table tbody tr').live('click', functi0n(e) { e.preventDefault(); var trIndex = $(this).children().first().html();
if ($(this).hasClass("select")) { $(this).removeClass("select trChart"); $(this).children().last().removeClass("tdChart").hide(); $(this).attr("title", "Click on the bar to view the graph"); } else { $(this).removeAttr("title"); $('#country_data_table').find('*').removeClass('select trChart'); $('#country_data_table').find('td:last-child').removeClass('tdChart').hide(); $(this).addClass("select trChart"); $(this).children().last().addClass("tdChart").show(); }
//window.location.hash = chart_type+'-'+trIndex; options.chart.renderTo = 'country_container' + trIndex; $('#country_container' + trIndex).empty(); var country = $(this).children(':nth-child(3)').html().replace("&", "&"); options.series = []; var series1 = new Array(); var chart_array = []; for (i in main_data) { if (i == country) { series1[i] = { showInLegend: '', name: '', type: '', pointInterval: '', data: [] }; series1[i].showInLegend = false; series1[i].name = i; series1[i].type = 'area'; //series1[i].pointInterval = 24 * 3600 * 1000; var json_data = main_data[i]; for (a in json_data) {
console.log(timeStamp(a)); chart_array.push([timeStamp(a), parseFloat(json_data[a])]) }
chart_array.sort(functi0n(a, b) { return a[0] - b[0] }); for (var j in chart_array) { series1[i].data.push(([(chart_array[j][0]), chart_array[j][1]])); //series1[i].data.push(([chart_array[j][1]])); } options.series.push(series1[i]); } } // if ($(window).width() <= 767) { options.navigation.buttonOptions.enabled = false; } var chart = new Highcharts.Chart(options); });
}); var timeStamp = functi0n(str) { return new Date(str.replace(/^(\d{2}\-)(\d{2}\-)(\d{4})$/, '$2$1$3')).getTime(); }; |
https://codepen.io/intprotest/pen/mNqrwwhttp://caucasusoffline.com/1000/data2/country2.jsonეს ცხრილია რომელიც Json დან კითხულობს მონაცემებს მინდა google sheet ზე გადაკეთება ანუ მონაცემები წაიკითხოს google sheet დან ან ყველაზე ბოლო ვარიანტი ექსელი/csv ფაილიდან სხვა ყველაფერი ( ცხრილი/ჩარტის ფუნქცია უცვლელად) JS მცოდნისთვის არაა შეუძლებელი ამოცანა
--------------------
ერთ მხარეს - ”ნაცების” ნაცემი კაცები, მეორე მხარეს კი- ეს ,,არაკაცები”.!
სასურსათო უსაფრთოება ისეთივე მნიშვნელოვანი უნდა იყოს ქვეყნისთვის , როგორც ენერგო უსაფრთხოება !
I R L Y M! ! !
https://www.facebook.com/IntProtest https://CAUCASUSOFFLINE.COM
|