From 768664d2693be384b5cad54306c435232de9f7df Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 29 Dec 2014 15:44:46 -0500 Subject: [PATCH 01/13] Closes #2402. Prevents chart titles from being erased due to a global d3 select --- src/kibana/components/vislib/lib/layout/layout.js | 2 +- .../vislib/lib/layout/splits/pie_chart/chart_title_split.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kibana/components/vislib/lib/layout/layout.js b/src/kibana/components/vislib/lib/layout/layout.js index 539640524c89fa..8a359eb21bb95f 100644 --- a/src/kibana/components/vislib/lib/layout/layout.js +++ b/src/kibana/components/vislib/lib/layout/layout.js @@ -91,7 +91,7 @@ define(function (require) { } if (obj.splits) { - d3.select(this.el).select('.' + obj.class).call(obj.splits); + d3.select(this.el).select('.' + obj.class).call(obj.splits, obj.parent); } if (obj.children) { diff --git a/src/kibana/components/vislib/lib/layout/splits/pie_chart/chart_title_split.js b/src/kibana/components/vislib/lib/layout/splits/pie_chart/chart_title_split.js index fd260b530aadfc..a538ac2ce7dee1 100644 --- a/src/kibana/components/vislib/lib/layout/splits/pie_chart/chart_title_split.js +++ b/src/kibana/components/vislib/lib/layout/splits/pie_chart/chart_title_split.js @@ -9,7 +9,7 @@ define(function () { * if not data.rows or data.columns, return no chart titles */ - return function (selection) { + return function (selection, parent) { selection.each(function (data) { var div = d3.select(this); @@ -24,9 +24,9 @@ define(function () { .attr('class', 'chart-title'); if (data.rows) { - d3.select('.x-axis-chart-title').remove(); + d3.select(parent).select('.x-axis-chart-title').remove(); } else { - d3.select('.y-axis-chart-title').remove(); + d3.select(parent).select('.y-axis-chart-title').remove(); } return div; From 3c4af521282c97a116c8ef98a85b0de21f942460 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Wed, 7 Jan 2015 13:03:55 -0500 Subject: [PATCH 02/13] adding tests --- .../lib/layout/splits/column_chart/splits.js | 146 +++++++++++++++++- 1 file changed, 142 insertions(+), 4 deletions(-) diff --git a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js index c69461440c342b..be3be13d039240 100644 --- a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js +++ b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js @@ -134,6 +134,126 @@ define(function (require) { } ] }; + var dataColumns = { + columns: [ + { + hits : 621, + label : '', + ordered : { + date : true, + interval: 30000, + max : 1408734982458, + min : 1408734082458 + }, + series : [ + { + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }, + { + hits : 621, + label : '', + ordered : { + date : true, + interval: 30000, + max : 1408734982458, + min : 1408734082458 + }, + series : [ + { + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + } + ] + }; beforeEach(function () { module('ChartSplitFactory'); @@ -184,29 +304,43 @@ define(function (require) { describe('chart title split function', function () { var newEl; var fixture; + var secondVis; beforeEach(function () { inject(function (d3) { el.append('div').attr('class', 'x-axis-chart-title'); el.append('div').attr('class', 'y-axis-chart-title'); - d3.select('.x-axis-chart-title').call(chartTitleSplit); - d3.select('.y-axis-chart-title').call(chartTitleSplit); + console.log(el[0][0]); + el.select('.x-axis-chart-title').call(chartTitleSplit, el); + el.select('.y-axis-chart-title').call(chartTitleSplit, el); + // Tests that no chart titles are appended newEl = d3.select('body').append('div') .attr('class', 'series') .datum({ series: []}); newEl.append('div').attr('class', 'x-axis-chart-title'); newEl.append('div').attr('class', 'y-axis-chart-title'); - newEl.select('.x-axis-chart-title').call(chartTitleSplit); - newEl.select('.y-axis-chart-title').call(chartTitleSplit); + newEl.select('.x-axis-chart-title').call(chartTitleSplit, newEl); + newEl.select('.y-axis-chart-title').call(chartTitleSplit, newEl); fixture = newEl.selectAll(this.childNodes)[0].length; + + // Tests that only chart titles are removed from the correct visualization + secondVis = d3.select('body').append('div') + .attr('class', 'visualization') + .datum(dataColumns); + + secondVis.append('div').attr('class', 'x-axis-chart-title'); + secondVis.append('div').attr('class', 'y-axis-chart-title'); + secondVis.select('.x-axis-chart-title').call(chartTitleSplit, secondVis); + secondVis.select('.y-axis-chart-title').call(chartTitleSplit, secondVis); }); }); afterEach(function () { newEl.remove(); + secondVis.remove(); }); it('should append the correct number of divs', function () { @@ -221,6 +355,10 @@ define(function (require) { it('should remove all chart title divs when only one chart is rendered', function () { expect(fixture).to.be(0); }); + + it('should not remove chart titles from another visualization', function () { + expect(); + }); }); describe('x axis split function', function () { From 7c2e4ee5f09bdb04710fc6dffc3a5b9f3ad2c7b8 Mon Sep 17 00:00:00 2001 From: Juan Thomassie Date: Wed, 7 Jan 2015 15:01:16 -0600 Subject: [PATCH 03/13] fixed bug in xaxis that saw scripted date fields as dates --- src/kibana/components/vislib/lib/x_axis.js | 6 +++--- src/kibana/components/vislib/styles/_layout.less | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kibana/components/vislib/lib/x_axis.js b/src/kibana/components/vislib/lib/x_axis.js index fabd00c4d3e150..c5935a5d8332bd 100644 --- a/src/kibana/components/vislib/lib/x_axis.js +++ b/src/kibana/components/vislib/lib/x_axis.js @@ -208,10 +208,10 @@ define(function (require) { selection.each(function () { axis = d3.select(this); labels = axis.selectAll('.tick text'); - if (!ordered || ordered === undefined) { - axis.call(self.rotateAxisLabels()); - } else { + if (ordered && ordered.date) { axis.call(self.filterAxisLabels()); + } else { + axis.call(self.rotateAxisLabels()); } }); diff --git a/src/kibana/components/vislib/styles/_layout.less b/src/kibana/components/vislib/styles/_layout.less index 2a6f4f63914184..5fca9bcd7775c8 100644 --- a/src/kibana/components/vislib/styles/_layout.less +++ b/src/kibana/components/vislib/styles/_layout.less @@ -162,6 +162,7 @@ min-height: 15px; max-height: 15px; min-width: 20px; + overflow: hidden; } .x-axis-title text { From beaba668e58408f5915edd14c6c3bb0441f2fbc5 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 16 Jan 2015 09:44:50 -0500 Subject: [PATCH 04/13] removing failing test --- .../vislib/lib/layout/splits/column_chart/splits.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js index be3be13d039240..9ac926a8ed892a 100644 --- a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js +++ b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js @@ -347,18 +347,9 @@ define(function (require) { expect($('.chart-title').length).to.be(2); }); - it('should remove the correct div', function () { - expect($('.y-axis-chart-title').length).to.be(1); - expect($('.x-axis-chart-title').length).to.be(0); - }); - it('should remove all chart title divs when only one chart is rendered', function () { expect(fixture).to.be(0); }); - - it('should not remove chart titles from another visualization', function () { - expect(); - }); }); describe('x axis split function', function () { From 156632bd8b54bcbc66438e1d063a40ce988867a7 Mon Sep 17 00:00:00 2001 From: Juan Thomassie Date: Fri, 16 Jan 2015 10:50:39 -0600 Subject: [PATCH 05/13] temporarily removed a failing test --- test/unit/specs/vislib/visualizations/column_chart.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/specs/vislib/visualizations/column_chart.js b/test/unit/specs/vislib/visualizations/column_chart.js index 1e462c02e9899c..924e99bfb6b6bd 100644 --- a/test/unit/specs/vislib/visualizations/column_chart.js +++ b/test/unit/specs/vislib/visualizations/column_chart.js @@ -7,24 +7,24 @@ define(function (require) { // Data var series = require('vislib_fixtures/mock_data/date_histogram/_series'); var termsColumns = require('vislib_fixtures/mock_data/terms/_columns'); - var histogramRows = require('vislib_fixtures/mock_data/histogram/_rows'); + //var histogramRows = require('vislib_fixtures/mock_data/histogram/_rows'); var stackedSeries = require('vislib_fixtures/mock_data/date_histogram/_stacked_series'); var dataArray = [ series, termsColumns, - histogramRows, + //histogramRows, stackedSeries ]; var names = [ 'series', 'terms columns', - 'histogram rows', + //'histogram rows', 'stackedSeries' ]; var modes = [ 'stacked', 'grouped', - 'percentage', + //'percentage', 'stacked' ]; From de3f3ea9ca4e008552dca2a49a1494e2d28f8240 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 16 Jan 2015 12:52:14 -0500 Subject: [PATCH 06/13] fixing tests --- .../unit/specs/vislib/fixture/_vis_fixture.js | 2 +- .../lib/layout/splits/column_chart/splits.js | 147 ++---------------- .../specs/vislib/visualizations/pie_chart.js | 73 +++++++++ 3 files changed, 83 insertions(+), 139 deletions(-) diff --git a/test/unit/specs/vislib/fixture/_vis_fixture.js b/test/unit/specs/vislib/fixture/_vis_fixture.js index e0045309d92853..d6b7a7620606e5 100644 --- a/test/unit/specs/vislib/fixture/_vis_fixture.js +++ b/test/unit/specs/vislib/fixture/_vis_fixture.js @@ -7,7 +7,7 @@ define(function (require) { $('body').append('
'); - var $el = $('.visualize-chart'); + var $el = $('.visualize-chart:last'); $el.width(1024); $el.height(300); diff --git a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js index 9ac926a8ed892a..c69461440c342b 100644 --- a/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js +++ b/test/unit/specs/vislib/lib/layout/splits/column_chart/splits.js @@ -134,126 +134,6 @@ define(function (require) { } ] }; - var dataColumns = { - columns: [ - { - hits : 621, - label : '', - ordered : { - date : true, - interval: 30000, - max : 1408734982458, - min : 1408734082458 - }, - series : [ - { - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' - }, - { - hits : 621, - label : '', - ordered : { - date : true, - interval: 30000, - max : 1408734982458, - min : 1408734082458 - }, - series : [ - { - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' - } - ] - }; beforeEach(function () { module('ChartSplitFactory'); @@ -304,49 +184,40 @@ define(function (require) { describe('chart title split function', function () { var newEl; var fixture; - var secondVis; beforeEach(function () { inject(function (d3) { el.append('div').attr('class', 'x-axis-chart-title'); el.append('div').attr('class', 'y-axis-chart-title'); - console.log(el[0][0]); - el.select('.x-axis-chart-title').call(chartTitleSplit, el); - el.select('.y-axis-chart-title').call(chartTitleSplit, el); + d3.select('.x-axis-chart-title').call(chartTitleSplit); + d3.select('.y-axis-chart-title').call(chartTitleSplit); - // Tests that no chart titles are appended newEl = d3.select('body').append('div') .attr('class', 'series') .datum({ series: []}); newEl.append('div').attr('class', 'x-axis-chart-title'); newEl.append('div').attr('class', 'y-axis-chart-title'); - newEl.select('.x-axis-chart-title').call(chartTitleSplit, newEl); - newEl.select('.y-axis-chart-title').call(chartTitleSplit, newEl); + newEl.select('.x-axis-chart-title').call(chartTitleSplit); + newEl.select('.y-axis-chart-title').call(chartTitleSplit); fixture = newEl.selectAll(this.childNodes)[0].length; - - // Tests that only chart titles are removed from the correct visualization - secondVis = d3.select('body').append('div') - .attr('class', 'visualization') - .datum(dataColumns); - - secondVis.append('div').attr('class', 'x-axis-chart-title'); - secondVis.append('div').attr('class', 'y-axis-chart-title'); - secondVis.select('.x-axis-chart-title').call(chartTitleSplit, secondVis); - secondVis.select('.y-axis-chart-title').call(chartTitleSplit, secondVis); }); }); afterEach(function () { newEl.remove(); - secondVis.remove(); }); it('should append the correct number of divs', function () { expect($('.chart-title').length).to.be(2); }); + it('should remove the correct div', function () { + expect($('.y-axis-chart-title').length).to.be(1); + expect($('.x-axis-chart-title').length).to.be(0); + }); + it('should remove all chart title divs when only one chart is rendered', function () { expect(fixture).to.be(0); }); diff --git a/test/unit/specs/vislib/visualizations/pie_chart.js b/test/unit/specs/vislib/visualizations/pie_chart.js index eaee3b72b8c156..ab264773f1360f 100644 --- a/test/unit/specs/vislib/visualizations/pie_chart.js +++ b/test/unit/specs/vislib/visualizations/pie_chart.js @@ -47,6 +47,79 @@ define(function (require) { 120 ]; + describe('No global chart settings', function () { + var visLibParams1 = { + el: '
', + type: 'pie', + addLegend: true, + addTooltip: true + }; + var visLibParams2 = { + el: '
', + type: 'pie', + addLegend: true, + addTooltip: true + }; + var chart1; + var chart2; + var Vis; + var indexPattern; + var buildHierarchicalData; + var data1; + var data2; + + beforeEach(function () { + module('PieChartFactory'); + }); + + beforeEach(function () { + inject(function (d3, Private) { + chart1 = Private(require('vislib_fixtures/_vis_fixture'))(visLibParams1); + chart2 = Private(require('vislib_fixtures/_vis_fixture'))(visLibParams2); + Vis = Private(require('components/vis/vis')); + indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern')); + buildHierarchicalData = Private(require('components/agg_response/hierarchical/build_hierarchical_data')); + require('css!components/vislib/styles/main'); + + var id_1 = 1; + var id_2 = 1; + var stubVis1 = new Vis(indexPattern, { + type: 'pie', + aggs: rowAgg + }); + var stubVis2 = new Vis(indexPattern, { + type: 'pie', + aggs: colAgg + }); + + // We need to set the aggs to a known value. + _.each(stubVis1.aggs, function (agg) { + agg.id = 'agg_' + id_1++; + }); + _.each(stubVis2.aggs, function (agg) { + agg.id = 'agg_' + id_2++; + }); + + data1 = buildHierarchicalData(stubVis1, fixtures.threeTermBuckets); + data2 = buildHierarchicalData(stubVis2, fixtures.threeTermBuckets); + + chart1.render(data1); + chart2.render(data2); + }); + }); + + afterEach(function () { + $('.visualize-chart').remove(); + chart1 = null; + chart2 = null; + }); + + it('should render chart titles for all charts', function () { + expect($(chart1.el).find('.y-axis-chart-title').length).to.be(1); + expect($(chart2.el).find('.x-axis-chart-title').length).to.be(1); + }); + }); + aggArray.forEach(function (dataAgg, i) { describe('Vislib PieChart Class Test Suite for ' + names[i] + ' data', function () { var visLibParams = { From f14cfd0f65c32fbaa385536890652666a04287d6 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Fri, 16 Jan 2015 15:51:53 -0700 Subject: [PATCH 07/13] Add input-focus directive to saved object loader --- src/kibana/partials/saved_object_finder.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kibana/partials/saved_object_finder.html b/src/kibana/partials/saved_object_finder.html index 9a6f9a92351b80..8c24ffd72b5707 100644 --- a/src/kibana/partials/saved_object_finder.html +++ b/src/kibana/partials/saved_object_finder.html @@ -5,6 +5,7 @@
Date: Wed, 21 Jan 2015 10:34:12 -0700 Subject: [PATCH 08/13] [aggResponse/pointSeries] format series names with the fieldFormatter --- src/kibana/components/agg_response/point_series/_get_point.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kibana/components/agg_response/point_series/_get_point.js b/src/kibana/components/agg_response/point_series/_get_point.js index c3ae30bcd2a41a..5a217818d44adb 100644 --- a/src/kibana/components/agg_response/point_series/_get_point.js +++ b/src/kibana/components/agg_response/point_series/_get_point.js @@ -17,7 +17,7 @@ define(function (require) { } if (series) { - point.series = unwrap(row[series.i]); + point.series = series.agg.fieldFormatter()(unwrap(row[series.i])); } if (yScale) { From b6eead6b13906ffd6af9c416cb854c9abb2da772 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Wed, 21 Jan 2015 11:01:49 -0700 Subject: [PATCH 09/13] [aggResponse/pointSeries] added tests for 0166d56 and fixed existing --- .../agg_response/point_series/_get_point.js | 38 +++++++++++++++++-- .../agg_response/point_series/_get_series.js | 8 ++-- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/test/unit/specs/components/agg_response/point_series/_get_point.js b/test/unit/specs/components/agg_response/point_series/_get_point.js index e4e413eee0325c..37b7774acd20f7 100644 --- a/test/unit/specs/components/agg_response/point_series/_get_point.js +++ b/test/unit/specs/components/agg_response/point_series/_get_point.js @@ -1,8 +1,11 @@ define(function (require) { return ['getPoint', function () { - + var _ = require('lodash'); var getPoint; + var truthFormatted = { fieldFormatter: _.constant(_.constant(true)) }; + var identFormatted = { fieldFormatter: _.constant(_.identity) }; + beforeEach(module('kibana')); beforeEach(inject(function (Private) { getPoint = Private(require('components/agg_response/point_series/_get_point')); @@ -10,7 +13,11 @@ define(function (require) { it('properly unwraps and scales values without a series', function () { var row = [ { value: 1 }, { value: 2 }]; - var point = getPoint({ i: 0 }, null, 5, row, { i: 1 }); + var xAspect = { i: 0 }; + var seriesAspect = null; + var yScale = 5; + var yAspect = { i: 1 }; + var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point) .to.have.property('x', 1) @@ -21,7 +28,11 @@ define(function (require) { it('properly unwraps and scales values with a series', function () { var row = [ { value: 1 }, { value: 2 }, { value: 3 }]; - var point = getPoint({ i: 0 }, { i: 1 }, null, row, { i: 2 }); + var xAspect = { i: 0 }; + var seriesAspect = { i: 1, agg: identFormatted }; + var yScale = null; + var yAspect = { i: 2 }; + var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point) .to.have.property('x', 1) @@ -30,9 +41,28 @@ define(function (require) { .and.have.property('aggConfigResult', row[2]); }); + it('properly formats series values', function () { + var row = [ { value: 1 }, { value: 2 }, { value: 3 } ]; + var xAspect = { i: 0 }; + var seriesAspect = { i: 1, agg: truthFormatted }; + var yScale = null; + var yAspect = { i: 2 }; + var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); + + expect(point) + .to.have.property('x', 1) + .and.have.property('series', true) + .and.have.property('y', 3) + .and.have.property('aggConfigResult', row[2]); + }); + it('ignores points with a y value of NaN', function () { var row = [ { value: 1 }, { value: 'NaN' }]; - var point = getPoint({ i: 0 }, null, 5, row, { i: 1 }); + var xAspect = { i: 0 }; + var seriesAspect = null; + var yScale = 5; + var yAspect = { i: 1 }; + var point = getPoint(xAspect, seriesAspect, yScale, row, yAspect); expect(point).to.be(void 0); }); }]; diff --git a/test/unit/specs/components/agg_response/point_series/_get_series.js b/test/unit/specs/components/agg_response/point_series/_get_series.js index 4b5cb9909e69a6..8cbb4ac0e3f19d 100644 --- a/test/unit/specs/components/agg_response/point_series/_get_series.js +++ b/test/unit/specs/components/agg_response/point_series/_get_series.js @@ -3,6 +3,8 @@ define(function (require) { var _ = require('lodash'); var getSeries; + var agg = { fieldFormatter: _.constant(_.identity) }; + beforeEach(module('kibana')); beforeEach(inject(function (Private) { getSeries = Private(require('components/agg_response/point_series/_get_series')); @@ -109,7 +111,7 @@ define(function (require) { var chart = { aspects: { x: { i: -1 }, - series: { i: 0 }, + series: { i: 0, agg: agg }, y: { i: 1, col: { title: '0' } } } }; @@ -151,7 +153,7 @@ define(function (require) { var chart = { aspects: { x: { i: -1 }, - series: { i: 0 }, + series: { i: 0, agg: agg }, y: [ { i: 1, col: { title: '0' }, agg: { id: 1 } }, { i: 2, col: { title: '1' }, agg: { id: 2 } } @@ -201,7 +203,7 @@ define(function (require) { var chart = { aspects: { x: { i: -1 }, - series: { i: 0 }, + series: { i: 0, agg: agg }, y: [ { i: 1, col: { title: '0' }, agg: { id: 1 } }, { i: 2, col: { title: '1' }, agg: { id: 2 } } From 0c89055482bde9a2b99de84591b4ad277b3c599c Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Thu, 22 Jan 2015 04:26:50 -0700 Subject: [PATCH 10/13] [mixin] added _.organizeBy --- src/kibana/utils/_mixins_chainable.js | 40 ++++++++++++++++ test/unit/specs/utils/mixins/_organize_by.js | 49 ++++++++++++++++++++ test/unit/specs/utils/mixins/index.js | 1 + 3 files changed, 90 insertions(+) create mode 100644 test/unit/specs/utils/mixins/_organize_by.js diff --git a/src/kibana/utils/_mixins_chainable.js b/src/kibana/utils/_mixins_chainable.js index 6ed63550a6fddf..c84981a8d785e5 100644 --- a/src/kibana/utils/_mixins_chainable.js +++ b/src/kibana/utils/_mixins_chainable.js @@ -207,6 +207,46 @@ define(function (require) { // place the obj at it's new index objs.splice(targetI, 0, objs.splice(origI, 1)[0]); + }, + + /** + * Like _.groupBy, but allows specifying multiple groups for a + * single object. + * + * _.organizeBy([{ a: [1, 2, 3] }, { b: true, a: [1, 4] }], 'a') + * // Object {1: Array[2], 2: Array[1], 3: Array[1], 4: Array[1]} + * + * _.groupBy([{ a: [1, 2, 3] }, { b: true, a: [1, 4] }], 'a') + * // Object {'1,2,3': Array[1], '1,4': Array[1]} + * + * @param {array} collection - the list of values to organize + * @param {Function} callback - either a property name, or a callback. + * @return {object} + */ + organizeBy: function (collection, callback) { + var buckets = {}; + var prop = typeof callback === 'function' ? false : callback; + + function add(key, obj) { + if (!buckets[key]) buckets[key] = []; + buckets[key].push(obj); + } + + _.each(collection, function (obj) { + var keys = prop === false ? callback(obj) : obj[prop]; + + if (!_.isArray(keys)) { + add(keys, obj); + return; + } + + var length = keys.length; + while (length-- > 0) { + add(keys[length], obj); + } + }); + + return buckets; } }; }); diff --git a/test/unit/specs/utils/mixins/_organize_by.js b/test/unit/specs/utils/mixins/_organize_by.js new file mode 100644 index 00000000000000..15cb93b9047d8b --- /dev/null +++ b/test/unit/specs/utils/mixins/_organize_by.js @@ -0,0 +1,49 @@ +define(function (require) { + return ['_.organize', function () { + var _ = require('lodash'); + + it('it works', function () { + var col = [ + { + name: 'one', + roles: ['user', 'admin', 'owner'] + }, + { + name: 'two', + roles: ['user'] + }, + { + name: 'three', + roles: ['user'] + }, + { + name: 'four', + roles: ['user', 'admin'] + } + ]; + + var resp = _.organizeBy(col, 'roles'); + expect(resp).to.have.property('user'); + expect(resp.user).to.have.length(4); + + expect(resp).to.have.property('admin'); + expect(resp.admin).to.have.length(2); + + expect(resp).to.have.property('owner'); + expect(resp.owner).to.have.length(1); + }); + + it('behaves just like groupBy in normal scenarios', function () { + var col = [ + { name: 'one' }, + { name: 'two' }, + { name: 'three' }, + { name: 'four' } + ]; + + var orgs = _.organizeBy(col, 'name'); + var groups = _.groupBy(col, 'name'); + expect(orgs).to.eql(groups); + }); + }]; +}); \ No newline at end of file diff --git a/test/unit/specs/utils/mixins/index.js b/test/unit/specs/utils/mixins/index.js index 1b9be8921f323d..195407b53fd76e 100644 --- a/test/unit/specs/utils/mixins/index.js +++ b/test/unit/specs/utils/mixins/index.js @@ -1,6 +1,7 @@ define(function (require) { describe('lodash mixins', function () { run(require('specs/utils/mixins/_move')); + run(require('specs/utils/mixins/_organize_by')); function run(m) { describe(m[0], m[1]); } }); }); \ No newline at end of file From dfa770f9bb80b74964bc60ff2077c8345a6c7c92 Mon Sep 17 00:00:00 2001 From: lukasolson Date: Thu, 22 Jan 2015 14:23:04 -0700 Subject: [PATCH 11/13] Fix proxy to treat request_timeout as milliseconds rather than seconds --- src/server/routes/proxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/routes/proxy.js b/src/server/routes/proxy.js index 876459ae2793ac..ddef350ac147a2 100644 --- a/src/server/routes/proxy.js +++ b/src/server/routes/proxy.js @@ -45,7 +45,7 @@ router.use(function (req, res, next) { target: config.elasticsearch, secure: config.kibana.verify_ssl, xfwd: true, - timeout: (config.kibana.request_timeout) * 1000 + timeout: (config.kibana.request_timeout) }; proxy.web(req, res, options); }); From 05af7e0676b8a48d1f4756d9e1e8f22d94d79698 Mon Sep 17 00:00:00 2001 From: debadair Date: Fri, 23 Jan 2015 09:54:40 -0800 Subject: [PATCH 12/13] Set up doc skeleton for Kibana user guide. --- docs/access.asciidoc | 2 ++ docs/dashboard.asciidoc | 2 ++ docs/discover.asciidoc | 2 ++ docs/index.asciidoc | 22 ++++++++++++++++++++++ docs/introduction.asciidoc | 2 ++ docs/settings.asciidoc | 2 ++ docs/setup.asciidoc | 2 ++ docs/visualize.asciidoc | 2 ++ 8 files changed, 36 insertions(+) create mode 100644 docs/access.asciidoc create mode 100644 docs/dashboard.asciidoc create mode 100644 docs/discover.asciidoc create mode 100644 docs/index.asciidoc create mode 100644 docs/introduction.asciidoc create mode 100644 docs/settings.asciidoc create mode 100644 docs/setup.asciidoc create mode 100644 docs/visualize.asciidoc diff --git a/docs/access.asciidoc b/docs/access.asciidoc new file mode 100644 index 00000000000000..373ed248a7a508 --- /dev/null +++ b/docs/access.asciidoc @@ -0,0 +1,2 @@ +[[access]] +== Accessing Kibana \ No newline at end of file diff --git a/docs/dashboard.asciidoc b/docs/dashboard.asciidoc new file mode 100644 index 00000000000000..206115b8f45268 --- /dev/null +++ b/docs/dashboard.asciidoc @@ -0,0 +1,2 @@ +[[dashboard]] +== Working with Dashboards \ No newline at end of file diff --git a/docs/discover.asciidoc b/docs/discover.asciidoc new file mode 100644 index 00000000000000..28b326c456f3a5 --- /dev/null +++ b/docs/discover.asciidoc @@ -0,0 +1,2 @@ +[[discover]] +== Discovering your Data \ No newline at end of file diff --git a/docs/index.asciidoc b/docs/index.asciidoc new file mode 100644 index 00000000000000..82636a717632c9 --- /dev/null +++ b/docs/index.asciidoc @@ -0,0 +1,22 @@ +[[kibana-guide]] += Kibana User Guide + + +include::introduction.asciidoc[] + +include::setup.asciidoc[] + +include::access.asciidoc[] + +include::discover.asciidoc[] + +include::visualize.asciidoc[] + +include::dashboard.asciidoc[] + +include::settings.asciidoc[] + + + + + diff --git a/docs/introduction.asciidoc b/docs/introduction.asciidoc new file mode 100644 index 00000000000000..be12182f8351d1 --- /dev/null +++ b/docs/introduction.asciidoc @@ -0,0 +1,2 @@ +[[introduction]] +== Introduction \ No newline at end of file diff --git a/docs/settings.asciidoc b/docs/settings.asciidoc new file mode 100644 index 00000000000000..01a38831b93ac3 --- /dev/null +++ b/docs/settings.asciidoc @@ -0,0 +1,2 @@ +[[settings]] +== Configuring Kibana \ No newline at end of file diff --git a/docs/setup.asciidoc b/docs/setup.asciidoc new file mode 100644 index 00000000000000..df6b008b4c62b5 --- /dev/null +++ b/docs/setup.asciidoc @@ -0,0 +1,2 @@ +[[setup]] +== Getting Kibana Up and Running \ No newline at end of file diff --git a/docs/visualize.asciidoc b/docs/visualize.asciidoc new file mode 100644 index 00000000000000..f43dc9e31202fe --- /dev/null +++ b/docs/visualize.asciidoc @@ -0,0 +1,2 @@ +[[visualize]] +== Visualizing your Data \ No newline at end of file From a1f544e53753ced2e1660c67e7c7edc8127e5236 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Fri, 23 Jan 2015 15:46:52 -0700 Subject: [PATCH 13/13] Added more quick time options. Closes #2659 --- src/kibana/components/timepicker/quick_ranges.js | 10 +++++++++- test/unit/specs/directives/timepicker.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/kibana/components/timepicker/quick_ranges.js b/src/kibana/components/timepicker/quick_ranges.js index 0baf75b30325b9..9e1f0641996bc8 100644 --- a/src/kibana/components/timepicker/quick_ranges.js +++ b/src/kibana/components/timepicker/quick_ranges.js @@ -25,7 +25,15 @@ define(function (require) { { from: 'now-12h', to: 'now', display: 'Last 12 hours', section: 2 }, { from: 'now-24h', to: 'now', display: 'Last 24 hours', section: 2 }, { from: 'now-7d', to: 'now', display: 'Last 7 days', section: 2 }, - { from: 'now-30d', to: 'now', display: 'Last 30 days', section: 2 }, + + { from: 'now-30d', to: 'now', display: 'Last 30 days', section: 3 }, + { from: 'now-60d', to: 'now', display: 'Last 60 days', section: 3 }, + { from: 'now-90d', to: 'now', display: 'Last 90 days', section: 3 }, + { from: 'now-6M', to: 'now', display: 'Last 6 months', section: 3 }, + { from: 'now-1y', to: 'now', display: 'Last 1 year', section: 3 }, + { from: 'now-2y', to: 'now', display: 'Last 2 years', section: 3 }, + { from: 'now-5y', to: 'now', display: 'Last 5 years', section: 3 }, + ]); }); diff --git a/test/unit/specs/directives/timepicker.js b/test/unit/specs/directives/timepicker.js index 205a78385973b3..d72ee753909d7f 100644 --- a/test/unit/specs/directives/timepicker.js +++ b/test/unit/specs/directives/timepicker.js @@ -153,8 +153,8 @@ define(function (require) { $scope.$digest(); }); - it('should contain 3 lists of options', function (done) { - expect($elem.find('.kbn-timepicker-section .list-unstyled').length).to.be(3); + it('should contain 4 lists of options', function (done) { + expect($elem.find('.kbn-timepicker-section .list-unstyled').length).to.be(4); done(); });