From 10ebddaf89beab497a8ca5af930bb8182ec7a898 Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Tue, 4 Sep 2012 00:24:05 +0530 Subject: [PATCH] jqplot: y axis autoscaling enabled, jqplot's autoscale didn't seem to work --- js/server_status_monitor.js | 51 ++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index 7410de4725..bef3d0ddde 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -72,7 +72,8 @@ $(function() { nodes: [ { dataPoints: [{type: 'statusvar', name: 'Qcache_hits'}, {type: 'statusvar', name: 'Com_select'}], transformFn: 'qce' - } ] + } ], + maxYLabel: [] }, // Query cache usage 'qcu': { @@ -83,7 +84,8 @@ $(function() { nodes: [ { dataPoints: [{type: 'statusvar', name: 'Qcache_free_memory'}, {type: 'servervar', name: 'query_cache_size'}], transformFn: 'qcu' - } ] + } ], + maxYLabel: [] } }; @@ -98,7 +100,8 @@ $(function() { } ], nodes: [ { dataPoints: [{ type: 'cpu', name: 'loadavg'}] - } ] + } ], + maxYLabel: [] }, 'memory': { @@ -115,7 +118,8 @@ $(function() { } ], nodes: [{ dataPoints: [{ type: 'memory', name: 'MemTotal' }], valueDivisor: 1024 }, { dataPoints: [{ type: 'memory', name: 'MemUsed' }], valueDivisor: 1024 } - ] + ], + maxYLabel: [] }, 'swap': { @@ -131,7 +135,8 @@ $(function() { } ], nodes: [{ dataPoints: [{ type: 'memory', name: 'SwapTotal' }]}, { dataPoints: [{ type: 'memory', name: 'SwapUsed' }]} - ] + ], + maxYLabel: [] } }); break; @@ -143,7 +148,8 @@ $(function() { series: [ { label: PMA_messages['strAverageLoad'] } ], - nodes: [{ dataPoints: [{ type: 'cpu', name: 'irrelevant' }], transformFn: 'cpu-linux'}] + nodes: [{ dataPoints: [{ type: 'cpu', name: 'irrelevant' }], transformFn: 'cpu-linux'}], + maxYLabel: [] }, 'memory': { title: PMA_messages['strSystemMemory'], @@ -158,7 +164,8 @@ $(function() { { dataPoints: [{ type: 'memory', name: 'Cached' }], valueDivisor: 1024 }, { dataPoints: [{ type: 'memory', name: 'Buffers' }], valueDivisor: 1024 }, { dataPoints: [{ type: 'memory', name: 'MemFree' }], valueDivisor: 1024 } - ] + ], + maxYLabel: [] }, 'swap': { title: PMA_messages['strSystemSwap'], @@ -171,7 +178,8 @@ $(function() { { dataPoints: [{ type: 'memory', name: 'SwapUsed' }], valueDivisor: 1024 }, { dataPoints: [{ type: 'memory', name: 'SwapCached' }], valueDivisor: 1024 }, { dataPoints: [{ type: 'memory', name: 'SwapFree' }], valueDivisor: 1024 } - ] + ], + maxYLabel: [] } }); break; @@ -181,7 +189,8 @@ $(function() { defaultChartGrid = { 'c0': { title: PMA_messages['strQuestions'], series: [{label: PMA_messages['strQuestions']}], - nodes: [{dataPoints: [{ type: 'statusvar', name: 'Questions' }], display: 'differential' }] + nodes: [{dataPoints: [{ type: 'statusvar', name: 'Questions' }], display: 'differential' }], + maxYLabel: [] }, 'c1': { title: PMA_messages['strChartConnectionsTitle'], @@ -189,7 +198,8 @@ $(function() { { label: PMA_messages['strProcesses']} ], nodes: [ { dataPoints: [{ type: 'statusvar', name: 'Connections' }], display: 'differential' }, { dataPoints: [{ type: 'proc', name: 'processes' }] } - ] + ], + maxYLabel: [] }, 'c2': { title: PMA_messages['strTraffic'], @@ -200,7 +210,8 @@ $(function() { nodes: [ { dataPoints: [{ type: 'statusvar', name: 'Bytes_sent' }], display: 'differential', valueDivisor: 1024 }, { dataPoints: [{ type: 'statusvar', name: 'Bytes_received' }], display: 'differential', valueDivisor: 1024 } - ] + ], + maxYLabel: [] } }; @@ -1083,8 +1094,8 @@ $(function() { }, yaxis: { min:0, - max:500, - numberTicks:6 + max:100, + tickInterval: 20 } }, seriesDefaults: { @@ -1279,18 +1290,22 @@ $(function() { // Set y value, if defined if (value != undefined) { - /*elem.chart.series[j].addPoint( - { x: chartData.x, y: value }, - false, - elem.numPoints >= runtime.gridMaxPoints - );*/ elem.chart.series[j].data.push([chartData.x, value]); + if(elem.maxYLabel.length == 0) { + elem.maxYLabel.push([runtime.xmax, 100]); + }else if(value > elem.maxYLabel[elem.maxYLabel.length - 1][1]) { + elem.maxYLabel.push([chartData.x, value + 200]); + } else if(elem.maxYLabel[elem.maxYLabel.length - 1][0] < runtime.xmin) { + elem.maxYLabel.pop(); + } } } // update chart options elem.chart['axes']['xaxis']['max'] = runtime.xmax; elem.chart['axes']['xaxis']['min'] = runtime.xmin; + elem.chart['axes']['yaxis']['max'] = (elem.maxYLabel.length == 0) ? 100 : elem.maxYLabel[elem.maxYLabel.length - 1][1]; + elem.chart['axes']['yaxis']['tickInterval'] = (elem.maxYLabel.length == 0) ? 20 : Math.floor(elem.maxYLabel[elem.maxYLabel.length - 1][1]/5); i++; runtime.charts[orderKey].numPoints++; if (runtime.redrawCharts) {