diff --git a/README.md b/README.md index 9892b90..8191b0c 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ Table of Contents - Luxon v2.1.1 - jqPlot v1.0.9 - Chart.js v3.6.1 + - chartjs-plugin-crosshair v1.2.0 ([https://github.com/abelheinsbroek/chartjs-plugin-crosshair](https://github.com/abelheinsbroek/chartjs-plugin-crosshair)) - flag-icon-css v4.1.4 ([https://github.com/lipis/flag-icon-css](https://github.com/lipis/flag-icon-css)) - Mobile-friendly - Sass support @@ -161,6 +162,9 @@ Table of Contents - **Price:** Displays the current market price (value measured using default market pair) - **Market Cap:** Displays the current market cap value in (value measured using default market pair) - **Logo:** Display an image of your coin logo +- Configurable network charts that can be independently displayed in the header of any page + - **Hashrate chart:** Line graph listing of the estimated network hashes per second over the last number of blocks *\*Requires a full sync before network data will start being collected* + - **Difficulty chart:** Line graph listing of the block difficulty over the last number of blocks *\*Requires a full sync before network data will start being collected* - Add as many custom social links to the explorer footer as desired. Useful for linking to github, twitter, coinmarketcap or any other social media or external links as necessary. - Custom rpc/api command support which increases blockchain compatibility. Supported cmds: - **getnetworkhashps:** Returns the estimated network hashes per second diff --git a/app.js b/app.js index 34a5752..c87153a 100644 --- a/app.js +++ b/app.js @@ -575,6 +575,15 @@ app.use('/ext/getmasternoderewardstotal/:hash/:since', function(req, res) { res.end('This method is disabled'); }); +app.use('/ext/getnetworkchartdata', function(req, res) { + db.get_network_chart_data(function(data) { + if (data) + res.send(data); + else + res.send(); + }); +}); + var market_data = []; var market_count = 0; @@ -680,6 +689,7 @@ settings.api_page.public_apis.rpc.getmasternodelist = { "enabled": false }; app.set('explorer_version', package_metadata.version); app.set('locale', locale); app.set('coin', settings.coin); +app.set('network_history', settings.network_history); app.set('shared_pages', settings.shared_pages); app.set('index_page', settings.index_page); app.set('block_page', settings.block_page); diff --git a/lib/database.js b/lib/database.js index 253635b..79a558f 100644 --- a/lib/database.js +++ b/lib/database.js @@ -8,6 +8,7 @@ var mongoose = require('mongoose'), Richlist = require('../models/richlist'), Peers = require('../models/peers'), Heavy = require('../models/heavy'), + NetworkHistory = require('../models/networkhistory'), lib = require('./explorer'), settings = require('./settings'), locale = require('./locale'), @@ -826,6 +827,65 @@ module.exports = { }); }, + // updates network history (nethash and difficulty) data + // height: current block height + update_network_history: function(height, cb) { + // lookup network history data for this block height + NetworkHistory.findOne({blockindex: height}, function(err, network_hist) { + // check if there is already network history data for this block height + if (!network_hist) { + // lookup network hashrate + lib.get_hashrate(function(hashrate) { + // lookup network difficulty + lib.get_difficulty(function(difficulty) { + // create a new network history record + var newNetworkHistory = new NetworkHistory({ + blockindex: height, + nethash: (hashrate == null || hashrate == '-' ? 0 : hashrate), + difficulty: difficulty + }); + + // save the new network history record + newNetworkHistory.save(function(err) { + // check for errors + if (err) { + console.log('error updating network history: ' + err); + return cb(); + } else { + // get the count of network history records + NetworkHistory.find({}).countDocuments(function(err, count) { + // read maximum allowed records from settings + let max_records = settings.network_history.max_saved_records; + + // check if the current count of records is greater than the maximum allowed + if (count > max_records) { + // prune network history records to keep collection small and quick to access + NetworkHistory.find().select('blockindex').sort({blockindex: 1}).limit(count - max_records).exec(function(err, records) { + // create a list of the oldest network history ids that will be deleted + const ids = records.map((doc) => doc.blockindex); + + // delete old network history records + NetworkHistory.deleteMany({blockindex: {$in: ids}}, function(err) { + console.log('network history update complete'); + return cb(); + }); + }); + } else { + console.log('network history update complete'); + return cb(); + } + }); + } + }); + }); + }); + } else { + // skip saving network history data when the block hasn't moved since saving last time + return cb(); + } + }); + }, + // updates market data for given market; called by sync.js update_markets_db: function(market, coin_symbol, pair_symbol, cb) { // check if market exists @@ -1377,5 +1437,12 @@ module.exports = { }); }, + get_network_chart_data: function(cb) { + // lookup all network history data for populating network charts + NetworkHistory.find().sort({blockindex: 1}).exec(function (err, data) { + return cb(data); + }); + }, + fs: fs }; \ No newline at end of file diff --git a/lib/settings.js b/lib/settings.js index a39e2fd..2a24e57 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -79,6 +79,15 @@ exports.coin = { "symbol": "EXOR" }; +// network_history: a collection of settings that controls saving of extra historical network data during a block sync +exports.network_history = { + // enabled: Enable/disable the saving of additional network history data (true/false) + // If set to false, historical data such as network hashrate and difficulty values will not be saved or available for network charts + "enabled": true, + // max_saved_records: The maximum # of blocks to save historical data for + "max_saved_records": 120 +}; + /* Shared page settings */ // shared_pages: a collection of settings that pertain to all webpages for the explorer @@ -127,7 +136,7 @@ exports.shared_pages = { // Hybrid: Display both the proof-of-work and proof-of-stake difficulty values "difficulty": "POS", // show_hashrate: Determine whether to show network hash rate where applicable (true/false) - // If set to false, the /api/getnetworkhashps and /ext/getsummary apis will no longer show hash rate information + // If set to false, the /api/getnetworkhashps and /ext/getsummary apis will no longer show hash rate information, and the network hashrate chart will automatically be disabled "show_hashrate": true, // page_header: A collection of settings that pertain to the page header that is displayed at the top of all pages "page_header": { @@ -250,6 +259,60 @@ exports.shared_pages = { "image_path": "/img/page-title-img.png", // enable_animation: Enable/disable the flip/spin animation on the page title image (true/false) "enable_animation": true + }, + // network_charts: A collection of settings that pertain to the network hashrate and difficulty line charts displayed on page header of all pages + // NOTE: You can independently show/hide individual charts by changing the show_nethash_chart and show_difficulty_chart values in the settings for each page + // The "network_history.enabled" setting must be set to true for network charts to work correctly + // If the "network_history.enabled" setting is false, all network charts will be completely disabled, regardless of their independent settings + "network_charts": { + // nethash_chart: A collection of settings that pertain to the network hashrate chart + "nethash_chart": { + // enabled: Enable/disable the network hashrate chart (true/false) + // If set to false, the network hashrate chart will be completely inaccessible + // NOTE: The `shared_pages.show_hashrate` option must be set to true or else the network hashrate chart will be completely inaccessible + "enabled": true, + // bgcolor: Change the background color of the network hashrate chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "bgcolor": "#ffffff", + // line_color: Change the line color of the network hashrate chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "line_color": "rgba(54, 162, 235, 1)", + // fill_color: Change the fill color of the network hashrate chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "fill_color": "rgba(54, 162, 235, 0.2)", + // crosshair_color: Change the vertical crosshair line color of the network hashrate chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "crosshair_color": "#000000" + }, + // difficulty_chart: A collection of settings that pertain to the network difficulty chart + "difficulty_chart": { + // enabled: Enable/disable the network difficulty chart (true/false) + // If set to false, the network difficulty chart will be completely inaccessible + "enabled": true, + // bgcolor: Change the background color of the network difficulty chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "bgcolor": "#ffffff", + // line_color: Change the line color of the network difficulty chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "line_color": "rgba(255, 99, 132, 1)", + // fill_color: Change the fill color of the network difficulty chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "fill_color": "rgba(255, 99, 132, 0.2)", + // crosshair_color: Change the vertical crosshair line color of the network difficulty chart + // Set this to any valid html color + // Ex: "#ffffff" or "rgba(255, 255, 255, 1)" or "white" + "crosshair_color": "#000000" + }, + // reload_chart_seconds: The time in seconds to automatically reload the network chart data from the server + // Set to 0 to disable automatic reloading of chart data + "reload_chart_seconds": 60 } }, // page_footer: A collection of settings that pertain to the page footer that is displayed at the bottom of all pages @@ -294,6 +357,10 @@ exports.shared_pages = { exports.index_page = { // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": true, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": true, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": true, // page_header: a collection of settings that pertain to the index page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -323,6 +390,10 @@ exports.index_page = { exports.block_page = { // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the block page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -342,6 +413,10 @@ exports.block_page = { exports.transaction_page = { // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the transaction/tx page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -364,6 +439,10 @@ exports.transaction_page = { exports.address_page = { // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the address page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -398,6 +477,10 @@ exports.address_page = { exports.error_page = { // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the error page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -418,6 +501,10 @@ exports.masternodes_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the masternodes page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -446,6 +533,10 @@ exports.movement_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the movement page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -484,6 +575,10 @@ exports.network_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the network page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -528,6 +623,10 @@ exports.richlist_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the richlist/top100 page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -579,6 +678,10 @@ exports.markets_page = { "enabled": false, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the markets page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -714,6 +817,10 @@ exports.api_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the api page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -951,6 +1058,10 @@ exports.claim_address_page = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the claim address page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) @@ -1073,6 +1184,10 @@ exports.blockchain_specific = { "enabled": true, // show_panels: Determine whether to show the panels configured in the shared_pages.page_header section across the top of this page (true/false) "show_panels": false, + // show_nethash_chart: Determine whether to show the network hashrate chart configured in the shared_pages.network_charts.nethash_chart section across the top of this page (true/false) + "show_nethash_chart": false, + // show_difficulty_chart: Determine whether to show the network difficulty chart configured in the shared_pages.network_charts.difficulty_chart section across the top of this page (true/false) + "show_difficulty_chart": false, // page_header: a collection of settings that pertain to the reward page header "page_header": { // show_img: Determine whether to show the page title image defined in the "shared_pages.page_header.page_title_image" setting (true/false) diff --git a/models/networkhistory.js b/models/networkhistory.js new file mode 100644 index 0000000..fc99549 --- /dev/null +++ b/models/networkhistory.js @@ -0,0 +1,10 @@ +var mongoose = require('mongoose'), + Schema = mongoose.Schema; + +var NetworkHistorySchema = new Schema({ + blockindex: {type: Number, default: 0, index: true}, + nethash: { type: Number, default: 0 }, + difficulty: { type: Number, default: 0 } +}, {id: false}); + +module.exports = mongoose.model('NetworkHistory', NetworkHistorySchema); \ No newline at end of file diff --git a/scripts/delete_database.sh b/scripts/delete_database.sh index 831b30f..403c155 100755 --- a/scripts/delete_database.sh +++ b/scripts/delete_database.sh @@ -21,6 +21,7 @@ sudo touch "${SCRIPT_PATH}/del.tmp" && mongo < a.nav-link').addClass('active'); @@ -265,34 +333,187 @@ html(lang='en') $("#lblBlockcount").text(json.blockcount + ' blocks'); }}); } + var nethashChart; + var difficultyChart; + function update_network_charts() { + $.ajax({ + url: '/ext/getnetworkchartdata', + success: function(result) { + if (#{settings.network_history.enabled} == true && #{showNethashChart} == true && #{settings.shared_pages.page_header.network_charts.nethash_chart.enabled} == true && #{settings.shared_pages.show_hashrate} == true) { + const ctxNethash = document.getElementById('nethashChart').getContext('2d'); + + if (nethashChart == null) { + nethashChart = new Chart(ctxNethash, { + type: 'line', + data: { + labels: result.map(function(a) {return a.blockindex;}), + datasets: [ + { + label: 'Hashrate', + data: result.map(function(a) {return a.nethash;}), + backgroundColor: ['#{settings.shared_pages.page_header.network_charts.nethash_chart.fill_color}'], + borderColor: ['#{settings.shared_pages.page_header.network_charts.nethash_chart.line_color}'], + fill: 'start' + } + ] + }, + options: { + maintainAspectRatio: false, + elements: { + point: { + radius: 1 + }, + line: { + tension: 0.1 + } + }, + scales: { + yAxis: { + title: { + display: true, + text: 'Network ' + getNetHashUnits(), + font: { + weight: 'bold' + } + } + } + }, + plugins: { + legend: { + display: true, + position: 'bottom' + }, + title: { + display: false + }, + tooltip: { + mode: 'index', + intersect: false, + displayColors: true, + callbacks: { + title: function(context) { + return 'Block ' + context[0].label + ' Hashrate'; + }, + label: function(context) { + return context.formattedValue + ' ' + getNetHashUnits() + } + } + }, + crosshair: { + line: { + color: '#{settings.shared_pages.page_header.network_charts.nethash_chart.crosshair_color}', + width: 1 + }, + sync: { + enabled: false + }, + zoom: { + enabled: false + } + } + } + } + }); + $('#nethashChartParent').fadeIn(); + } else { + nethashChart.data.labels = result.map(function(a) {return a.blockindex;}); + nethashChart.data.datasets[0].data = result.map(function(a) {return a.nethash;}); + nethashChart.update(); + } + } + + if (#{settings.network_history.enabled} == true && #{showDifficultyChart} == true && #{settings.shared_pages.page_header.network_charts.difficulty_chart.enabled} == true) { + const ctxDifficulty = document.getElementById('difficultyChart').getContext('2d'); + + if (difficultyChart == null) { + difficultyChart = new Chart(ctxDifficulty, { + type: 'line', + data: { + labels: result.map(function(a) {return a.blockindex;}), + datasets: [ + { + label: 'Difficulty', + data: result.map(function(a) {return a.difficulty;}), + backgroundColor: ['#{settings.shared_pages.page_header.network_charts.difficulty_chart.fill_color}'], + borderColor: ['#{settings.shared_pages.page_header.network_charts.difficulty_chart.line_color}'], + fill: 'start' + } + ] + }, + options: { + maintainAspectRatio: false, + elements: { + point: { + radius: 1 + }, + line: { + tension: 0.1 + } + }, + scales: { + yAxis: { + title: { + display: true, + text: 'Difficulty', + font: { + weight: 'bold' + } + } + } + }, + plugins: { + legend: { + display: true, + position: 'bottom' + }, + title: { + display: false + }, + tooltip: { + mode: 'index', + intersect: false, + displayColors: true, + callbacks: { + title: function(context) { + return 'Block ' + context[0].label + ' Difficulty'; + }, + label: function(context) { + return context.formattedValue; + } + } + }, + crosshair: { + line: { + color: '#{settings.shared_pages.page_header.network_charts.difficulty_chart.crosshair_color}', + width: 1 + }, + sync: { + enabled: false + }, + zoom: { + enabled: false + } + } + } + } + }); + $('#difficultyChartParent').fadeIn(); + } else { + difficultyChart.data.labels = result.map(function(a) {return a.blockindex;}); + difficultyChart.data.datasets[0].data = result.map(function(a) {return a.difficulty;}); + difficultyChart.update(); + } + } + } + }); + } $(window).resize(function () { fixDataTableColumns(); fixFooterHeightAndPosition(); }); function getNetworkPanel() { - var networkSuffix=''; - switch ('#{settings.shared_pages.page_header.panels.network_panel.nethash_units}') { - case "K": - networkSuffix='(KH/s)'; - break; - case "M": - networkSuffix='(MH/s)'; - break; - case "G": - networkSuffix='(GH/s)'; - break; - case "T": - networkSuffix='(TH/s)'; - break; - case "P": - networkSuffix='(PH/s)'; - break; - case "H": - networkSuffix='(H/s)'; - break; - } var hashRateType=''; - return '
#{settings.locale.network} '+networkSuffix+'
'; + return '
#{settings.locale.network} '+getNetHashUnits()+'
'; } function getDifficultyPanel() { var difficultyType=''; @@ -372,6 +593,15 @@ html(lang='en') setInterval(function() { update_stats(); }, 60000); + if (#{settings.network_history.enabled} == true && ((#{showNethashChart} == true && #{settings.shared_pages.page_header.network_charts.nethash_chart.enabled} == true && #{settings.shared_pages.show_hashrate} == true) || (#{showDifficultyChart} == true && #{settings.shared_pages.page_header.network_charts.difficulty_chart.enabled} == true))) { + var setting_reload_chart_seconds = #{settings.shared_pages.page_header.network_charts.reload_chart_seconds}; + if (setting_reload_chart_seconds > 0) { + setInterval(function() { + update_network_charts(); + }, (setting_reload_chart_seconds * 1000)); + } + update_network_charts(); + } update_stats(); fixFooterHeightAndPosition(); enableTooltips(); @@ -521,6 +751,26 @@ html(lang='en') #index-search.form-group.d-flex.justify-content-center input.form-control(type='text', name='search', placeholder=settings.locale.ex_search_message, style='min-width:80%;margin-right:5px;') button.btn.btn-success(type='submit') #{settings.locale.ex_search_button} + if settings.network_history.enabled == true && ((showNethashChart == true && settings.shared_pages.page_header.network_charts.nethash_chart.enabled == true && settings.shared_pages.show_hashrate == true) || (showDifficultyChart == true && settings.shared_pages.page_header.network_charts.difficulty_chart.enabled == true)) + .container + .row.align-items-start + - var chartColumnClass = 'col-lg-12'; + if showNethashChart == true && settings.shared_pages.page_header.network_charts.nethash_chart.enabled == true && settings.shared_pages.show_hashrate == true && showDifficultyChart == true && settings.shared_pages.page_header.network_charts.difficulty_chart.enabled == true + - chartColumnClass = 'col-lg-6'; + if showNethashChart == true && settings.shared_pages.page_header.network_charts.nethash_chart.enabled == true && settings.shared_pages.show_hashrate == true + div#nethashChartParent(class=chartColumnClass, style='display:none;margin:10px 0;') + .card.card-default.border-0 + .card-header + strong Network Hashrate + .card-body + canvas#nethashChart(style='max-height:300px;background-color:'+settings.shared_pages.page_header.network_charts.nethash_chart.bgcolor+';') + if showDifficultyChart == true && settings.shared_pages.page_header.network_charts.difficulty_chart.enabled == true + div#difficultyChartParent(class=chartColumnClass, style='display:none;margin:10px 0;') + .card.card-default.border-0 + .card-header + strong Network Difficulty + .card-body + canvas#difficultyChart(style='max-height:300px;background-color:'+settings.shared_pages.page_header.network_charts.difficulty_chart.bgcolor+';') block content div#footer-container(class=footerClasses, role='navigation') .col-4.navbar-nav diff --git a/views/reward.pug b/views/reward.pug index d8e9098..7fb43b2 100644 --- a/views/reward.pug +++ b/views/reward.pug @@ -123,7 +123,8 @@ block content plugins: { legend: { display: false - } + }, + crosshair: false } }; new Chart(ctx, { type: 'doughnut', data: data, options: options }); @@ -162,7 +163,8 @@ block content plugins: { legend: { display: false - } + }, + crosshair: false }, scales: { y: {