mirror of
https://github.com/timberjoegithub/grafana-statusmap.git
synced 2026-07-22 15:53:09 +00:00
Sort options for Y axis
- sort as on metrics tab - ascending and descending natural sort (1-2-10)
This commit is contained in:
Vendored
+1
@@ -146,6 +146,7 @@ This plugin is based on "Heatmap" panel by Grafana and partly inspired by ideas
|
||||
|
||||
##### v0.0.3
|
||||
|
||||
- Add simple sort options for Y axis
|
||||
- Fix display null values as zero
|
||||
|
||||
##### v0.0.2
|
||||
|
||||
Vendored
+10
-1
@@ -118,7 +118,16 @@
|
||||
label="Show tooltip"
|
||||
checked="ctrl.panel.tooltip.show" on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-8">Y axis sort</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input max-width-8"
|
||||
ng-model="ctrl.panel.yAxisSort"
|
||||
ng-options="f for f in ['metrics', 'a → z', 'z → a']"
|
||||
ng-change="ctrl.render()"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">Bucket</h5>
|
||||
|
||||
Vendored
+16
-4
@@ -121,9 +121,10 @@ System.register(['lodash', 'jquery', 'moment', 'app/core/utils/kbn', 'app/core/c
|
||||
function getYScale(ticks) {
|
||||
var range = [];
|
||||
var step = chartHeight / ticks.length;
|
||||
range.push(chartHeight);
|
||||
// svg has y=0 on the top, so top card should have a minimal value in range
|
||||
range.push(step);
|
||||
for (var i = 1; i < ticks.length; i++) {
|
||||
range.push(chartHeight - step * i);
|
||||
range.push(step * (i + 1));
|
||||
}
|
||||
return d3.scaleOrdinal().domain(ticks).range(range);
|
||||
}
|
||||
@@ -132,9 +133,10 @@ System.register(['lodash', 'jquery', 'moment', 'app/core/utils/kbn', 'app/core/c
|
||||
function getYAxisScale(ticks) {
|
||||
var range = [];
|
||||
var step = chartHeight / ticks.length;
|
||||
range.push(chartHeight - yOffset);
|
||||
// svg has y=0 on the top, so top tick should have a minimal value in range
|
||||
range.push(yOffset);
|
||||
for (var i = 1; i < ticks.length; i++) {
|
||||
range.push(chartHeight - step * i - yOffset);
|
||||
range.push(step * i + yOffset);
|
||||
}
|
||||
return d3.scaleOrdinal().domain(ticks).range(range);
|
||||
}
|
||||
@@ -149,6 +151,16 @@ System.register(['lodash', 'jquery', 'moment', 'app/core/utils/kbn', 'app/core/c
|
||||
ticks = [''];
|
||||
}
|
||||
|
||||
if (panel.yAxisSort == 'a → z') {
|
||||
ticks.sort(function (a, b) {
|
||||
return a.localeCompare(b, 'en', { ignorePunctuation: false, numeric: true });
|
||||
});
|
||||
} else if (panel.yAxisSort == 'z → a') {
|
||||
ticks.sort(function (b, a) {
|
||||
return a.localeCompare(b, 'en', { ignorePunctuation: false, numeric: true });
|
||||
});
|
||||
}
|
||||
|
||||
var yAxisScale = getYAxisScale(ticks);
|
||||
scope.yScale = yScale = getYScale(ticks);
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -97,6 +97,7 @@ System.register(['app/plugins/sdk', 'lodash', 'app/core/core', 'app/core/utils/k
|
||||
},
|
||||
// how null points should be handled
|
||||
nullPointMode: 'as empty',
|
||||
yAxisSort: 'metrics',
|
||||
highlightCards: true,
|
||||
useMax: true
|
||||
};
|
||||
@@ -263,7 +264,6 @@ System.register(['app/plugins/sdk', 'lodash', 'app/core/core', 'app/core/utils/k
|
||||
|
||||
// TODO add some logic for targets heirarchy
|
||||
cardsData.targets = _.keys(cardsData.targetIndex);
|
||||
cardsData.targets.sort();
|
||||
cardsData.yBucketSize = cardsData.targets.length;
|
||||
cardsData.xBucketSize = _.min(_.map(data, function (d) {
|
||||
return d.datapoints.length;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user