Commit 73dcd9e1 by Torkel Ödegaard

improvement to bar width

parent 50fd5512
...@@ -75,9 +75,6 @@ function (angular, $, kbn, moment, _) { ...@@ -75,9 +75,6 @@ function (angular, $, kbn, moment, _) {
} }
}); });
// Set barwidth based on specified interval
var barwidth = kbn.interval_to_ms(scope.interval);
var stack = panel.stack ? true : null; var stack = panel.stack ? true : null;
// Populate element // Populate element
...@@ -96,7 +93,7 @@ function (angular, $, kbn, moment, _) { ...@@ -96,7 +93,7 @@ function (angular, $, kbn, moment, _) {
bars: { bars: {
show: panel.bars, show: panel.bars,
fill: 1, fill: 1,
barWidth: barwidth/1.5, barWidth: 1,
zero: false, zero: false,
lineWidth: 0 lineWidth: 0
}, },
...@@ -128,6 +125,10 @@ function (angular, $, kbn, moment, _) { ...@@ -128,6 +125,10 @@ function (angular, $, kbn, moment, _) {
data[i].data = _d; data[i].data = _d;
} }
if (panel.bars && data.length && data[0].info.timeStep) {
options.series.bars.barWidth = data[0].info.timeStep / 1.5;
}
addTimeAxis(options); addTimeAxis(options);
addGridThresholds(options, panel); addGridThresholds(options, panel);
addAnnotations(options); addAnnotations(options);
......
...@@ -213,6 +213,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) { ...@@ -213,6 +213,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope.setDatasource = function(datasource) { $scope.setDatasource = function(datasource) {
$scope.panel.datasource = datasource; $scope.panel.datasource = datasource;
$scope.datasource = datasourceSrv.get(datasource); $scope.datasource = datasourceSrv.get(datasource);
if (!$scope.datasource) {
$scope.panel.error = "Cannot find datasource " + datasource;
return;
}
$scope.get_data(); $scope.get_data();
}; };
......
...@@ -50,7 +50,12 @@ function (_, kbn) { ...@@ -50,7 +50,12 @@ function (_, kbn) {
result.push([currentTime * 1000, currentValue]); result.push([currentTime * 1000, currentValue]);
}, this); }, this);
if (result.length > 2) {
this.info.timeStep = result[1][0] - result[0][0];
}
if (result.length) { if (result.length) {
this.info.avg = (this.info.total / result.length); this.info.avg = (this.info.total / result.length);
this.info.current = result[result.length-1][1]; this.info.current = result[result.length-1][1];
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
<button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button> <button class="btn btn-success pull-right" ng-click="add_target(panel.target)">Add query</button>
<div class="btn-group pull-right" style="margin-right: 10px;"> <div class="btn-group pull-right" style="margin-right: 10px;">
<button class="btn btn-info dropdown-toggle" data-toggle="dropdown">DS {{datasource.name}} <span class="caret"></span></button> <button class="btn btn-info dropdown-toggle" data-toggle="dropdown" bs-tooltip="'Datasource'">{{datasource.name}} <span class="caret"></span></button>
<ul class="dropdown-menu" role="menu"> <ul class="dropdown-menu" role="menu">
<li ng-repeat="datasource in datasources" role="menuitem"> <li ng-repeat="datasource in datasources" role="menuitem">
<a ng-click="setDatasource(datasource.value);">{{datasource.name}}</a> <a ng-click="setDatasource(datasource.value);">{{datasource.name}}</a>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -20,6 +20,9 @@ function (angular, _, config) { ...@@ -20,6 +20,9 @@ function (angular, _, config) {
if (!name) { return this.default; } if (!name) { return this.default; }
var ds = config.datasources[name]; var ds = config.datasources[name];
if (!ds) {
return null;
}
switch(ds.type) { switch(ds.type) {
case 'graphite': case 'graphite':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment