Browse Source

high-charts

master
yuriy0803 2 years ago
parent
commit
f3d60c431c
  1. 502
      www/app/controllers/index.js
  2. 3
      www/app/templates/index.hbs
  3. 2
      www/translations/en-us.yaml

502
www/app/controllers/index.js

@ -1,292 +1,305 @@
import Ember from 'ember'; function formatDate(date, format) {
date = new Date(date);
var formattedDate = {
year: date.getFullYear(),
month: date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1,
day: date.getDate() < 10 ? "0" + date.getDate() : date.getDate(),
hours: date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
minutes: date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
seconds: date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(),
};
for (var key in formattedDate) {
format = format.replace(key, formattedDate[key]);
}
return format;
}
function formatHashrate(hashrate, showUnit) {
var units = ["H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s"];
var index = 0;
while (hashrate > 1e3) {
hashrate /= 1e3;
index++;
}
return showUnit
? hashrate.toFixed(2) + " " + units[index]
: hashrate.toFixed(2) + " " + units[index];
}
function formatNumber(number) {
var units = ["H/s", "KH/s", "MH/s", "GH/s", "TH/s", "PH/s"];
var index = 0;
while (number >= 1e3) {
number /= 1e3;
index++;
}
number = number < 10 ? number.toFixed(2) : number.toFixed(2);
return number.replace(".00", "") + " " + units[index];
}
import Ember from "ember";
export default Ember.Controller.extend({ export default Ember.Controller.extend({
applicationController: Ember.inject.controller('application'), applicationController: Ember.inject.controller("application"),
stats: Ember.computed.reads('applicationController'), stats: Ember.computed.reads("applicationController"),
config: Ember.computed.reads('applicationController.config'), config: Ember.computed.reads("applicationController.config"),
cachedLogin: Ember.computed('login', { cachedLogin: Ember.computed("login", {
get() { get() {
return this.get('login') || Ember.$.cookie('login'); return this.get("login") || Ember.$.cookie("login");
}, },
set(key, value) { set(key, value) {
Ember.$.cookie('login', value); Ember.$.cookie("login", value);
this.set('model.login', value); this.set("model.login", value);
return value; return value;
} },
}), }),
chartOptions: Ember.computed("model.hashrate", { chartOptions: Ember.computed("model.hashrate", "model.poolCharts", "model.netCharts", {
get() { get() {
var now = new Date();
var e = this, var e = this,
t = e.getWithDefault("stats.model.poolCharts"), t = e.getWithDefault("model.poolCharts", []),
netCharts = e.getWithDefault("model.netCharts", []),
a = { a = {
chart: { chart: {
backgroundColor: "rgba(255, 255, 255, 0.1)", backgroundColor: "rgba(48, 97, 63, 0.0) ",
type: "spline", type: "areaspline",
height: 220, height: 270,
marginRight: 10, ignoreHiddenSeries: !1,
events: { events: {
load: function () { load: function () {
var series = this.series[0]; var self = this;
setInterval(function () {
var x = (new Date()).getTime(), y = e.getWithDefault("model.Hashrate") / 1000000; var chartInterval = setInterval(function () {
series.addPoint([x, y], true, true); var series = self.series;
}, 1090000000); if (!series) {
} clearInterval(chartInterval);
} return;
}
t = e.getWithDefault("model.poolCharts", []);
netCharts = e.getWithDefault("model.netCharts", []);
// Hashrate chart
var hashData = [];
t.forEach(function (entry) {
var x = new Date(1000 * entry.x);
var l = x.toLocaleString();
var y = entry.y;
hashData.push({ x: x, y: y, d: l });
});
// Point for now
var now = new Date();
var l = now.toLocaleString();
var y = e.getWithDefault("model.hashrate");
var lastHash = { x: now, y: y, d: l };
{ hashData.push(lastHash); }
// Network Difficulty chart
var netDiffData = [];
netCharts.forEach(function (entry) {
var x = new Date(1000 * entry.x);
var l = x.toLocaleString();
var y = entry.y;
netDiffData.push({ x: x, y: y, d: l });
});
series[0].setData(hashData, true, {}, true);
series[1].setData(netDiffData, true, {}, true);
}, 88 * 1000);
},
},
}, },
title: { title: {
text: "Pool Hashrate", text: '<b>Ethereum Classic - PPLNS </b>',
align: 'center',
x: 0,
y: 15,
useHTML: false,
style: { style: {
color: "#000" color: "rgba(0,0,0,0.76)",
fontSize: '15px',
fontFamily: 'Arial',
fontWeight: '400'
} }
}, },
xAxis: { xAxis: {
labels: {
style: {
color: "#000"
}
},
ordinal: false, ordinal: false,
type: "datetime" gridLineWidth: 1,
}, type: "datetime",
yAxis: {
title: {
text: "HASHRATE",
style: {
color: "#000"
}
},
min: 0,
labels: { labels: {
style: { style: {
color: "#000" color: "#000",
} },
} formatter: function () {
}, return formatDate(this.value, "hours:minutes");
plotLines: [{ },
value: 0,
width: 1,
color: "#ccc"
}],
legend: {
enabled: true
},
tooltip: {
formatter: function () {
return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000000).toFixed(2) + "&nbsp;TH/s</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000000).toFixed(2) + "&nbsp;GH/s</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Hashrate&nbsp;" + (this.y / 1000000).toFixed(2) + "&nbsp;MH/s</b>" : "<b>" + this.point.d + "<b><br>Hashrate<b>&nbsp;" + this.y.toFixed(2) + "&nbsp;H/s</b>";
}, },
useHTML: true
}, },
exporting: { yAxis: [
enabled: false
},
series: [{
color: "#15BD27",
name: "Hashrate",
data: function () {
var e, a = [];
if (null != t) {
for (e = 0; e <= t.length - 1; e += 1) {
var n = 0,
r = 0,
l = 0;
r = new Date(1e3 * t[e].x);
l = r.toLocaleString();
n = t[e].y; a.push({
x: r,
d: l,
y: n
});
}
} else {
a.push({
x: 0,
d: 0,
y: 0
});
}
return a;
}()
}]
};
return a;
}
}),
chartDiff: Ember.computed("model.hashrate", {
get() {
var e = this,
t = e.getWithDefault("stats.model.netCharts"),
a = {
chart: {
backgroundColor: "rgba(255, 255, 255, 0.1)",
type: "spline",
height: 250,
marginRight: 10,
//zoomType: 'xy',
/* events: {
load: function() {
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime(), y = e.getWithDefault("difficulty") / 1000000;
series.addPoint([x, y], true, true);
}, 1090000000);
}
} */
},
title: {
text: "Network Difficulty",
style: {
color: "#000"
}
},
rangeSelector: {
enabled: true,
selected: 4,
allButtonsEnabled: true,
inputDateFormat: '%Y/%m/%d %H:%M',
inputEditDateFormat: '%Y/%m/%d %H:%M',
inputEnabled: false,
buttons: [{
type: 'hour',
count: 1,
text: '1h'
},
{ {
type: 'hour', index: 0,
count: 2, tickAmount: 4,
text: '2h' title: {
text: "Pool Hashrate",
style: {
color: "#32e400",
},
},
min: 0,
labels: {
enabled: true,
style: {
color: "#000",
},
formatter: function () {
return formatNumber(this.value);
},
},
}, },
{ {
type: 'hour', index: 1,
count: 4, tickAmount: 4,
text: '4h' title: {
text: "NETWORK DIFFICULTY",
style: {
color: "#007BFF",
},
},
min: 0,
labels: {
enabled: true,
style: {
color: "#000",
},
formatter: function () {
return formatNumber(this.value);
},
},
opposite: true,
}, },
{ ],
type: 'hour', plotOptions: {
count: 6, areaspline: {
text: '6h' marker: {
enabled: false,
},
}, },
},
plotLines: [
{ {
type: 'hour', value: 0,
count: 12, width: 1,
text: '12h' color: "#000",
}, },
{ ],
type: 'all', legend: {
text: 'All' symbolRadius: 4,
} borderWidth: 1,
], itemStyle: {
}, color: "rgba(0,0,0,0.76)",
navigator: {
enabled: true
},
/* scrollbar: {
enabled:true,
barBackgroundColor: 'gray',
barBorderRadius: 7,
barBorderWidth: 0,
buttonBackgroundColor: 'gray',
buttonBorderWidth: 0,
buttonArrowColor: 'yellow',
buttonBorderRadius: 7,
rifleColor: 'yellow',
trackBackgroundColor: 'white',
trackBorderWidth: 1,
trackBorderColor: 'silver',
trackBorderRadius: 7
}, */
credits: {
enabled: false,
position: {
align: 'right',
x: -10,
verticalAlign: 'bottom',
y: -5
}, },
href: "https://highcharts.com", itemHoverStyle: {
text: "Highcharts" color: "#000000",
},
xAxis: {
labels: {
style: {
color: "#000"
}
//minRange: 1
}, },
ordinal: false, itemHiddenStyle: {
type: "datetime" color: "#A8A2A2",
},
yAxis: {
title: {
text: "DIFFICULTY",
style: {
color: "#000"
}
}, },
labels: {
style: {
color: "#000"
}
}
},
plotLines: [{
value: 0,
width: 1,
color: "#000"
}],
legend: {
enabled: false
}, },
tooltip: { tooltip: {
formatter: function () { borderRadius: 7,
return this.y > 1000000000000 ? "<b>" + this.point.d + "<b><br>Difficulty&nbsp;" + (this.y / 1000000000000).toFixed(2) + "&nbsp;TH/s</b>" : this.y > 1000000000 ? "<b>" + this.point.d + "<b><br>Difficulty&nbsp;" + (this.y / 1000000000).toFixed(2) + "&nbsp;GH/s</b>" : this.y > 1000000 ? "<b>" + this.point.d + "<b><br>Difficulty&nbsp;" + (this.y / 1000000).toFixed(2) + "&nbsp;MH/s</b>" : "<b>" + this.point.d + "<b><br>Difficulty<b>&nbsp;" + this.y.toFixed(2) + "&nbsp;H/s</b>"; borderWidth: 1,
}, shared: false,
useHTML: true headerFormat: "",
shared: false,
headerFormat: "",
}, },
exporting: { exporting: {
enabled: true enabled: false,
}, },
series: [{ series: [
color: "#F87217", {
name: "Difficulty", yAxis: 0,
data: function () { name: "Pool Hashrate",
var e, a = []; fillColor: "rgba(49, 227, 0, 0.22)",
if (null != t) { color: "#32e400",
for (e = 0; e <= t.length - 1; e += 1) { tooltip: {
var n = 0, pointFormatter: function () {
r = 0, return (
l = 0; formatDate(this.x, "day.month.year hours:minutes") +
r = new Date(1e3 * t[e].x); "<br><b>Pool Hashrate: " +
l = r.toLocaleString(); formatHashrate(this.y, true) +
n = t[e].y; a.push({ "</b>"
x: r, );
d: l, },
y: n },
states: {
inactive: {
opacity: 0.1,
},
},
data: function () {
var hashData = [];
if (null != t) {
t.forEach(function (entry) {
var x = new Date(1000 * entry.x);
var l = x.toLocaleString();
var y = entry.y;
hashData.push({ x: x, y: y, d: l });
});
}
var l = now.toLocaleString();
var y = e.getWithDefault("model.hashrate");
var lastHash = { x: now, y: y, d: l };
{ hashData.push(lastHash); }
return hashData;
}()
},
{
yAxis: 1,
name: "NETWORK DIFFICULTY",
fillColor: "rgba(212, 175, 55, 0.35)",
color: "#007BFF",
tooltip: {
pointFormatter: function () {
return (
formatDate(this.x, "day.month.year hours:minutes") +
"<br><b>NETWORK DIFFICULTY: " +
formatNumber(this.y) +
"</b>"
);
},
},
states: {
inactive: {
opacity: 0.1,
},
},
data: function () {
var netDiffData = [];
if (null != netCharts) {
netCharts.forEach(function (entry) {
var x = new Date(1000 * entry.x);
var l = x.toLocaleString();
var y = entry.y;
netDiffData.push({ x: x, y: y, d: l });
}); });
} }
} else {
a.push({
x: 0,
d: 0,
y: 0
});
}
return a;
}()
}] return netDiffData;
}()
},
],
}; };
return a; return a;
} },
}), }),
dag: Ember.computed("stats", "model", { dag: Ember.computed("stats", "model", {
get() { get() {
var percent = (this.get("epoch") * 8192) / 1024 / 1024 + 1; var percent = (this.get("epoch") * 8192) / 1024 / 1024 + 1;
@ -296,9 +309,10 @@ export default Ember.Controller.extend({
return percent; return percent;
}, },
}), }),
epoch: Ember.computed("model.stats", { epoch: Ember.computed("model.stats", {
get() { get() {
return parseInt(this.get("applicationController.height") / 60000); /* etchash 60000 ethash 30000 */ return parseInt(this.get("applicationController.height") / 30000);
}, },
}) }),
}); });

3
www/app/templates/index.hbs

@ -56,9 +56,6 @@
<div> <div>
{{high-charts mode=chartMode chartOptions=chartOptions content=chartData}} {{high-charts mode=chartMode chartOptions=chartOptions content=chartData}}
</div> </div>
<div>
{{high-charts mode=mode chartOptions=chartDiff content=chartData}}
</div>
<div class="stats"> <div class="stats">
<h3>{{t "home.query_history"}}</h3> <h3>{{t "home.query_history"}}</h3>
<div class="input-group"> <div class="input-group">

2
www/translations/en-us.yaml

@ -41,7 +41,7 @@ home:
payouts_run: every {interval}. payouts_run: every {interval}.
payout_scheme_detail: Real time PPLNS payout scheme. payout_scheme_detail: Real time PPLNS payout scheme.
miners_online: Miners Online miners_online: Miners Online
pool_hashrate: Pool Hash Rate pool_hashrate: Pool Hashrate
pool_fee: Pool Fee pool_fee: Pool Fee
last_block_found: Last Block Found last_block_found: Last Block Found
network_difficulty: Network Difficulty network_difficulty: Network Difficulty

Loading…
Cancel
Save