Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for an 'other' label in pie charts. #266

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion panels/pie/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
</div>
</div>
<div class="row-fluid">
<div class="span1">
<label class="small"> Rest </label><input type="checkbox" ng-model="panel.rest" ng-checked="panel.rest" ng-change="set_refresh(true)">
</div>
<div class="span1">
<label class="small"> Donut </label><input type="checkbox" ng-model="panel.donut" ng-checked="panel.donut">
</div>
Expand All @@ -59,4 +62,4 @@ <h5>Panel Spy</h5>
of the panel.
</div>
</div>
</div>
</div>
20 changes: 18 additions & 2 deletions panels/pie/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
** query: A string of the query to run
** goal: How many to shoot for, only does anything in goal mode
* exclude :: In terms mode, ignore these terms
* rest :: Show the rest in the pie
* donut :: Drill a big hole in the pie
* tilt :: A janky 3D representation of the pie. Looks terrible 90% of the time.
* legend :: Show the legend?
Expand All @@ -37,6 +38,7 @@ angular.module('kibana.pie', [])
query : { field:"_type", goal: 100},
size : 10,
exclude : [],
rest : false,
donut : false,
tilt : false,
legend : "above",
Expand Down Expand Up @@ -118,12 +120,18 @@ angular.module('kibana.pie', [])
$scope.hits = results.hits.total;
$scope.data = [];
var k = 0;
var sum = 0;
_.each(results.facets.pie.terms, function(v) {
var slice = { label : v.term, data : v.count };
$scope.data.push();
$scope.data.push(slice);
k = k + 1;
sum += v.count;
});
if ($scope.panel.rest && results.facets.pie.total > sum) {
var rest = { label: 'other', data : results.facets.pie.total - sum};
$scope.data.push(rest);
}
$scope.$emit('render');
});
// Goal mode
Expand Down Expand Up @@ -273,7 +281,15 @@ angular.module('kibana.pie', [])
return;
}
if(scope.panel.mode === 'terms') {
filterSrv.set({type:'terms',field:scope.panel.query.field,value:object.series.label});
var field = scope.panel.query.field;
var label = object.series.label;
if (label == 'other') {
_.each(scope.data, function(v) {
filterSrv.set({type:'terms',field:field,value:v.label,mandate:'mustNot'});
});
} else {
filterSrv.set({type:'terms',field:field,value:label});
}
dashboard.refresh();
}
});
Expand All @@ -290,4 +306,4 @@ angular.module('kibana.pie', [])

}
};
});
});