Merge pull request #1619 from deecay/count-rows

Add: use results row count as the value for the counter visualization.
This commit is contained in:
Arik Fraimovich 2017-02-28 13:03:36 +02:00 committed by GitHub
commit 20f1a60f90
2 changed files with 11 additions and 4 deletions

View File

@ -2,13 +2,13 @@
<div class="form-group">
<label class="col-lg-6">Counter Value Column Name</label>
<div class="col-lg-6">
<select ng-options="name for name in queryResult.getColumnNames()" ng-model="visualization.options.counterColName" class="form-control"></select>
<select ng-options="name for name in queryResult.getColumnNames()" ng-model="visualization.options.counterColName" class="form-control" ng-disabled="visualization.options.countRow"></select>
</div>
</div>
<div class="form-group">
<label class="col-lg-6">Counter Value Row Number</label>
<div class="col-lg-6">
<input type="number" ng-model="visualization.options.rowNumber" min="1" class="form-control">
<input type="number" ng-model="visualization.options.rowNumber" min="1" class="form-control" ng-disabled="visualization.options.countRow">
</div>
</div>
<div class="form-group">
@ -25,4 +25,10 @@
<input type="number" ng-model="visualization.options.targetRowNumber" min="1" class="form-control">
</div>
</div>
<div class="form-group">
<div class="col-lg-6">
<input type="checkbox" ng-model="visualization.options.countRow">
<i class="input-helper"></i> Count Rows
</div>
</div>
</div>

View File

@ -14,10 +14,11 @@ function CounterRenderer() {
const counterColName = $scope.visualization.options.counterColName;
const targetColName = $scope.visualization.options.targetColName;
if (counterColName) {
if ($scope.visualization.options.countRow) {
$scope.counterValue = queryData.length;
} else if (counterColName) {
$scope.counterValue = queryData[rowNumber][counterColName];
}
if (targetColName) {
$scope.targetValue = queryData[targetRowNumber][targetColName];