Skip to content

Commit e1e7ce9

Browse files
jasonjoo2010sczyh30
authored andcommitted
Fix the wrong coordinate scaling of QPS chart (passed/blocked) in dashboard (alibaba#172)
Fixes alibaba#22 (by @jasonjoo2010)
1 parent 8bd61fd commit e1e7ce9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

sentinel-dashboard/src/main/webapp/resources/app/scripts/controllers/metric.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,31 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
7070
height: 250,
7171
padding: [10, 30, 70, 30]
7272
});
73+
var maxQps = 0;
74+
for (var i in metric.data) {
75+
var item = metric.data[i];
76+
if (item.passQps > maxQps) {
77+
maxQps = item.passQps;
78+
}
79+
if (item.blockQps > maxQps) {
80+
maxQps = item.blockQps;
81+
}
82+
}
7383
chart.source(metric.data);
7484
chart.scale('timestamp', {
7585
type: 'time',
7686
mask: 'YYYY-MM-DD HH:mm:ss'
7787
});
7888
chart.scale('passQps', {
7989
min: 0,
90+
max: maxQps,
8091
fine: true,
8192
alias: 'p_qps'
8293
// max: 10
8394
});
8495
chart.scale('blockQps', {
8596
min: 0,
97+
max: maxQps,
8698
fine: true,
8799
alias: 'b_qps',
88100
});
@@ -105,7 +117,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
105117
textAlign: 'center', // 文本对齐方向,可取值为: start center end
106118
fill: '#404040', // 文本的颜色
107119
fontSize: '11', // 文本大小
108-
textBaseline: 'top', // 文本基准线,可取 top middle bottom,默认为middle
120+
//textBaseline: 'top', // 文本基准线,可取 top middle bottom,默认为middle
109121
},
110122
autoRotate: false,
111123
formatter: function (text, item, index) {
@@ -115,9 +127,9 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
115127
});
116128
chart.legend({
117129
custom: true,
130+
position: 'bottom',
118131
allowAllCanceled: true,
119132
itemFormatter: function (val) {
120-
// console.log('val=', val);
121133
if ('passQps' === val) {
122134
return 'p_qps';
123135
}
@@ -129,7 +141,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
129141
items: [
130142
{ value: 'passQps', marker: { symbol: 'hyphen', stroke: 'green', radius: 5, lineWidth: 2 } },
131143
{ value: 'blockQps', marker: { symbol: 'hyphen', stroke: 'blue', radius: 5, lineWidth: 2 } },
132-
// { value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} },
144+
//{ value: 'rt', marker: {symbol: 'hyphen', stroke: 'gray', radius: 5, lineWidth: 2} },
133145
],
134146
onClick: function (ev) {
135147
const item = ev.item;
@@ -150,7 +162,7 @@ app.controller('MetricCtl', ['$scope', '$stateParams', 'MetricService', '$interv
150162
});
151163
chart.line().position('timestamp*passQps').size(1).color('green').shape('smooth');
152164
chart.line().position('timestamp*blockQps').size(1).color('blue').shape('smooth');
153-
// chart.line().position('timestamp*rt').size(1).color('gray');
165+
//chart.line().position('timestamp*rt').size(1).color('gray').shape('smooth');
154166
G2.track(false);
155167
chart.render();
156168
});

sentinel-dashboard/src/main/webapp/resources/index.htm

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<script src="//cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
2020
<script src="//cdn.bootcss.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
2121
<script src="//cdn.bootcss.com/angular.js/1.4.8/angular.min.js"></script>
22-
<script src="//gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.2.0-beta.6/dist/g2.min.js"></script>
22+
<script src="//gw.alipayobjects.com/os/antv/pkg/_antv.g2-3.3.0-beta.4/dist/g2.min.js"></script>
2323

2424
<script src="dist/js/app.vendor.js"></script>
2525
<script src="dist/js/app.js"></script>

0 commit comments

Comments
 (0)