Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export const termsBucketAgg = new BucketAggType({
makeOrderAgg: function (termsAgg, state) {
state = state || {};
state.schema = orderAggSchema;
const orderAgg = this.aggConfigs.createAggConfig(state);
const orderAgg = termsAgg.aggConfigs.createAggConfig(state, { addToAggConfigs: false });
orderAgg.id = termsAgg.id + '-orderAgg';
return orderAgg;
},
Expand Down
5 changes: 3 additions & 2 deletions src/ui/public/agg_types/controls/order_agg.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
<option
ng-repeat="respAgg in responseValueAggs track by respAgg.id"
value="{{respAgg.id}}"
data-test-subj="visEditorOrder{{agg.id}}-{{respAgg.id}}"
ng-disabled="rejectAgg(respAgg)"
ng-selected="agg.params.orderBy === respAgg.id">
metric: {{safeMakeLabel(respAgg)}}
</option>
<option value="custom" ng-selected="agg.params.orderBy === 'custom'">
<option value="custom" data-test-subj="visEditorOrder{{agg.id}}-custom" ng-selected="agg.params.orderBy === 'custom'">
Custom Metric
</option>
<option value="_key" ng-selected="agg.params.orderBy === '_key'">
<option value="_key" data-test-subj="visEditorOrder{{agg.id}}-key" ng-selected="agg.params.orderBy === '_key'">
Alphabetical
</option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vis/agg_configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class AggConfigs extends IndexedArray {
updateAggTimeRange(param);
}
});
if (agg.type.name === 'date_histogram') {
if (_.get(agg, 'type.name') === 'date_histogram') {
agg.params.timeRange = timeRange;
}
};
Expand Down
11 changes: 11 additions & 0 deletions test/functional/apps/visualize/_vertical_bar_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ export default function ({ getService, getPageObjects }) {
const legendEntries = await PageObjects.visualize.getLegendEntries();
expect(legendEntries).to.eql(expectedEntries);
});

it('should allow custom sorting of series', async () => {
await PageObjects.visualize.toggleOpenEditor(1, 'false');
await PageObjects.visualize.selectCustomSortMetric(3, 'Min', 'bytes');
await PageObjects.visualize.clickGo();
await PageObjects.header.waitUntilLoadingHasFinished();

const expectedEntries = ['404', '200', '503'];
const legendEntries = await PageObjects.visualize.getLegendEntries();
expect(legendEntries).to.eql(expectedEntries);
});
});

describe('vertical bar with multiple splits', function () {
Expand Down
11 changes: 11 additions & 0 deletions test/functional/page_objects/visualize_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,17 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
const pieSlices = await this.getAllPieSlices(name);
return await Promise.all(pieSlices.map(async pieSlice => await pieSlice.getAttribute('style')));
}

async selectSortMetric(agg, metric) {
const sortMetric = await find.byCssSelector(`[data-test-subj="visEditorOrder${agg}-${metric}"]`);
return await sortMetric.click();
}

async selectCustomSortMetric(agg, metric, field) {
await this.selectSortMetric(agg, 'custom');
await this.selectAggregation(metric, 'groupName');
await this.selectField(field, 'groupName');
}
}

return new VisualizePage();
Expand Down