reorganize files

This commit is contained in:
stoffu
2018-08-24 16:53:56 +09:00
parent a99558d23b
commit 01a3356d02
58 changed files with 232 additions and 232 deletions
+1309
View File
File diff suppressed because it is too large Load Diff
+70
View File
@@ -0,0 +1,70 @@
function get_chart(chartData) {
chartData.shift();
for (var i = 0; i < chartData.length; ++i) {
chartData[i].date = new Date(1000 * chartData[i][0]);
chartData[i].height = i + 1;
chartData[i].bc_size = chartData[i][3];
if (i > 0)
chartData[i].bc_size += chartData[i - 1].bc_size;
chartData[i].bc_size_str = formatBytes(chartData[i].bc_size, 3);
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData,
"valueAxes": [{
"axisAlpha": 0,
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#07ab82",
"balloonText": "Size: [[bc_size_str]]\nHeight: <b>[[height]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "block size",
"valueField": "bc_size",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"minPeriod": "ss",
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+67
View File
@@ -0,0 +1,67 @@
function get_chart(chartData, decimal_point) {
chartData.shift();
for (var i = 0; i < chartData.length; ++i) {
chartData[i].date = new Date(1000 * chartData[i][0]);
chartData[i].height = i + 1;
chartData[i].reward = print_money(chartData[i][2], decimal_point);
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData,
"valueAxes": [{
"axisAlpha": 0,
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#ffa366",
"balloonText": "Reward: <b>[[value]]</b>\nHeight: <b>[[height]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "block reward",
"valueField": "reward",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"minPeriod": "ss",
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+68
View File
@@ -0,0 +1,68 @@
function get_chart(chartData) {
chartData.shift();
for (var i = 0; i < chartData.length; ++i) {
chartData[i].date = new Date(1000 * chartData[i][0]);
chartData[i].height = i + 1;
chartData[i].block_size = chartData[i][3];
chartData[i].block_size_str = formatBytes(chartData[i].block_size, 3);
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData,
"valueAxes": [{
"axisAlpha": 0,
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#9bc408",
"balloonText": "Size: [[block_size_str]]\nHeight: <b>[[height]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "block size",
"valueField": "block_size",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"minPeriod": "ss",
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+73
View File
@@ -0,0 +1,73 @@
function get_chart(chartData, decimal_point) {
for (var i = 0; i < chartData.length; ++i) {
chartData[i].date = new Date(1000 * chartData[i][0]);
chartData[i].height = i;
chartData[i].coin_supply = bigInt(chartData[i][2]);
for (var j = 0; j < chartData[i][4].length; ++j)
chartData[i].coin_supply = chartData[i].coin_supply.minus(chartData[i][4][j][4]);
if (i > 0)
chartData[i].coin_supply = chartData[i].coin_supply.plus(chartData[i - 1].coin_supply);
chartData[i].coin_supply_str = print_money(chartData[i].coin_supply, decimal_point);
chartData[i].coin_supply_real = chartData[i].coin_supply.toJSNumber() / Math.pow(10, decimal_point);
}
chartData.shift();
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData,
"valueAxes": [{
"axisAlpha": 0,
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#cc9900",
"balloonText": "Supply: <b>[[coin_supply_str]]</b>\nHeight: <b>[[height]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "coin supply",
"valueField": "coin_supply_real",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"minPeriod": "ss",
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+68
View File
@@ -0,0 +1,68 @@
function get_chart(chartData) {
chartData.shift();
for (var i = 0; i < chartData.length; ++i) {
chartData[i].date = new Date(1000 * chartData[i][0]);
chartData[i].height = i + 1;
chartData[i].difficulty = chartData[i][1];
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData,
"valueAxes": [{
"axisAlpha": 0,
"logarithmic": true
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#67B7DC",
"balloonText": "Diff: <b>[[value]]</b>\nHeight: <b>[[height]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "difficulty",
"valueField": "difficulty",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"minPeriod": "ss",
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true,
"position": "bottom-right"
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+144
View File
@@ -0,0 +1,144 @@
function get_chart(chartData, levels) {
chartData.shift();
var chartData_rs = [];
var block_date = null;
var num_txes_per_day = {};
for (var i = 0; i < chartData.length; ++i) {
var block_date_new = new Date(1000 * chartData[i][0]);
block_date_new.setHours(0);
block_date_new.setMinutes(0);
block_date_new.setSeconds(0);
if (block_date === null || block_date < block_date_new) {
block_date = block_date_new;
chartData_rs.push({
"date": block_date,
"histogram": [],
});
num_txes_per_day[block_date] = 0;
}
var e = chartData_rs[chartData_rs.length - 1];
var num_txes = chartData[i][4].length;
if (num_txes > 0) {
var ring_size = chartData[i][4][0][3];
while (ring_size >= e.histogram.length) {
e.histogram.push(0);
}
e.histogram[ring_size] += num_txes;
num_txes_per_day[block_date] += num_txes;
}
}
for (var i = 0; i < chartData_rs.length; ++i) {
var count_per_level = new Uint32Array(levels.length + 1);
for (var k = 1; k < chartData_rs[i].histogram.length; ++k) {
var l = 0;
while (l < levels.length && k > levels[l])
++l;
count_per_level[l] += chartData_rs[i].histogram[k];
}
for (var l = 0; l <= levels.length; ++l) {
chartData_rs[i]["level" + l] = count_per_level[l];
}
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData_rs,
"valueAxes": [{
"stackType": "100%",
"axisAlpha": 0.2,
"dashLength": 1,
"position": "left",
"title": "percent",
}],
"legend": {
"align": "center",
"equalWidths": false,
"valueAlign": "left",
"valueText": "[[value]] ([[percents]]%)",
"equalWidths": true,
"fontSize": 14,
"valueWidth": 100
},
"mouseWheelZoomEnabled": true,
"graphs": [],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g",
"scrollbarHeight": 40
},
"chartCursor": {
"pan": false,
categoryBalloonFunction: function(date) {
var num_txes = num_txes_per_day[date];
return AmCharts.formatDate(date, "DD MMM, YYYY") + "<br><b>" + num_txes + "</b> transaction" + (num_txes == 1 ? "" : "s");
},
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true
}
});
var color_table = [
"#d77575",
"#d7be75",
"#a6d775",
"#75d78d",
"#75d7d7",
"#758dd7",
"#a675d7",
"#d775be",
];
function get_label(l) {
if (l == 0)
return levels[0] == 1 ? "1" : ("1~" + levels[0])
else if (l == levels.length)
return ">" + levels[l - 1];
else if (levels[l - 1] + 1 < levels[l])
return (levels[l - 1] + 1) + "~" + levels[l];
else
return levels[l];
}
for (var l = 0; l <= levels.length; ++l) {
chart.graphs.push({
"id": "g"+l,
"lineColor": color_table[l % color_table.length],
"showBalloon" : false,
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"fillAlphas": 0.5,
"hideBulletsCount": 50,
"valueField": "level" + l,
"title": get_label(l) + ": ",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
});
}
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+79
View File
@@ -0,0 +1,79 @@
function get_chart(chartData) {
chartData.shift();
var chartData_tpd = [];
var block_date = null;
for (var i = 0; i < chartData.length; ++i) {
var block_date_new = new Date(1000 * chartData[i][0]);
block_date_new.setHours(0);
block_date_new.setMinutes(0);
block_date_new.setSeconds(0);
if (block_date === null || block_date < block_date_new) {
block_date = block_date_new;
chartData_tpd.push({
"date": block_date,
"num_txes": 0,
});
}
chartData_tpd[chartData_tpd.length - 1].num_txes += chartData[i][4].length;
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginRight": 80,
"autoMarginOffset": 20,
"marginTop": 7,
"dataProvider": chartData_tpd,
"valueAxes": [{
"axisAlpha": 0.2,
"dashLength": 1,
"position": "left",
}],
"mouseWheelZoomEnabled": true,
"graphs": [{
"id": "g1",
"lineColor": "#cc99ff",
"balloonText": "<b>[[value]]</b>",
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"hideBulletsCount": 50,
"title": "red line",
"valueField": "num_txes",
"useLineColorForBulletBorder": true,
"balloon":{
"cornerRadius": 10,
}
}],
"chartScrollbar": {
"autoGridCount": true,
"graph": "g1",
"scrollbarHeight": 40
},
"chartCursor": {
"limitToGraph":"g1",
"pan": false
},
"categoryField": "date",
"categoryAxis": {
"parseDates": true,
"axisColor": "#DADADA",
"dashLength": 1,
"minorGridEnabled": true
},
"export": {
"enabled": true
}
});
// this method is called when chart is first inited as we listen for "rendered" event
function zoomChart() {
// different zoom methods can be used - zoomToIndexes, zoomToDates, zoomToCategoryValues
chart.zoomToIndexes(0, chartData.length - 1);
}
chart.addListener("rendered", zoomChart);
zoomChart();
return chart;
}
+26
View File
@@ -0,0 +1,26 @@
// https://stackoverflow.com/a/18650828
function formatBytes(bytes, decimal) {
if (0 == bytes)
return "0 bytes";
var c = 1024;
var d = decimal || 2;
var e = ["bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
var f = Math.floor(Math.log(bytes) / Math.log(c));
return "<b>" + parseFloat((bytes / Math.pow(c, f)).toFixed(d)) + "</b> " + e[f]
}
function print_money(amount, decimal_point) {
var s1 = String(amount);
while (s1.length < decimal_point+1)
s1 = "0" + s1;
var s2 = "";
for (var i = 0; i < decimal_point; ++i)
s2 = s1[s1.length - 1 - i] + s2;
s2 = "." + s2;
for (var i = 0; i < s1.length - decimal_point; ++i) {
if (i > 0 && i % 3 == 0)
s2 = "," + s2;
s2 = s1[s1.length - 1 - decimal_point - i] + s2
}
return s2;
}