Skip to content

Commit

Permalink
Fix the wrong coordinate scaling of QPS chart (passed/blocked) in das…
Browse files Browse the repository at this point in the history
…hboard (#172)

Fixes #22 (by @jasonjoo2010)
  • Loading branch information
jasonjoo2010 authored and sczyh30 committed Oct 16, 2018
1 parent b06bb02 commit a757950
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,31 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
height: 250,
padding: [10, 30, 70, 30]
});
var maxQps = 0;
for (var i in metric.data) {
var item = metric.data[i];
if (item.passQps > maxQps) {
maxQps = item.passQps;
}
if (item.blockQps > maxQps) {
maxQps = item.blockQps;
}
}
chart.source(metric.data);
chart.scale('timestamp', {
type: 'time',
mask: 'YYYY-MM-DD HH:mm:ss'
});
chart.scale('passQps', {
min: 0,
max: maxQps,
fine: true,
alias: 'p_qps'
// max: 10
});
chart.scale('blockQps', {
min: 0,
max: maxQps,
fine: true,
alias: 'b_qps',
});
Expand All @@ -105,7 +117,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
textAlign: 'center', // 文本对齐方向,可取值为: start center end
fill: '#404040', // 文本的颜色
fontSize: '11', // 文本大小
textBaseline: 'top', // 文本基准线,可取 top middle bottom,默认为middle
//textBaseline: 'top', // 文本基准线,可取 top middle bottom,默认为middle
},
autoRotate: false,
formatter: function (text, item, index) {
Expand All @@ -115,9 +127,9 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
});
chart.legend({
custom: true,
position: 'bottom',
allowAllCanceled: true,
itemFormatter: function (val) {
// console.log('val=', val);
if ('passQps' === val) {
return 'p_qps';
}
Expand All @@ -129,7 +141,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
items: [
{ value: 'passQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } },
{ value: 'blockQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } },
// { value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} },
//{ value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} },
],
onClick: function (ev) {
const item = ev.item;
Expand All @@ -150,7 +162,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
});
chart.line().position('timestamp*passQps').size(1).color('green').shape('smooth');
chart.line().position('timestamp*blockQps').size(1).color('blue').shape('smooth');
// chart.line().position('timestamp*rt').size(1).color('gray');
//chart.line().position('timestamp*rt').size(1).color('gray').shape('smooth');
G2.track(false);
chart.render();
});
Expand Down
2 changes: 1 addition & 1 deletion sentinel-dashboard/src/main/webapp/resources/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//cdn.bootcss.com/angular.js/1.4.8/angular.min.js"></script>
<script src="//gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.2.0-beta.6/dist/g2.min.js"></script>
<script src="//gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.3.0-beta.4/dist/g2.min.js"></script>

<script src="dist/js/app.vendor.js"></script>
<script src="dist/js/app.js"></script>
Expand Down

0 comments on commit a757950

Please sign in to comment.