Merge branch 'master' of https://github.com/lostcharlie/Bench4Q.git
Conflicts: Bench4Q-Web/src/main/webapp/script/testResult/pieChart.js
This commit is contained in:
commit
34025c9605
File diff suppressed because one or more lines are too long
|
@ -179,6 +179,7 @@ result-vuser=VUs Active
|
|||
result-request=Requests
|
||||
result-loadingInfo=Please wait,loading result data...
|
||||
result-charts=Charts
|
||||
result-resource-types=Resource types
|
||||
testPlan-view=View Result
|
||||
home-createScript=Create New Script
|
||||
delete=Delete
|
||||
|
|
|
@ -179,6 +179,7 @@ result-testStatus=\u6D4B\u8BD5\u72B6\u6001
|
|||
result-vuser=\u5E76\u53D1\u7528\u6237
|
||||
result-request=\u53D1\u9001\u8BF7\u6C42
|
||||
result-charts=\u6D4B\u8BD5\u7ED3\u679C
|
||||
result-resource-types=\u8d44\u6e90\u7c7b\u578b
|
||||
result-loadingInfo=\u8BF7\u7A0D\u7B49\uFF0C\u6B63\u5728\u52A0\u8F7D\u6570\u636E
|
||||
testPlan-view=\u67E5\u770B\u7ED3\u679C
|
||||
scriptmanagerment=\u811A\u672C\u7BA1\u7406
|
||||
|
|
|
@ -142,6 +142,11 @@ body {
|
|||
</table>
|
||||
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<h4 class="pull-left"><fmt:message key="result-resource-types" /></h4>
|
||||
</div>
|
||||
|
||||
<div class="app-container " id="pie-chart"></div>
|
||||
<!-- <div class="app-container" id="url-distribution"></div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
@ -233,4 +238,4 @@ body {
|
|||
<script src="script/Share/information.js"></script>
|
||||
</fmt:bundle>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
var PieChart = function(chartId, title) {
|
||||
var PiePoint = function(name, count, percentage) {
|
||||
this.name = name;
|
||||
this.count = count;
|
||||
this.percentage = percentage;
|
||||
}
|
||||
|
||||
var PieChart = function(chartId, title) {
|
||||
$('#' + chartId)
|
||||
.highcharts(
|
||||
{
|
||||
|
@ -10,7 +15,8 @@ var PieChart = function(chartId, title) {
|
|||
plotShadow : false
|
||||
},
|
||||
title : {
|
||||
text : title
|
||||
text : title,
|
||||
align: 'left'
|
||||
},
|
||||
tooltip : {
|
||||
pointFormat : '{series.name}: <b>{point.percentage:.1f}</b> %'
|
||||
|
@ -24,7 +30,7 @@ var PieChart = function(chartId, title) {
|
|||
enabled : true,
|
||||
color : '#000000',
|
||||
connectorColor : '#000000',
|
||||
format : '<b>{point.name}</b>: {point.percentage:.1f} %'
|
||||
format : '<b>{point.name}</b>: {point.count} ({point.percentage:.1f}%)'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -40,35 +46,41 @@ var PieChart = function(chartId, title) {
|
|||
var UrlContentTypeDistribution = function(containerId, testPlanId) {
|
||||
var pieChart = new PieChart(containerId, "URL content type distribution");
|
||||
var chart = $("#" + containerId).highcharts();
|
||||
var urlPath = [ testPlanId, "urlContentTypePercent" ];
|
||||
var url = generateUrl(urlPath);
|
||||
var i=0;
|
||||
var intervalId = setInterval(function() {
|
||||
|
||||
$.post(url, "", function(data) {
|
||||
var dataArray = new Array();
|
||||
if(!data.success){
|
||||
information(data.failedMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
else data=data.data;
|
||||
|
||||
for(var key in data)
|
||||
dataArray.push([key,data[key]]);
|
||||
chart.series[0].setData(dataArray);
|
||||
|
||||
|
||||
loadItems.urlDistribution=true;
|
||||
},"json").error(function(){
|
||||
information($.i18n.prop('failed-connect-server'));
|
||||
});
|
||||
|
||||
if (testStatus == "Complete"&&i>=1) {
|
||||
clearInterval(intervalId);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
|
||||
}, 1000);
|
||||
getUrlContentTypeData(testPlanId, chart);
|
||||
}
|
||||
|
||||
var addPieData = function(chart,data){
|
||||
var points = contentTypeDataFormat(data);
|
||||
for(var i=0; i<points.length; i++){
|
||||
chart.series[0].addPoint({
|
||||
name: points[i].name,
|
||||
count: points[i].count,
|
||||
y: points[i].percentage
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var getUrlContentTypeData = function (testPlanId, chart){
|
||||
$.post( testPlanId + "/" + "urlContentTypeCount",
|
||||
{},
|
||||
function(data) {
|
||||
if (data.success) {
|
||||
addPieData(chart, data.result);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}).error(function(){
|
||||
information($.i18n.prop('failed-connect-server'));
|
||||
});;
|
||||
|
||||
}
|
||||
|
||||
var contentTypeDataFormat = function (data){
|
||||
var points = new Array();
|
||||
var sum = data[""] + data["text/html;charset=utf8"] + data["application/json;charset=UTF-8"];
|
||||
points[0] = new PiePoint("image", data[""], data[""]/sum);
|
||||
points[1] = new PiePoint("text/html", data["text/html;charset=utf8"], data["text/html;charset=utf8"]/sum);
|
||||
points[2] = new PiePoint("text/html", data["application/json;charset=UTF-8"], data["application/json;charset=UTF-8"]/sum);
|
||||
return points;
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ $(function() {
|
|||
getShowTreePathValues(tree));
|
||||
chartSelector.initChart();
|
||||
graphButtonListener(chartSelector);
|
||||
|
||||
UrlContentTypeDistribution("pie-chart", testPlanRunId);
|
||||
$("#stop-testplan").click(function() {
|
||||
if ($("#status").attr("status") == "InRunning") {
|
||||
$.post("stop/" + testPlanRunId, {}, function(data) {
|
||||
|
|
Loading…
Reference in New Issue