diff --git a/README.md b/README.md
index f8e89d5..a2552bc 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ _These JavaScript-based interactive charts are highly memory intensive. You will
- [Blockchain size](https://stoffu.github.io/diff-chart/aeon-bc-size.html)
- [Block reward](https://stoffu.github.io/diff-chart/aeon-block-reward.html)
- [Coin supply](https://stoffu.github.io/diff-chart/aeon-coin-supply.html)
+- [Block time](https://stoffu.github.io/diff-chart/aeon-block-time.html)
## Monero
@@ -21,6 +22,7 @@ _These JavaScript-based interactive charts are highly memory intensive. You will
- [Blockchain size](https://stoffu.github.io/diff-chart/monero-bc-size.html)
- [Block reward](https://stoffu.github.io/diff-chart/monero-block-reward.html)
- [Coin supply](https://stoffu.github.io/diff-chart/monero-coin-supply.html)
+- [Block time](https://stoffu.github.io/diff-chart/monero-block-time.html)
## Wownero
@@ -31,3 +33,4 @@ _These JavaScript-based interactive charts are highly memory intensive. You will
- [Blockchain size](https://stoffu.github.io/diff-chart/wownero-bc-size.html)
- [Block reward](https://stoffu.github.io/diff-chart/wownero-block-reward.html)
- [Coin supply](https://stoffu.github.io/diff-chart/wownero-coin-supply.html)
+- [Block time](https://stoffu.github.io/diff-chart/wownero-block-time.html)
diff --git a/aeon-block-time.html b/aeon-block-time.html
new file mode 100644
index 0000000..e9b5275
--- /dev/null
+++ b/aeon-block-time.html
@@ -0,0 +1,57 @@
+
+
Enable panning
+ + + diff --git a/js/block-time.js b/js/block-time.js new file mode 100644 index 0000000..148ba6b --- /dev/null +++ b/js/block-time.js @@ -0,0 +1,165 @@ +function get_chart(chartData) { + chartData.shift(); + var chartData_bt = []; + 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_bt.push({ + "date": block_date, + "block_times": [], + }); + } + chartData_bt[chartData_bt.length - 1].block_times.push(i==0? 1 : (chartData[i][0] - chartData[i-1][0])); + } + + for (var i = 0; i < chartData_bt.length; ++i) { + var stats = getStats(chartData_bt[i].block_times); + chartData_bt[i].max = stats.max; + chartData_bt[i].min = stats.min; + chartData_bt[i].mean = stats.mean.toFixed(2); + chartData_bt[i].stddev = stats.stddev.toFixed(2); + chartData_bt[i].median = stats.median; + } + + var chart = AmCharts.makeChart("chartdiv", { + "type": "serial", + "theme": "light", + "marginRight": 80, + "autoMarginOffset": 20, + "marginTop": 7, + "dataProvider": chartData_bt, + "valueAxes": [{ + "id":"va_normal", + "color": "#3359cc", + "axisColor": "#3359cc", + "axisThickness": 2, + "axisAlpha": 1, + "position": "left" + }, { + "id":"va_extreme", + "color": "#666600", + "axisColor": "#666600", + "axisThickness": 2, + "axisAlpha": 0.5, + "gridAlpha": 0, + "position": "right" + }], + "legend": { + "align": "center", + "equalWidths": false, + "valueAlign": "left", + "valueText": "[[value]] s", + "labelText": "[[title]]: ", + "equalWidths": true, + "fontSize": 14, + "valueWidth": 100 + }, + "mouseWheelZoomEnabled": true, + "graphs": [{ + "id": "g_mean", + "valueAxis": "va_normal", + "type": "smoothedLine", + "lineColor": "#3359cc", + "lineThickness": 5, + "showBalloon" : false, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#FFFFFF", + "hideBulletsCount": 50, + "title": "Mean", + "valueField": "mean", + "useLineColorForBulletBorder": true, + },{ + "id": "g_stddev", + "valueAxis": "va_normal", + "lineColor": "#33a6cc", + "lineThickness": 2, + "showBalloon" : false, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#FFFFFF", + "hideBulletsCount": 50, + "title": "StdDev", + "valueField": "stddev", + "useLineColorForBulletBorder": true, + },{ + "id": "g_median", + "valueAxis": "va_normal", + "type": "smoothedLine", + "lineColor": "#8033cc", + "lineThickness": 2, + "showBalloon" : false, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#FFFFFF", + "hideBulletsCount": 50, + "title": "Median", + "valueField": "median", + "useLineColorForBulletBorder": true, + },{ + "id": "g_max", + "valueAxis": "va_extreme", + "type": "step", + "lineColor": "#b3b300", + "lineAlpha": 0.5, + "showBalloon" : false, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#FFFFFF", + "hideBulletsCount": 50, + "title": "Max", + "valueField": "max", + "useLineColorForBulletBorder": true, + },{ + "id": "g_min", + "valueAxis": "va_extreme", + "type": "step", + "lineColor": "#666600", + "lineAlpha": 0.5, + "showBalloon" : false, + "bullet": "round", + "bulletBorderAlpha": 1, + "bulletColor": "#FFFFFF", + "hideBulletsCount": 50, + "title": "Min", + "valueField": "min", + "useLineColorForBulletBorder": true, + }], + "chartScrollbar": { + "autoGridCount": true, + "graph": "g_mean", + "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; +} diff --git a/js/util.js b/js/util.js index 9f0c466..96f4b4c 100644 --- a/js/util.js +++ b/js/util.js @@ -24,3 +24,22 @@ function print_money(amount, decimal_point) { } return s2; } + +function getStats(values) { + values.sort(function(a,b){return a-b;}); + var max = values[values.length - 1]; + var min = values[0]; + var mean = 0; + for (var i = 0; i < values.length; ++i) + mean += values[i]; + mean /= values.length; + var stddev = 0; + for (var i = 0; i < values.length; ++i) + stddev += (values[i]-mean) * (values[i]-mean); + stddev = Math.sqrt(stddev / values.length); + var median_idx = Math.floor(values.length/2); + var median = values[median_idx]; + if (values.length%2 == 0) + median = (median + values[median_idx + 1]) / 2; + return {"max":max, "min":min, "mean":mean, "stddev":stddev, "median":median}; +} diff --git a/monero-block-time.html b/monero-block-time.html new file mode 100644 index 0000000..f9dd7e5 --- /dev/null +++ b/monero-block-time.html @@ -0,0 +1,71 @@ + +Enable panning
+ + + diff --git a/wownero-block-time.html b/wownero-block-time.html new file mode 100644 index 0000000..b4d2751 --- /dev/null +++ b/wownero-block-time.html @@ -0,0 +1,37 @@ + +Enable panning
+ + +