From eabb3b5c86f3c85190f5ee1c61705eb1e30d053c Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 7 Nov 2014 02:34:23 +0200 Subject: [PATCH 1/8] Closes #1821. Displays a y axis max value based on the data displayed in the chart --- src/kibana/components/vislib/lib/data.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/kibana/components/vislib/lib/data.js b/src/kibana/components/vislib/lib/data.js index ad588924736d..fdec0dfb62d3 100644 --- a/src/kibana/components/vislib/lib/data.js +++ b/src/kibana/components/vislib/lib/data.js @@ -261,8 +261,16 @@ define(function (require) { * @returns {Number} Y stack max value */ Data.prototype.getYStackMax = function (series) { + var isOrdered = (this.data.ordered && this.data.ordered.date); + var minDate = isOrdered ? this.data.ordered.min : undefined; + var maxDate = isOrdered ? this.data.ordered.max : undefined; + return d3.max(this.stackData(series), function (data) { return d3.max(data, function (d) { + if (isOrdered) { + return (d.x >= minDate && d.x <= maxDate) ? d.y0 + d.y : undefined; + } + return d.y0 + d.y; }); }); @@ -276,8 +284,16 @@ define(function (require) { * @returns {Number} Y domain max value */ Data.prototype.getYMax = function (series) { + var isOrdered = (this.data.ordered && this.data.ordered.date); + var minDate = isOrdered ? this.data.ordered.min : undefined; + var maxDate = isOrdered ? this.data.ordered.max : undefined; + return d3.max(series, function (data) { return d3.max(data, function (d) { + if (isOrdered) { + return (d.x >= minDate && d.x <= maxDate) ? d.y : undefined; + } + return d.y; }); }); From fc86dde11022db4625ead7b7eadd848dea647639 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Sat, 22 Nov 2014 02:54:20 +0200 Subject: [PATCH 2/8] Closes issue #1707. Adds brushing capability for both time series and nominal scales to the area, line, and vertical bar charts. --- src/kibana/components/vislib/lib/dispatch.js | 16 ++++++++++++++-- .../vislib/visualizations/area_chart.js | 17 ++++++++++++----- .../vislib/visualizations/line_chart.js | 17 ++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/kibana/components/vislib/lib/dispatch.js b/src/kibana/components/vislib/lib/dispatch.js index e394fb8f9902..c665d0ca6eb2 100644 --- a/src/kibana/components/vislib/lib/dispatch.js +++ b/src/kibana/components/vislib/lib/dispatch.js @@ -190,11 +190,23 @@ define(function (require) { var brush = d3.svg.brush() .x(xScale) .on('brushend', function brushEnd() { + + // Assumes data is selected at the chart level + // In this case, the number of data objects should always be 1 + var data = d3.select(this).data()[0]; + var isTimeSeries = (data.ordered && data.ordered.date); + + // Allows for brushing on d3.scale.ordinal() + var selected = xScale.domain().filter(function (d) { + return (brush.extent()[0] <= xScale(d)) && (xScale(d) <= brush.extent()[1]); + }); + var range = isTimeSeries ? brush.extent() : selected; + return dispatch.brush({ - range: brush.extent(), + range: range, config: attr, e: d3.event, - data: d3.event.sourceEvent.target.__data__ + data: data }); }); diff --git a/src/kibana/components/vislib/visualizations/area_chart.js b/src/kibana/components/vislib/visualizations/area_chart.js index b6c1964baf6f..fb7c3ee2e32a 100644 --- a/src/kibana/components/vislib/visualizations/area_chart.js +++ b/src/kibana/components/vislib/visualizations/area_chart.js @@ -139,12 +139,19 @@ define(function (require) { * @param element {D3.UpdateSelection} SVG circles * @returns {D3.Selection} circles with event listeners attached */ - AreaChart.prototype.addCircleEvents = function (element) { + AreaChart.prototype.addCircleEvents = function (element, svg) { var events = this.events; + var isBrushable = (typeof events.dispatch.on('brush') === 'function'); + var brush = isBrushable ? events.addBrushEvent(svg) : undefined; + var hover = events.addHoverEvent(); + var click = events.addClickEvent(); + var attachedEvents = element.call(hover).call(click); + + if (isBrushable) { + attachedEvents.call(brush); + } - return element - .call(events.addHoverEvent()) - .call(events.addClickEvent()); + return attachedEvents; }; /** @@ -310,7 +317,7 @@ define(function (require) { circles = self.addCircles(svg, layers); // add click and hover events to circles - self.addCircleEvents(circles); + self.addCircleEvents(circles, svg); // chart base line var line = svg.append('line') diff --git a/src/kibana/components/vislib/visualizations/line_chart.js b/src/kibana/components/vislib/visualizations/line_chart.js index 229eaccca753..311174df9952 100644 --- a/src/kibana/components/vislib/visualizations/line_chart.js +++ b/src/kibana/components/vislib/visualizations/line_chart.js @@ -39,12 +39,19 @@ define(function (require) { * @param element{D3.UpdateSelection} Reference to SVG circle * @returns {D3.Selection} SVG circles with event listeners attached */ - LineChart.prototype.addCircleEvents = function (element) { + LineChart.prototype.addCircleEvents = function (element, svg) { var events = this.events; + var isBrushable = (typeof events.dispatch.on('brush') === 'function'); + var brush = isBrushable ? events.addBrushEvent(svg) : undefined; + var hover = events.addHoverEvent(); + var click = events.addClickEvent(); + var attachedEvents = element.call(hover).call(click); - return element - .call(events.addHoverEvent()) - .call(events.addClickEvent()); + if (isBrushable) { + attachedEvents.call(brush); + } + + return attachedEvents; }; /** @@ -255,7 +262,7 @@ define(function (require) { self.addClipPath(svg, width, height); lines = self.addLines(svg, data.series); circles = self.addCircles(svg, layers); - self.addCircleEvents(circles); + self.addCircleEvents(circles, svg); var line = svg .append('line') From 0d0a3138f3637f8edc52b476e210ed1f3e7eaf0f Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 24 Nov 2014 10:38:47 -0700 Subject: [PATCH 3/8] [jshint] updated jshint paths, fixing some linting errors --- src/kibana/plugins/discover/controllers/discover.js | 3 ++- src/kibana/plugins/vis_types/vislib/tile_map.js | 2 +- tasks/config/jshint.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kibana/plugins/discover/controllers/discover.js b/src/kibana/plugins/discover/controllers/discover.js index 022389a8e709..2d2166732dbc 100644 --- a/src/kibana/plugins/discover/controllers/discover.js +++ b/src/kibana/plugins/discover/controllers/discover.js @@ -47,7 +47,8 @@ define(function (require) { } }); - app.controller('discover', function ($scope, config, courier, $route, $window, Notifier, AppState, timefilter, Promise, Private, kbnUrl, highlightTags) { + app.controller('discover', function ($scope, config, courier, $route, $window, Notifier, + AppState, timefilter, Promise, Private, kbnUrl, highlightTags) { var Vis = Private(require('components/vis/vis')); var docTitle = Private(require('components/doc_title/doc_title')); diff --git a/src/kibana/plugins/vis_types/vislib/tile_map.js b/src/kibana/plugins/vis_types/vislib/tile_map.js index aa6e189869ad..b959dc53e5d1 100644 --- a/src/kibana/plugins/vis_types/vislib/tile_map.js +++ b/src/kibana/plugins/vis_types/vislib/tile_map.js @@ -8,7 +8,7 @@ define(function (require) { name: 'tile_map', title: 'Tile map', icon: 'fa-map-marker', - params: { + params: { defaults: { mapType: 'Shaded Circle Markers' }, diff --git a/tasks/config/jshint.js b/tasks/config/jshint.js index 80506b801555..062b86553f5d 100644 --- a/tasks/config/jshint.js +++ b/tasks/config/jshint.js @@ -7,7 +7,7 @@ module.exports = function (grunt) { 'Gruntfile.js', '<%= root %>/tasks/**/*.js', '<%= src %>/kibana/*.js', - '<%= src %>/kibana/{apps,components,controllers,directives,factories,filters,services,utils}/**/*.js', + '<%= src %>/kibana/{components,directives,factories,filters,plugins,registry,services,utils}/**/*.js', '<%= unitTestDir %>/**/*.js' ] } From 39f750fa6cd5c3a9befcdc5b823722c742f6d423 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 24 Nov 2014 10:43:20 -0700 Subject: [PATCH 4/8] [discover] Cannot read property 'query' of undefined --- .../plugins/discover/controllers/discover.js | 60 ++++++++++++------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/src/kibana/plugins/discover/controllers/discover.js b/src/kibana/plugins/discover/controllers/discover.js index 2d2166732dbc..1fe38967e050 100644 --- a/src/kibana/plugins/discover/controllers/discover.js +++ b/src/kibana/plugins/discover/controllers/discover.js @@ -523,8 +523,8 @@ define(function (require) { } // TODO: On array fields, negating does not negate the combination, rather all terms - $scope.filterQuery = function (field, value, operation) { - value = _.isArray(value) ? value : [value]; + $scope.filterQuery = function (field, values, operation) { + values = _.isArray(values) ? values : [values]; var indexPattern = $scope.searchSource.get('index'); indexPattern.popularizeField(field, 1); @@ -532,28 +532,46 @@ define(function (require) { // Grap the filters from the searchSource and ensure it's an array var filters = _.flatten([$state.filters], true); - _.each(value, function (clause) { - var previous = _.find(filters, function (item) { - if (item && item.query) { - return item.query.match[field].query === clause; - } else if (item && item.exists && field === '_exists_') { - return item.exists.field === clause; - } else if (item && item.missing && field === '_missing_') { - return item.missing.field === clause; + _.each(values, function (value) { + var existing = _.find(filters, function (filter) { + if (!filter) return; + + if (field === '_exists_' && filter.exists) { + return filter.exists.field === value; } - }); - if (!previous) { - var filter; - if (field === '_exists_') { - filter = { exists: { field: clause } }; - } else if (field === '_missing_') { - filter = { missing: { field: clause } }; - } else { - filter = { query: { match: {} } }; - filter.negate = operation === '-'; - filter.query.match[field] = { query: clause, type: 'phrase' }; + + if (field === '_missing_' && filter.missing) { + return filter.missing.field === value; } + + if (filter.query) { + return filter.query.match[field] && filter.query.match[field].query === value; + } + }); + + if (existing) return; + + switch (field) { + case '_exists_': + filters.push({ + exists: { + field: value + } + }); + break; + case '_missing_': + filters.push({ + missing: { + field: value + } + }); + break; + default: + var filter = { query: { match: {} } }; + filter.negate = operation === '-'; + filter.query.match[field] = { query: value, type: 'phrase' }; filters.push(filter); + break; } }); From af6e448df9ae32a5af408fa3e30c6ea38581c352 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Mon, 24 Nov 2014 20:31:36 +0200 Subject: [PATCH 5/8] adding tests --- .../vislib/fixture/mock_data/series/_data0.js | 2 +- .../fixture/mock_data/stacked/_stacked.js | 1574 +++++++++++++++++ test/unit/specs/vislib/lib/data.js | 47 + 3 files changed, 1622 insertions(+), 1 deletion(-) create mode 100644 test/unit/specs/vislib/fixture/mock_data/stacked/_stacked.js diff --git a/test/unit/specs/vislib/fixture/mock_data/series/_data0.js b/test/unit/specs/vislib/fixture/mock_data/series/_data0.js index d19981be0c21..a38e0d434e4d 100644 --- a/test/unit/specs/vislib/fixture/mock_data/series/_data0.js +++ b/test/unit/specs/vislib/fixture/mock_data/series/_data0.js @@ -16,7 +16,7 @@ define(function (require) { 'values': [ { 'x': 1411761450000, - 'y': 21 + 'y': 41 }, { 'x': 1411761480000, diff --git a/test/unit/specs/vislib/fixture/mock_data/stacked/_stacked.js b/test/unit/specs/vislib/fixture/mock_data/stacked/_stacked.js new file mode 100644 index 000000000000..7def3fcb21c7 --- /dev/null +++ b/test/unit/specs/vislib/fixture/mock_data/stacked/_stacked.js @@ -0,0 +1,1574 @@ +define(function (require) { + var moment = require('moment'); + + return { + 'label': '', + 'xAxisLabel': '@timestamp per 30 sec', + 'ordered': { + 'date': true, + 'interval': 30000, + 'min': 1416850340336, + 'max': 1416852140336 + }, + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'jpg', + 'values': [ + { + 'x': 1416850320000, + 'y': 110, + 'y0': 0 + }, + { + 'x': 1416850350000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416850380000, + 'y': 34, + 'y0': 0 + }, + { + 'x': 1416850410000, + 'y': 21, + 'y0': 0 + }, + { + 'x': 1416850440000, + 'y': 32, + 'y0': 0 + }, + { + 'x': 1416850470000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416850500000, + 'y': 16, + 'y0': 0 + }, + { + 'x': 1416850530000, + 'y': 27, + 'y0': 0 + }, + { + 'x': 1416850560000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416850590000, + 'y': 38, + 'y0': 0 + }, + { + 'x': 1416850620000, + 'y': 33, + 'y0': 0 + }, + { + 'x': 1416850650000, + 'y': 33, + 'y0': 0 + }, + { + 'x': 1416850680000, + 'y': 31, + 'y0': 0 + }, + { + 'x': 1416850710000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416850740000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416850770000, + 'y': 38, + 'y0': 0 + }, + { + 'x': 1416850800000, + 'y': 34, + 'y0': 0 + }, + { + 'x': 1416850830000, + 'y': 30, + 'y0': 0 + }, + { + 'x': 1416850860000, + 'y': 38, + 'y0': 0 + }, + { + 'x': 1416850890000, + 'y': 19, + 'y0': 0 + }, + { + 'x': 1416850920000, + 'y': 23, + 'y0': 0 + }, + { + 'x': 1416850950000, + 'y': 33, + 'y0': 0 + }, + { + 'x': 1416850980000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851010000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416851040000, + 'y': 22, + 'y0': 0 + }, + { + 'x': 1416851070000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851100000, + 'y': 27, + 'y0': 0 + }, + { + 'x': 1416851130000, + 'y': 32, + 'y0': 0 + }, + { + 'x': 1416851160000, + 'y': 32, + 'y0': 0 + }, + { + 'x': 1416851190000, + 'y': 30, + 'y0': 0 + }, + { + 'x': 1416851220000, + 'y': 32, + 'y0': 0 + }, + { + 'x': 1416851250000, + 'y': 36, + 'y0': 0 + }, + { + 'x': 1416851280000, + 'y': 32, + 'y0': 0 + }, + { + 'x': 1416851310000, + 'y': 29, + 'y0': 0 + }, + { + 'x': 1416851340000, + 'y': 22, + 'y0': 0 + }, + { + 'x': 1416851370000, + 'y': 29, + 'y0': 0 + }, + { + 'x': 1416851400000, + 'y': 33, + 'y0': 0 + }, + { + 'x': 1416851430000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851460000, + 'y': 39, + 'y0': 0 + }, + { + 'x': 1416851490000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851520000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851550000, + 'y': 28, + 'y0': 0 + }, + { + 'x': 1416851580000, + 'y': 30, + 'y0': 0 + }, + { + 'x': 1416851610000, + 'y': 29, + 'y0': 0 + }, + { + 'x': 1416851640000, + 'y': 30, + 'y0': 0 + }, + { + 'x': 1416851670000, + 'y': 23, + 'y0': 0 + }, + { + 'x': 1416851700000, + 'y': 23, + 'y0': 0 + }, + { + 'x': 1416851730000, + 'y': 27, + 'y0': 0 + }, + { + 'x': 1416851760000, + 'y': 21, + 'y0': 0 + }, + { + 'x': 1416851790000, + 'y': 24, + 'y0': 0 + }, + { + 'x': 1416851820000, + 'y': 26, + 'y0': 0 + }, + { + 'x': 1416851850000, + 'y': 26, + 'y0': 0 + }, + { + 'x': 1416851880000, + 'y': 21, + 'y0': 0 + }, + { + 'x': 1416851910000, + 'y': 33, + 'y0': 0 + }, + { + 'x': 1416851940000, + 'y': 23, + 'y0': 0 + }, + { + 'x': 1416851970000, + 'y': 46, + 'y0': 0 + }, + { + 'x': 1416852000000, + 'y': 27, + 'y0': 0 + }, + { + 'x': 1416852030000, + 'y': 20, + 'y0': 0 + }, + { + 'x': 1416852060000, + 'y': 34, + 'y0': 0 + }, + { + 'x': 1416852090000, + 'y': 15, + 'y0': 0 + }, + { + 'x': 1416852120000, + 'y': 18, + 'y0': 0 + } + ] + }, + { + 'label': 'css', + 'values': [ + { + 'x': 1416850320000, + 'y': 3, + 'y0': 11 + }, + { + 'x': 1416850350000, + 'y': 13, + 'y0': 24 + }, + { + 'x': 1416850380000, + 'y': 5, + 'y0': 34 + }, + { + 'x': 1416850410000, + 'y': 12, + 'y0': 21 + }, + { + 'x': 1416850440000, + 'y': 9, + 'y0': 32 + }, + { + 'x': 1416850470000, + 'y': 12, + 'y0': 24 + }, + { + 'x': 1416850500000, + 'y': 6, + 'y0': 16 + }, + { + 'x': 1416850530000, + 'y': 6, + 'y0': 27 + }, + { + 'x': 1416850560000, + 'y': 11, + 'y0': 24 + }, + { + 'x': 1416850590000, + 'y': 11, + 'y0': 38 + }, + { + 'x': 1416850620000, + 'y': 6, + 'y0': 33 + }, + { + 'x': 1416850650000, + 'y': 8, + 'y0': 33 + }, + { + 'x': 1416850680000, + 'y': 6, + 'y0': 31 + }, + { + 'x': 1416850710000, + 'y': 4, + 'y0': 24 + }, + { + 'x': 1416850740000, + 'y': 9, + 'y0': 24 + }, + { + 'x': 1416850770000, + 'y': 3, + 'y0': 38 + }, + { + 'x': 1416850800000, + 'y': 5, + 'y0': 34 + }, + { + 'x': 1416850830000, + 'y': 6, + 'y0': 30 + }, + { + 'x': 1416850860000, + 'y': 9, + 'y0': 38 + }, + { + 'x': 1416850890000, + 'y': 5, + 'y0': 19 + }, + { + 'x': 1416850920000, + 'y': 8, + 'y0': 23 + }, + { + 'x': 1416850950000, + 'y': 9, + 'y0': 33 + }, + { + 'x': 1416850980000, + 'y': 5, + 'y0': 28 + }, + { + 'x': 1416851010000, + 'y': 6, + 'y0': 24 + }, + { + 'x': 1416851040000, + 'y': 9, + 'y0': 22 + }, + { + 'x': 1416851070000, + 'y': 9, + 'y0': 28 + }, + { + 'x': 1416851100000, + 'y': 11, + 'y0': 27 + }, + { + 'x': 1416851130000, + 'y': 5, + 'y0': 32 + }, + { + 'x': 1416851160000, + 'y': 8, + 'y0': 32 + }, + { + 'x': 1416851190000, + 'y': 6, + 'y0': 30 + }, + { + 'x': 1416851220000, + 'y': 10, + 'y0': 32 + }, + { + 'x': 1416851250000, + 'y': 5, + 'y0': 36 + }, + { + 'x': 1416851280000, + 'y': 6, + 'y0': 32 + }, + { + 'x': 1416851310000, + 'y': 4, + 'y0': 29 + }, + { + 'x': 1416851340000, + 'y': 8, + 'y0': 22 + }, + { + 'x': 1416851370000, + 'y': 3, + 'y0': 29 + }, + { + 'x': 1416851400000, + 'y': 8, + 'y0': 33 + }, + { + 'x': 1416851430000, + 'y': 10, + 'y0': 28 + }, + { + 'x': 1416851460000, + 'y': 5, + 'y0': 39 + }, + { + 'x': 1416851490000, + 'y': 7, + 'y0': 28 + }, + { + 'x': 1416851520000, + 'y': 6, + 'y0': 28 + }, + { + 'x': 1416851550000, + 'y': 4, + 'y0': 28 + }, + { + 'x': 1416851580000, + 'y': 9, + 'y0': 30 + }, + { + 'x': 1416851610000, + 'y': 3, + 'y0': 29 + }, + { + 'x': 1416851640000, + 'y': 9, + 'y0': 30 + }, + { + 'x': 1416851670000, + 'y': 6, + 'y0': 23 + }, + { + 'x': 1416851700000, + 'y': 11, + 'y0': 23 + }, + { + 'x': 1416851730000, + 'y': 4, + 'y0': 27 + }, + { + 'x': 1416851760000, + 'y': 8, + 'y0': 21 + }, + { + 'x': 1416851790000, + 'y': 5, + 'y0': 24 + }, + { + 'x': 1416851820000, + 'y': 7, + 'y0': 26 + }, + { + 'x': 1416851850000, + 'y': 7, + 'y0': 26 + }, + { + 'x': 1416851880000, + 'y': 4, + 'y0': 21 + }, + { + 'x': 1416851910000, + 'y': 8, + 'y0': 33 + }, + { + 'x': 1416851940000, + 'y': 6, + 'y0': 23 + }, + { + 'x': 1416851970000, + 'y': 6, + 'y0': 46 + }, + { + 'x': 1416852000000, + 'y': 3, + 'y0': 27 + }, + { + 'x': 1416852030000, + 'y': 6, + 'y0': 20 + }, + { + 'x': 1416852060000, + 'y': 5, + 'y0': 34 + }, + { + 'x': 1416852090000, + 'y': 5, + 'y0': 15 + }, + { + 'x': 1416852120000, + 'y': 1, + 'y0': 18 + } + ] + }, + { + 'label': 'gif', + 'values': [ + { + 'x': 1416850320000, + 'y': 1, + 'y0': 14 + }, + { + 'x': 1416850350000, + 'y': 2, + 'y0': 37 + }, + { + 'x': 1416850380000, + 'y': 4, + 'y0': 39 + }, + { + 'x': 1416850410000, + 'y': 2, + 'y0': 33 + }, + { + 'x': 1416850440000, + 'y': 3, + 'y0': 41 + }, + { + 'x': 1416850470000, + 'y': 1, + 'y0': 36 + }, + { + 'x': 1416850500000, + 'y': 1, + 'y0': 22 + }, + { + 'x': 1416850530000, + 'y': 1, + 'y0': 33 + }, + { + 'x': 1416850560000, + 'y': 2, + 'y0': 35 + }, + { + 'x': 1416850590000, + 'y': 5, + 'y0': 49 + }, + { + 'x': 1416850620000, + 'y': 1, + 'y0': 39 + }, + { + 'x': 1416850650000, + 'y': 1, + 'y0': 41 + }, + { + 'x': 1416850680000, + 'y': 4, + 'y0': 37 + }, + { + 'x': 1416850710000, + 'y': 1, + 'y0': 28 + }, + { + 'x': 1416850740000, + 'y': 3, + 'y0': 33 + }, + { + 'x': 1416850770000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416850800000, + 'y': 2, + 'y0': 39 + }, + { + 'x': 1416850830000, + 'y': 5, + 'y0': 36 + }, + { + 'x': 1416850860000, + 'y': 3, + 'y0': 47 + }, + { + 'x': 1416850890000, + 'y': 1, + 'y0': 24 + }, + { + 'x': 1416850920000, + 'y': 3, + 'y0': 31 + }, + { + 'x': 1416850950000, + 'y': 4, + 'y0': 42 + }, + { + 'x': 1416850980000, + 'y': 3, + 'y0': 33 + }, + { + 'x': 1416851010000, + 'y': 5, + 'y0': 30 + }, + { + 'x': 1416851040000, + 'y': 2, + 'y0': 31 + }, + { + 'x': 1416851070000, + 'y': 3, + 'y0': 37 + }, + { + 'x': 1416851100000, + 'y': 5, + 'y0': 38 + }, + { + 'x': 1416851130000, + 'y': 3, + 'y0': 37 + }, + { + 'x': 1416851160000, + 'y': 4, + 'y0': 40 + }, + { + 'x': 1416851190000, + 'y': 9, + 'y0': 36 + }, + { + 'x': 1416851220000, + 'y': 7, + 'y0': 42 + }, + { + 'x': 1416851250000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416851280000, + 'y': 1, + 'y0': 38 + }, + { + 'x': 1416851310000, + 'y': 2, + 'y0': 33 + }, + { + 'x': 1416851340000, + 'y': 5, + 'y0': 30 + }, + { + 'x': 1416851370000, + 'y': 3, + 'y0': 32 + }, + { + 'x': 1416851400000, + 'y': 5, + 'y0': 41 + }, + { + 'x': 1416851430000, + 'y': 4, + 'y0': 38 + }, + { + 'x': 1416851460000, + 'y': 5, + 'y0': 44 + }, + { + 'x': 1416851490000, + 'y': 2, + 'y0': 35 + }, + { + 'x': 1416851520000, + 'y': 2, + 'y0': 34 + }, + { + 'x': 1416851550000, + 'y': 4, + 'y0': 32 + }, + { + 'x': 1416851580000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416851610000, + 'y': 4, + 'y0': 32 + }, + { + 'x': 1416851640000, + 'y': 0, + 'y0': 39 + }, + { + 'x': 1416851670000, + 'y': 2, + 'y0': 29 + }, + { + 'x': 1416851700000, + 'y': 1, + 'y0': 34 + }, + { + 'x': 1416851730000, + 'y': 3, + 'y0': 31 + }, + { + 'x': 1416851760000, + 'y': 0, + 'y0': 29 + }, + { + 'x': 1416851790000, + 'y': 4, + 'y0': 29 + }, + { + 'x': 1416851820000, + 'y': 3, + 'y0': 33 + }, + { + 'x': 1416851850000, + 'y': 3, + 'y0': 33 + }, + { + 'x': 1416851880000, + 'y': 0, + 'y0': 25 + }, + { + 'x': 1416851910000, + 'y': 0, + 'y0': 41 + }, + { + 'x': 1416851940000, + 'y': 3, + 'y0': 29 + }, + { + 'x': 1416851970000, + 'y': 3, + 'y0': 52 + }, + { + 'x': 1416852000000, + 'y': 1, + 'y0': 30 + }, + { + 'x': 1416852030000, + 'y': 5, + 'y0': 26 + }, + { + 'x': 1416852060000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416852090000, + 'y': 1, + 'y0': 20 + }, + { + 'x': 1416852120000, + 'y': 2, + 'y0': 19 + } + ] + }, + { + 'label': 'png', + 'values': [ + { + 'x': 1416850320000, + 'y': 1, + 'y0': 15 + }, + { + 'x': 1416850350000, + 'y': 6, + 'y0': 39 + }, + { + 'x': 1416850380000, + 'y': 6, + 'y0': 43 + }, + { + 'x': 1416850410000, + 'y': 5, + 'y0': 35 + }, + { + 'x': 1416850440000, + 'y': 3, + 'y0': 44 + }, + { + 'x': 1416850470000, + 'y': 5, + 'y0': 37 + }, + { + 'x': 1416850500000, + 'y': 6, + 'y0': 23 + }, + { + 'x': 1416850530000, + 'y': 1, + 'y0': 34 + }, + { + 'x': 1416850560000, + 'y': 3, + 'y0': 37 + }, + { + 'x': 1416850590000, + 'y': 2, + 'y0': 54 + }, + { + 'x': 1416850620000, + 'y': 1, + 'y0': 40 + }, + { + 'x': 1416850650000, + 'y': 1, + 'y0': 42 + }, + { + 'x': 1416850680000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416850710000, + 'y': 5, + 'y0': 29 + }, + { + 'x': 1416850740000, + 'y': 7, + 'y0': 36 + }, + { + 'x': 1416850770000, + 'y': 2, + 'y0': 43 + }, + { + 'x': 1416850800000, + 'y': 3, + 'y0': 41 + }, + { + 'x': 1416850830000, + 'y': 6, + 'y0': 41 + }, + { + 'x': 1416850860000, + 'y': 2, + 'y0': 50 + }, + { + 'x': 1416850890000, + 'y': 4, + 'y0': 25 + }, + { + 'x': 1416850920000, + 'y': 2, + 'y0': 34 + }, + { + 'x': 1416850950000, + 'y': 3, + 'y0': 46 + }, + { + 'x': 1416850980000, + 'y': 8, + 'y0': 36 + }, + { + 'x': 1416851010000, + 'y': 4, + 'y0': 35 + }, + { + 'x': 1416851040000, + 'y': 4, + 'y0': 33 + }, + { + 'x': 1416851070000, + 'y': 1, + 'y0': 40 + }, + { + 'x': 1416851100000, + 'y': 2, + 'y0': 43 + }, + { + 'x': 1416851130000, + 'y': 4, + 'y0': 40 + }, + { + 'x': 1416851160000, + 'y': 3, + 'y0': 44 + }, + { + 'x': 1416851190000, + 'y': 4, + 'y0': 45 + }, + { + 'x': 1416851220000, + 'y': 2, + 'y0': 49 + }, + { + 'x': 1416851250000, + 'y': 4, + 'y0': 43 + }, + { + 'x': 1416851280000, + 'y': 8, + 'y0': 39 + }, + { + 'x': 1416851310000, + 'y': 4, + 'y0': 35 + }, + { + 'x': 1416851340000, + 'y': 4, + 'y0': 35 + }, + { + 'x': 1416851370000, + 'y': 7, + 'y0': 35 + }, + { + 'x': 1416851400000, + 'y': 2, + 'y0': 46 + }, + { + 'x': 1416851430000, + 'y': 3, + 'y0': 42 + }, + { + 'x': 1416851460000, + 'y': 3, + 'y0': 49 + }, + { + 'x': 1416851490000, + 'y': 3, + 'y0': 37 + }, + { + 'x': 1416851520000, + 'y': 4, + 'y0': 36 + }, + { + 'x': 1416851550000, + 'y': 3, + 'y0': 36 + }, + { + 'x': 1416851580000, + 'y': 4, + 'y0': 42 + }, + { + 'x': 1416851610000, + 'y': 5, + 'y0': 36 + }, + { + 'x': 1416851640000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416851670000, + 'y': 3, + 'y0': 31 + }, + { + 'x': 1416851700000, + 'y': 2, + 'y0': 35 + }, + { + 'x': 1416851730000, + 'y': 5, + 'y0': 34 + }, + { + 'x': 1416851760000, + 'y': 4, + 'y0': 29 + }, + { + 'x': 1416851790000, + 'y': 5, + 'y0': 33 + }, + { + 'x': 1416851820000, + 'y': 1, + 'y0': 36 + }, + { + 'x': 1416851850000, + 'y': 3, + 'y0': 36 + }, + { + 'x': 1416851880000, + 'y': 6, + 'y0': 25 + }, + { + 'x': 1416851910000, + 'y': 4, + 'y0': 41 + }, + { + 'x': 1416851940000, + 'y': 7, + 'y0': 32 + }, + { + 'x': 1416851970000, + 'y': 5, + 'y0': 55 + }, + { + 'x': 1416852000000, + 'y': 2, + 'y0': 31 + }, + { + 'x': 1416852030000, + 'y': 2, + 'y0': 31 + }, + { + 'x': 1416852060000, + 'y': 4, + 'y0': 42 + }, + { + 'x': 1416852090000, + 'y': 6, + 'y0': 21 + }, + { + 'x': 1416852120000, + 'y': 2, + 'y0': 21 + } + ] + }, + { + 'label': 'php', + 'values': [ + { + 'x': 1416850320000, + 'y': 0, + 'y0': 16 + }, + { + 'x': 1416850350000, + 'y': 1, + 'y0': 45 + }, + { + 'x': 1416850380000, + 'y': 0, + 'y0': 49 + }, + { + 'x': 1416850410000, + 'y': 2, + 'y0': 40 + }, + { + 'x': 1416850440000, + 'y': 0, + 'y0': 47 + }, + { + 'x': 1416850470000, + 'y': 0, + 'y0': 42 + }, + { + 'x': 1416850500000, + 'y': 3, + 'y0': 29 + }, + { + 'x': 1416850530000, + 'y': 1, + 'y0': 35 + }, + { + 'x': 1416850560000, + 'y': 3, + 'y0': 40 + }, + { + 'x': 1416850590000, + 'y': 2, + 'y0': 56 + }, + { + 'x': 1416850620000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416850650000, + 'y': 5, + 'y0': 43 + }, + { + 'x': 1416850680000, + 'y': 2, + 'y0': 43 + }, + { + 'x': 1416850710000, + 'y': 1, + 'y0': 34 + }, + { + 'x': 1416850740000, + 'y': 2, + 'y0': 43 + }, + { + 'x': 1416850770000, + 'y': 2, + 'y0': 45 + }, + { + 'x': 1416850800000, + 'y': 1, + 'y0': 44 + }, + { + 'x': 1416850830000, + 'y': 1, + 'y0': 47 + }, + { + 'x': 1416850860000, + 'y': 1, + 'y0': 52 + }, + { + 'x': 1416850890000, + 'y': 1, + 'y0': 29 + }, + { + 'x': 1416850920000, + 'y': 2, + 'y0': 36 + }, + { + 'x': 1416850950000, + 'y': 2, + 'y0': 49 + }, + { + 'x': 1416850980000, + 'y': 0, + 'y0': 44 + }, + { + 'x': 1416851010000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416851040000, + 'y': 2, + 'y0': 37 + }, + { + 'x': 1416851070000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416851100000, + 'y': 2, + 'y0': 45 + }, + { + 'x': 1416851130000, + 'y': 0, + 'y0': 44 + }, + { + 'x': 1416851160000, + 'y': 1, + 'y0': 47 + }, + { + 'x': 1416851190000, + 'y': 2, + 'y0': 49 + }, + { + 'x': 1416851220000, + 'y': 4, + 'y0': 51 + }, + { + 'x': 1416851250000, + 'y': 0, + 'y0': 47 + }, + { + 'x': 1416851280000, + 'y': 3, + 'y0': 47 + }, + { + 'x': 1416851310000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416851340000, + 'y': 2, + 'y0': 39 + }, + { + 'x': 1416851370000, + 'y': 2, + 'y0': 42 + }, + { + 'x': 1416851400000, + 'y': 3, + 'y0': 48 + }, + { + 'x': 1416851430000, + 'y': 1, + 'y0': 45 + }, + { + 'x': 1416851460000, + 'y': 0, + 'y0': 52 + }, + { + 'x': 1416851490000, + 'y': 2, + 'y0': 40 + }, + { + 'x': 1416851520000, + 'y': 1, + 'y0': 40 + }, + { + 'x': 1416851550000, + 'y': 3, + 'y0': 39 + }, + { + 'x': 1416851580000, + 'y': 1, + 'y0': 46 + }, + { + 'x': 1416851610000, + 'y': 2, + 'y0': 41 + }, + { + 'x': 1416851640000, + 'y': 1, + 'y0': 42 + }, + { + 'x': 1416851670000, + 'y': 2, + 'y0': 34 + }, + { + 'x': 1416851700000, + 'y': 3, + 'y0': 37 + }, + { + 'x': 1416851730000, + 'y': 1, + 'y0': 39 + }, + { + 'x': 1416851760000, + 'y': 1, + 'y0': 33 + }, + { + 'x': 1416851790000, + 'y': 1, + 'y0': 38 + }, + { + 'x': 1416851820000, + 'y': 1, + 'y0': 37 + }, + { + 'x': 1416851850000, + 'y': 1, + 'y0': 39 + }, + { + 'x': 1416851880000, + 'y': 1, + 'y0': 31 + }, + { + 'x': 1416851910000, + 'y': 2, + 'y0': 45 + }, + { + 'x': 1416851940000, + 'y': 0, + 'y0': 39 + }, + { + 'x': 1416851970000, + 'y': 0, + 'y0': 60 + }, + { + 'x': 1416852000000, + 'y': 1, + 'y0': 33 + }, + { + 'x': 1416852030000, + 'y': 2, + 'y0': 33 + }, + { + 'x': 1416852060000, + 'y': 1, + 'y0': 46 + }, + { + 'x': 1416852090000, + 'y': 1, + 'y0': 27 + }, + { + 'x': 1416852120000, + 'y': 0, + 'y0': 23 + } + ] + } + ], + 'hits': 2595, + 'xAxisFormatter': function (thing) { + return moment(thing); + }, + 'tooltipFormatter': function (d) { + return d; + } + }; +}); diff --git a/test/unit/specs/vislib/lib/data.js b/test/unit/specs/vislib/lib/data.js index 42e799ddd32e..2058cb73bcea 100644 --- a/test/unit/specs/vislib/lib/data.js +++ b/test/unit/specs/vislib/lib/data.js @@ -247,5 +247,52 @@ define(function (require) { }); }); + describe('getYMaxValue method', function () { + var Data; + var dataSeries; + var stackedDataSeries; + var visData; + var stackedVisData; + var series; + var stackedSeries; + var maxValue; + var stackedMaxValue; + + beforeEach(function () { + module('DataFactory'); + }); + + beforeEach(function () { + inject(function (d3, Private) { + Data = Private(require('components/vislib/lib/data')); + dataSeries = require('vislib_fixtures/mock_data/series/_data0'); + stackedDataSeries = require('vislib_fixtures/mock_data/stacked/_stacked'); + visData = new Data(dataSeries, {}); + stackedVisData = new Data(stackedDataSeries, {}); + series = visData.flatten(); + stackedSeries = stackedVisData.flatten(); + maxValue = 25; + stackedMaxValue = 60; + }); + }); + + // The first value in the time series is less than the min date in the + // date range. It also has the largest y value. This value should be excluded + // when calculating the Y max value since it falls outside of the range. + it('should return the Y domain max value', function () { + series.forEach(function (data) { + expect(visData.getYMax(data)).to.be(maxValue); + }); + stackedSeries.forEach(function (data) { + expect(stackedVisData.getYStackMax(data)).to.be(stackedMaxValue); + }); + }); + + it('should have a minimum date value that is greater than the max value within the date range', function () { + expect(_.min(series, function (d) { return d.x; })).to.be.greaterThan(maxValue); + expect(_.min(stackedSeries, function (d) { return d.x; })).to.be.greaterThan(stackedMaxValue); + }); + }); + }); }); From d4789c5af5dc4ea7388583d8c3d0fd542f359e7b Mon Sep 17 00:00:00 2001 From: lukasolson Date: Mon, 24 Nov 2014 17:07:29 -0700 Subject: [PATCH 6/8] Shorten field names according to shortDots setting --- src/kibana/components/agg_response/flat.js | 4 +-- .../hierarchical/_collect_branch.js | 4 +-- .../hierarchical/build_hierarchical_data.js | 2 +- .../components/agg_types/buckets/histogram.js | 2 +- .../components/agg_types/buckets/range.js | 2 +- .../agg_types/buckets/significant_terms.js | 2 +- .../components/agg_types/buckets/terms.js | 2 +- .../components/agg_types/controls/field.html | 2 +- .../components/agg_types/metric_aggs.js | 10 +++---- .../index_patterns/_index_pattern.js | 20 +++++++++---- .../index_patterns/index_patterns.js | 1 + .../plugins/discover/controllers/discover.js | 1 + .../discover/directives/table_header.js | 2 ++ .../plugins/discover/directives/table_row.js | 6 ++-- .../discover/partials/table_header.html | 2 +- .../discover/partials/table_row/_source.html | 4 +-- .../settings/sections/indices/_edit.html | 2 +- .../vis_types/vislib/converters/histogram.js | 2 +- .../vis_types/vislib/converters/pie.js | 2 +- .../stubbed_logstash_index_pattern.js | 28 +++++++++---------- .../hierarchical/collect_branch.js | 2 +- 21 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/kibana/components/agg_response/flat.js b/src/kibana/components/agg_response/flat.js index 2c454adc557d..93c0081d7e34 100644 --- a/src/kibana/components/agg_response/flat.js +++ b/src/kibana/components/agg_response/flat.js @@ -104,7 +104,7 @@ define(function (require) { var groupMap = chartData.splits || (chartData.splits = {}); result.buckets.forEach(function (bucket) { - var bucketId = bucket.key + (col.field ? ': ' + col.field.name : ''); + var bucketId = bucket.key + (col.field ? ': ' + col.field.displayName : ''); var group = groupMap[bucketId]; if (!group) { @@ -167,7 +167,7 @@ define(function (require) { } if (config.field) { - config.label = config.field.name; + config.label = config.field.displayName; return; } }); diff --git a/src/kibana/components/agg_response/hierarchical/_collect_branch.js b/src/kibana/components/agg_response/hierarchical/_collect_branch.js index 098ce10b7226..6a84e1b6b360 100644 --- a/src/kibana/components/agg_response/hierarchical/_collect_branch.js +++ b/src/kibana/components/agg_response/hierarchical/_collect_branch.js @@ -6,11 +6,11 @@ define(function (require) { // record the the depth var depth = item.depth - 1; - // Using the aggConfig determin what the field name is. If the aggConfig + // Using the aggConfig determine what the field name is. If the aggConfig // doesn't exist (which means it's an _all agg) then use the level for // the field name var col = item.aggConfig; - var field = (col && col.params && col.params.field && col.params.field.name) + var field = (col && col.params && col.params.field && col.params.field.displayName) || (col && col.label) || ('level ' + item.depth); diff --git a/src/kibana/components/agg_response/hierarchical/build_hierarchical_data.js b/src/kibana/components/agg_response/hierarchical/build_hierarchical_data.js index 7ffb6d9ddd67..523584a7f9f0 100644 --- a/src/kibana/components/agg_response/hierarchical/build_hierarchical_data.js +++ b/src/kibana/components/agg_response/hierarchical/build_hierarchical_data.js @@ -53,7 +53,7 @@ define(function (require) { var agg = firstAgg._next; var split = buildSplit(agg, metric, bucket[agg.id]); // Since splits display labels we need to set it. - split.label = bucket.key + ': ' + firstAgg.params.field.name; + split.label = bucket.key + ': ' + firstAgg.params.field.displayName; split.tooltipFormatter = tooltipFormatter(raw.columns); return split; }); diff --git a/src/kibana/components/agg_types/buckets/histogram.js b/src/kibana/components/agg_types/buckets/histogram.js index 4338a6c53442..b17395d5264b 100644 --- a/src/kibana/components/agg_types/buckets/histogram.js +++ b/src/kibana/components/agg_types/buckets/histogram.js @@ -9,7 +9,7 @@ define(function (require) { title: 'Histogram', ordered: {}, makeLabel: function (aggConfig) { - return aggConfig.params.field.name; + return aggConfig.params.field.displayName; }, params: [ { diff --git a/src/kibana/components/agg_types/buckets/range.js b/src/kibana/components/agg_types/buckets/range.js index 51dc9010f8ba..79a7cbb1f2d2 100644 --- a/src/kibana/components/agg_types/buckets/range.js +++ b/src/kibana/components/agg_types/buckets/range.js @@ -9,7 +9,7 @@ define(function (require) { name: 'range', title: 'Range', makeLabel: function (aggConfig) { - return aggConfig.params.field.name + ' ranges'; + return aggConfig.params.field.displayName + ' ranges'; }, params: [ { diff --git a/src/kibana/components/agg_types/buckets/significant_terms.js b/src/kibana/components/agg_types/buckets/significant_terms.js index a499ef004650..d4ea2516cd1a 100644 --- a/src/kibana/components/agg_types/buckets/significant_terms.js +++ b/src/kibana/components/agg_types/buckets/significant_terms.js @@ -7,7 +7,7 @@ define(function (require) { name: 'significant_terms', title: 'Significant Terms', makeLabel: function (aggConfig) { - return 'Top ' + aggConfig.params.size + ' unusual terms in ' + aggConfig.params.field.name; + return 'Top ' + aggConfig.params.size + ' unusual terms in ' + aggConfig.params.field.displayName; }, params: [ { diff --git a/src/kibana/components/agg_types/buckets/terms.js b/src/kibana/components/agg_types/buckets/terms.js index b3254ffb1ce6..b67f175f6e36 100644 --- a/src/kibana/components/agg_types/buckets/terms.js +++ b/src/kibana/components/agg_types/buckets/terms.js @@ -9,7 +9,7 @@ define(function (require) { title: 'Terms', makeLabel: function (aggConfig) { var params = aggConfig.params; - return params.order.display + ' ' + params.size + ' ' + params.field.name; + return params.order.display + ' ' + params.size + ' ' + params.field.displayName; }, params: [ { diff --git a/src/kibana/components/agg_types/controls/field.html b/src/kibana/components/agg_types/controls/field.html index 1f31f8598d83..74e30b5f06c8 100644 --- a/src/kibana/components/agg_types/controls/field.html +++ b/src/kibana/components/agg_types/controls/field.html @@ -8,7 +8,7 @@ required ng-model="params.field" ng-options=" - field as field.name group by field.type for field in aggConfig.vis.indexPattern.fields.raw + field as field.displayName group by field.type for field in aggConfig.vis.indexPattern.fields.raw | fieldType: aggParam.filterFieldTypes | filter: { indexed: true } | orderBy: ['type', 'name'] diff --git a/src/kibana/components/agg_types/metric_aggs.js b/src/kibana/components/agg_types/metric_aggs.js index cbed3c9341c8..1d1b1c0ab303 100644 --- a/src/kibana/components/agg_types/metric_aggs.js +++ b/src/kibana/components/agg_types/metric_aggs.js @@ -15,7 +15,7 @@ define(function (require) { name: 'avg', title: 'Average', makeLabel: function (aggConfig) { - return 'Average ' + aggConfig.params.field.name; + return 'Average ' + aggConfig.params.field.displayName; }, params: [ { @@ -28,7 +28,7 @@ define(function (require) { name: 'sum', title: 'Sum', makeLabel: function (aggConfig) { - return 'Sum of ' + aggConfig.params.field.name; + return 'Sum of ' + aggConfig.params.field.displayName; }, params: [ { @@ -41,7 +41,7 @@ define(function (require) { name: 'min', title: 'Min', makeLabel: function (aggConfig) { - return 'Min ' + aggConfig.params.field.name; + return 'Min ' + aggConfig.params.field.displayName; }, params: [ { @@ -54,7 +54,7 @@ define(function (require) { name: 'max', title: 'Max', makeLabel: function (aggConfig) { - return 'Max ' + aggConfig.params.field.name; + return 'Max ' + aggConfig.params.field.displayName; }, params: [ { @@ -67,7 +67,7 @@ define(function (require) { name: 'cardinality', title: 'Unique count', makeLabel: function (aggConfig) { - return 'Unique count of ' + aggConfig.params.field.name; + return 'Unique count of ' + aggConfig.params.field.displayName; }, params: [ { diff --git a/src/kibana/components/index_patterns/_index_pattern.js b/src/kibana/components/index_patterns/_index_pattern.js index 80866855d412..d17e0b419f5e 100644 --- a/src/kibana/components/index_patterns/_index_pattern.js +++ b/src/kibana/components/index_patterns/_index_pattern.js @@ -1,5 +1,5 @@ define(function (require) { - return function IndexPatternFactory(Private, timefilter, configFile, Notifier) { + return function IndexPatternFactory(Private, timefilter, configFile, Notifier, shortDotsFilter) { var _ = require('lodash'); var angular = require('angular'); var errors = require('errors'); @@ -95,11 +95,19 @@ define(function (require) { field.count = field.count || 0; // non-enumerable type so that it does not get included in the JSON - Object.defineProperty(field, 'format', { - enumerable: false, - get: function () { - var formatName = self.customFormats && self.customFormats[field.name]; - return formatName ? fieldFormats.byName[formatName] : fieldFormats.defaultByType[field.type]; + Object.defineProperties(field, { + format: { + enumerable: false, + get: function () { + var formatName = self.customFormats && self.customFormats[field.name]; + return formatName ? fieldFormats.byName[formatName] : fieldFormats.defaultByType[field.type]; + } + }, + displayName: { + enumerable: false, + get: function () { + return shortDotsFilter(field.name); + } } }); diff --git a/src/kibana/components/index_patterns/index_patterns.js b/src/kibana/components/index_patterns/index_patterns.js index 0980f6df8326..bb87d02a7192 100644 --- a/src/kibana/components/index_patterns/index_patterns.js +++ b/src/kibana/components/index_patterns/index_patterns.js @@ -1,5 +1,6 @@ define(function (require) { var module = require('modules').get('kibana/index_patterns'); + require('filters/short_dots'); module.service('indexPatterns', function (configFile, es, Notifier, Private, Promise) { var self = this; diff --git a/src/kibana/plugins/discover/controllers/discover.js b/src/kibana/plugins/discover/controllers/discover.js index 2d2166732dbc..9b339f2545c2 100644 --- a/src/kibana/plugins/discover/controllers/discover.js +++ b/src/kibana/plugins/discover/controllers/discover.js @@ -509,6 +509,7 @@ define(function (require) { _.defaults(field, currentState[field.name]); // clone the field and add it's display prop var clone = _.assign({}, field, { + displayName: field.displayName, // this is a getter, so we need to copy it over manually format: field.format, // this is a getter, so we need to copy it over manually display: columnObjects[field.name] || false, rowCount: $scope.rows ? $scope.rows.fieldCounts[field.name] : 0 diff --git a/src/kibana/plugins/discover/directives/table_header.js b/src/kibana/plugins/discover/directives/table_header.js index ce770a901820..7f576f1693c1 100644 --- a/src/kibana/plugins/discover/directives/table_header.js +++ b/src/kibana/plugins/discover/directives/table_header.js @@ -2,6 +2,8 @@ define(function (require) { var _ = require('lodash'); var module = require('modules').get('app/discover'); + require('filters/short_dots'); + module.directive('kbnTableHeader', function () { var headerHtml = require('text!plugins/discover/partials/table_header.html'); return { diff --git a/src/kibana/plugins/discover/directives/table_row.js b/src/kibana/plugins/discover/directives/table_row.js index 62a96945f70c..ef617f265649 100644 --- a/src/kibana/plugins/discover/directives/table_row.js +++ b/src/kibana/plugins/discover/directives/table_row.js @@ -7,6 +7,7 @@ define(function (require) { require('components/highlight/highlight'); require('filters/trust_as_html'); + require('filters/short_dots'); // guestimate at the minimum number of chars wide cells in the table should be var MIN_LINE_LENGTH = 20; @@ -19,7 +20,7 @@ define(function (require) { * * ``` */ - module.directive('kbnTableRow', function ($compile, config, highlightFilter) { + module.directive('kbnTableRow', function ($compile, config, highlightFilter, shortDotsFilter) { var openRowHtml = require('text!plugins/discover/partials/table_row/open.html'); var detailsHtml = require('text!plugins/discover/partials/table_row/details.html'); var cellTemplate = _.template(require('text!plugins/discover/partials/table_row/cell.html')); @@ -134,7 +135,8 @@ define(function (require) { source: _.mapValues(row._formatted, function (val, field) { return _displayField(row, field, false); }), - highlight: row.highlight + highlight: row.highlight, + shortDotsFilter: shortDotsFilter }); } else { formatted = _displayField(row, column, true); diff --git a/src/kibana/plugins/discover/partials/table_header.html b/src/kibana/plugins/discover/partials/table_header.html index d55b81f04372..0a1528199228 100644 --- a/src/kibana/plugins/discover/partials/table_header.html +++ b/src/kibana/plugins/discover/partials/table_header.html @@ -4,7 +4,7 @@ - {{name}} + {{name | shortDotsFilter}} diff --git a/src/kibana/plugins/discover/partials/table_row/_source.html b/src/kibana/plugins/discover/partials/table_row/_source.html index 4d0ecd8899fe..005903101dfa 100644 --- a/src/kibana/plugins/discover/partials/table_row/_source.html +++ b/src/kibana/plugins/discover/partials/table_row/_source.html @@ -1,12 +1,12 @@
<% _.each(highlight, function (value, field) { /* show fields that match the query first */ %> -
<%= field %>:
+
<%= shortDotsFilter(field) %>:
<%= source[field] %>
<%= ' ' %> <% }); %> <% _.each(source, function (value, field) { %> <% if (_.has(highlight, field)) return; %> -
<%= field %>:
+
<%= shortDotsFilter(field) %>:
<%= value %>
<%= ' ' %> <% }); %> diff --git a/src/kibana/plugins/settings/sections/indices/_edit.html b/src/kibana/plugins/settings/sections/indices/_edit.html index 286bf459d3e4..b9644c5dfd2b 100644 --- a/src/kibana/plugins/settings/sections/indices/_edit.html +++ b/src/kibana/plugins/settings/sections/indices/_edit.html @@ -76,7 +76,7 @@

- +   Date: Tue, 25 Nov 2014 08:26:38 -0700 Subject: [PATCH 7/8] Fix bad reference to shortDotsFilter inside table header --- src/kibana/plugins/discover/partials/table_header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kibana/plugins/discover/partials/table_header.html b/src/kibana/plugins/discover/partials/table_header.html index 0a1528199228..e1a7c8aa6fc4 100644 --- a/src/kibana/plugins/discover/partials/table_header.html +++ b/src/kibana/plugins/discover/partials/table_header.html @@ -4,7 +4,7 @@ - {{name | shortDotsFilter}} + {{name | shortDots}} From 9cec87920cb815fd5bc2645f009594f661f95999 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 25 Nov 2014 09:13:58 -0700 Subject: [PATCH 8/8] Fix word breaking --- src/kibana/styles/_table.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kibana/styles/_table.less b/src/kibana/styles/_table.less index 72665e3b5241..470237528f9e 100644 --- a/src/kibana/styles/_table.less +++ b/src/kibana/styles/_table.less @@ -31,6 +31,7 @@ kbn-table,tbody[kbn-rows] { dd { display: inline; + word-break: break-all; } }