Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2cf29b5
Add uiState to discover
lukasolson Nov 13, 2015
f09d6d0
Pass uiState around in order to utilize it when rendering charts and …
lukasolson Nov 17, 2015
2ff4a47
Merge branch 'master' into issues/1362
lukasolson Nov 17, 2015
c0c7c7e
Add color picker to legend
lukasolson Nov 18, 2015
5257ae4
Merge branch 'master' into issues/1362
lukasolson Nov 18, 2015
bbcdb5d
Fix broken tests for color palette selection
lukasolson Nov 19, 2015
8895757
Merge branch 'master' of github.com:elastic/kibana into pr/5443
Nov 30, 2015
9f705d8
Initial pass at angularifying legend values
Dec 1, 2015
ee8d05f
Move color selection to angular directive
Dec 1, 2015
28c8950
Remove relabeling of legend when only 1 series exists
Dec 2, 2015
20b6d74
Persist legend state, add filter buttons to legend item details
Dec 3, 2015
566af1a
Merge branch 'master' into issues/1362
lukasolson Dec 3, 2015
afa135f
fix legend closed by default
Dec 4, 2015
c79b00c
Fix legend hover with series hover
Dec 4, 2015
a7e35d9
Destroy angular scopes
Dec 4, 2015
5f5aab8
Merge branch 'issues/1362' of github.com:lukasolson/kibana into pr/5443
Dec 4, 2015
9752d18
Angularize the entire legend
Dec 7, 2015
9d6273b
remove commented out code
Dec 7, 2015
3220c54
Remove legend from layout test, vislib no longer does that
Dec 7, 2015
5106399
Fix table tests
Dec 7, 2015
3e45978
Remove unused legend_header.html
Dec 7, 2015
f548e96
Use noop, 1px thing is not needed
Dec 7, 2015
a85cb1d
Fix BWC with addLegend
Dec 9, 2015
b16d5a3
move buttons up
Dec 9, 2015
45a315b
Always show the scrollbar, keep the color picker a fixed width
Dec 9, 2015
9c4f758
Merge pull request #8 from rashidkpc/pr/5443
lukasolson Dec 11, 2015
606c495
Merge branch 'master' into issues/1362
lukasolson Dec 11, 2015
92a7a47
Remove unused function
Dec 11, 2015
d9fa59c
Move ng-hide up
Dec 11, 2015
3584792
Remove magic number
Dec 11, 2015
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
15 changes: 15 additions & 0 deletions src/fixtures/mock_ui_state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
define(function (require) {
var _ = require('lodash');
var keys = {};
return {
get: function (path, def) {
return keys[path] == null ? def : keys[path];
},
set: function (path, val) {
keys[path] = val;
return val;
},
on: _.noop,
off: _.noop
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@
Show Tooltip
</label>
</div>
<div class="vis-option-item">
<label>
<input type="checkbox" ng-model="vis.params.addLegend">
Show Legend
</label>
</div>
</div>
2 changes: 2 additions & 0 deletions src/plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ define(function (require) {
}

var $state = $scope.state = new AppState(getStateDefaults());
$scope.uiState = $state.makeStateful('uiState');

function getStateDefaults() {
return {
query: $scope.searchSource.get('query') || '',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana/public/discover/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ <h2>Searching</h2>

</header>

<visualize ng-if="vis && rows.length != 0" vis="vis" es-resp="mergedEsResp" search-source="searchSource"></visualize>
<visualize ng-if="vis && rows.length != 0" vis="vis" ui-state="uiState" es-resp="mergedEsResp" search-source="searchSource"></visualize>
</div>

<div class="discover-table" fixed-scroll>
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/table_vis/public/__tests__/_table_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ describe('Integration', function () {

$rootScope.vis = vis;
$rootScope.esResponse = esResponse;
$el = $('<visualize vis="vis" es-resp="esResponse">');
$rootScope.uiState = require('fixtures/mock_ui_state');
$el = $('<visualize vis="vis" es-resp="esResponse" ui-state="uiState">');
$compile($el)($rootScope);
$rootScope.$apply();

Expand Down
3 changes: 2 additions & 1 deletion src/ui/public/Vis/Renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ define(function (require) {
* @param {Vis} vis - the vis object that contains all configuration data required to render the vis
* @param {jQuery<DOMElement>} $el - a jQuery wrapped element to render into
*/
function Renderbot(vis, $el) {
function Renderbot(vis, $el, uiState) {
this.vis = vis;
this.$el = $el;
this.uiState = uiState;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/ui/public/Vis/__tests__/_Renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ describe('renderbot', function () {
var vis;
var $el;
var renderbot;
var uiState;

beforeEach(init);
beforeEach(function () {
vis = { hello: 'world' };
$el = 'element';
renderbot = new Renderbot(vis, $el);
uiState = {};
renderbot = new Renderbot(vis, $el, uiState);
});

it('should have expected methods', function () {
Expand Down
27 changes: 14 additions & 13 deletions src/ui/public/filter_bar/filter_bar_click_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,11 @@ define(function (require) {
var _ = require('lodash');
var dedupFilters = require('./lib/dedupFilters');
var uniqFilters = require('./lib/uniqFilters');

// given an object or array of objects, return the value of the passed param
// if the param is missing, return undefined
function findByParam(values, param) {
if (_.isArray(values)) { // point series chart
var index = _.findIndex(values, param);
if (index === -1) return;
return values[index][param];
}
return values[param]; // pie chart
}
var findByParam = require('ui/utils/find_by_param');

return function (Notifier) {
return function ($state) {
return function (event) {
return function (event, simulate) {
var notify = new Notifier({
location: 'Filter bar'
});
Expand Down Expand Up @@ -58,9 +48,20 @@ define(function (require) {

if (!filters.length) return;

if (event.negate) {
_.each(filters, function (filter) {
filter.meta = filter.meta || {};
filter.meta.negate = true;
});
}

filters = dedupFilters($state.filters, uniqFilters(filters));
// We need to add a bunch of filter deduping here.
$state.$newFilters = filters;
if (!simulate) {
$state.$newFilters = filters;
}

return filters;
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/template_vis_type/TemplateRenderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ define(function (require) {
var Renderbot = Private(require('ui/Vis/Renderbot'));

_.class(TemplateRenderbot).inherits(Renderbot);
function TemplateRenderbot(vis, $el) {
TemplateRenderbot.Super.call(this, vis, $el);
function TemplateRenderbot(vis, $el, uiState) {
TemplateRenderbot.Super.call(this, vis, $el, uiState);

this.$scope = $rootScope.$new();
this.$scope.vis = vis;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/template_vis_type/TemplateVisType.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ define(function (require) {
}
}

TemplateVisType.prototype.createRenderbot = function (vis, $el) {
return new TemplateRenderbot(vis, $el);
TemplateVisType.prototype.createRenderbot = function (vis, $el, uiState) {
return new TemplateRenderbot(vis, $el, uiState);
};

return TemplateVisType;
Expand Down
13 changes: 13 additions & 0 deletions src/ui/public/utils/find_by_param.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define(function (require) {
var _ = require('lodash');
// given an object or array of objects, return the value of the passed param
// if the param is missing, return undefined
return function findByParam(values, param) {
if (_.isArray(values)) { // point series chart
var index = _.findIndex(values, param);
if (index === -1) return;
return values[index][param];
}
return values[param]; // pie chart
};
});
7 changes: 6 additions & 1 deletion src/ui/public/vislib/__tests__/components/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Vislib Color Module Test Suite', function () {
seedColors = Private(require('ui/vislib/components/color/seed_colors'));
getColors = Private(require('ui/vislib/components/color/color'));
mappedColors = Private(require('ui/vislib/components/color/mapped_colors'));
color = getColors(arr);
color = getColors(arr, {});
}));

afterEach(ngMock.inject((config) => {
Expand Down Expand Up @@ -110,6 +110,11 @@ describe('Vislib Color Module Test Suite', function () {
it('should return the value from the mapped colors', function () {
expect(color(arr[1])).to.be(mappedColors.get(arr[1]));
});

it('should return the value from the specified color mapping overrides', function () {
const colorFn = getColors(arr, {good: 'red'});
expect(colorFn('good')).to.be('red');
});
});

describe('Seed Colors', function () {
Expand Down
4 changes: 3 additions & 1 deletion src/ui/public/vislib/__tests__/lib/axis_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var expect = require('expect.js');
describe('Vislib AxisTitle Class Test Suite', function () {
var AxisTitle;
var Data;
var PersistedState;
var axisTitle;
var el;
var dataObj;
Expand Down Expand Up @@ -76,6 +77,7 @@ describe('Vislib AxisTitle Class Test Suite', function () {
beforeEach(ngMock.inject(function (Private) {
AxisTitle = Private(require('ui/vislib/lib/axis_title'));
Data = Private(require('ui/vislib/lib/data'));
PersistedState = Private(require('ui/persisted_state/persisted_state'));

el = d3.select('body').append('div')
.attr('class', 'vis-wrapper');
Expand All @@ -91,7 +93,7 @@ describe('Vislib AxisTitle Class Test Suite', function () {
.style('width', '20px');


dataObj = new Data(data, {});
dataObj = new Data(data, {}, new PersistedState());
xTitle = dataObj.get('xAxisLabel');
yTitle = dataObj.get('yAxisLabel');
axisTitle = new AxisTitle($('.vis-wrapper')[0], xTitle, yTitle);
Expand Down
4 changes: 3 additions & 1 deletion src/ui/public/vislib/__tests__/lib/chart_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var expect = require('expect.js');
describe('Vislib ChartTitle Class Test Suite', function () {
var ChartTitle;
var Data;
var persistedState;
var chartTitle;
var el;
var dataObj;
Expand Down Expand Up @@ -74,6 +75,7 @@ describe('Vislib ChartTitle Class Test Suite', function () {
beforeEach(ngMock.inject(function (Private) {
ChartTitle = Private(require('ui/vislib/lib/chart_title'));
Data = Private(require('ui/vislib/lib/data'));
persistedState = new (Private(require('ui/persisted_state/persisted_state')))();

el = d3.select('body').append('div')
.attr('class', 'vis-wrapper')
Expand All @@ -83,7 +85,7 @@ describe('Vislib ChartTitle Class Test Suite', function () {
.attr('class', 'chart-title')
.style('height', '20px');

dataObj = new Data(data, {});
dataObj = new Data(data, {}, persistedState);
chartTitle = new ChartTitle($('.vis-wrapper')[0], 'rows');
}));

Expand Down
38 changes: 20 additions & 18 deletions src/ui/public/vislib/__tests__/lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ var colsData = {

describe('Vislib Data Class Test Suite', function () {
var Data;
var persistedState;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Data = Private(require('ui/vislib/lib/data'));
persistedState = new (Private(require('ui/persisted_state/persisted_state')))();
}));

describe('Data Class (main)', function () {
Expand All @@ -113,7 +115,7 @@ describe('Vislib Data Class Test Suite', function () {
});

it('should return an object', function () {
var rowIn = new Data(rowsData, {});
var rowIn = new Data(rowsData, {}, persistedState);
expect(_.isObject(rowIn)).to.be(true);
});

Expand All @@ -128,7 +130,7 @@ describe('Vislib Data Class Test Suite', function () {
],
'yAxisLabel': 'customLabel'
};
var modifiedData = new Data(seriesDataWithoutLabelInSeries, {});
var modifiedData = new Data(seriesDataWithoutLabelInSeries, {}, persistedState);
expect(modifiedData.data.series[0].label).to.be('customLabel');
});

Expand Down Expand Up @@ -158,7 +160,7 @@ describe('Vislib Data Class Test Suite', function () {
],
};

var modifiedData = new Data(seriesDataWithoutLabelInRow, {});
var modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState);
expect(modifiedData.data.rows[0].series[0].label).to.be('customLabel');
expect(modifiedData.data.rows[1].series[0].label).to.be('customLabel');
});
Expand Down Expand Up @@ -190,7 +192,7 @@ describe('Vislib Data Class Test Suite', function () {
'yAxisLabel': 'customLabel'
};

var modifiedData = new Data(seriesDataWithoutLabelInRow, {});
var modifiedData = new Data(seriesDataWithoutLabelInRow, {}, persistedState);
expect(modifiedData.data.columns[0].series[0].label).to.be('customLabel');
expect(modifiedData.data.columns[1].series[0].label).to.be('customLabel');
});
Expand All @@ -210,7 +212,7 @@ describe('Vislib Data Class Test Suite', function () {
};

beforeEach(function () {
data = new Data(pieData, {});
data = new Data(pieData, {}, persistedState);
});

it('should remove zero values', function () {
Expand All @@ -228,9 +230,9 @@ describe('Vislib Data Class Test Suite', function () {
var colOut;

beforeEach(function () {
serIn = new Data(seriesData, {});
rowIn = new Data(rowsData, {});
colIn = new Data(colsData, {});
serIn = new Data(seriesData, {}, persistedState);
rowIn = new Data(rowsData, {}, persistedState);
colIn = new Data(colsData, {}, persistedState);
serOut = serIn.flatten();
rowOut = rowIn.flatten();
colOut = colIn.flatten();
Expand All @@ -246,7 +248,7 @@ describe('Vislib Data Class Test Suite', function () {

function testLength(inputData) {
return function () {
var data = new Data(inputData, {});
var data = new Data(inputData, {}, persistedState);
var len = _.reduce(data.chartData(), function (sum, chart) {
return sum + chart.series.reduce(function (sum, series) {
return sum + series.values.length;
Expand All @@ -267,9 +269,9 @@ describe('Vislib Data Class Test Suite', function () {
var minValueStacked = 15;

beforeEach(function () {
visData = new Data(dataSeries, {});
visDataNeg = new Data(dataSeriesNeg, {});
visDataStacked = new Data(dataStacked, { type: 'histogram' });
visData = new Data(dataSeries, {}, persistedState);
visDataNeg = new Data(dataSeriesNeg, {}, persistedState);
visDataStacked = new Data(dataStacked, { type: 'histogram' }, persistedState);
});

// The first value in the time series is less than the min date in the
Expand Down Expand Up @@ -304,9 +306,9 @@ describe('Vislib Data Class Test Suite', function () {
var maxValueStacked = 115;

beforeEach(function () {
visData = new Data(dataSeries, {});
visDataNeg = new Data(dataSeriesNeg, {});
visDataStacked = new Data(dataStacked, { type: 'histogram' });
visData = new Data(dataSeries, {}, persistedState);
visDataNeg = new Data(dataSeriesNeg, {}, persistedState);
visDataStacked = new Data(dataStacked, { type: 'histogram' }, persistedState);
});

// The first value in the time series is less than the min date in the
Expand Down Expand Up @@ -372,7 +374,7 @@ describe('Vislib Data Class Test Suite', function () {
};

beforeEach(function () {
data = new Data(geohashGridData, {});
data = new Data(geohashGridData, {}, persistedState);
});

describe('getVisData', function () {
Expand All @@ -393,7 +395,7 @@ describe('Vislib Data Class Test Suite', function () {

describe('null value check', function () {
it('should return false', function () {
var data = new Data(rowsData, {});
var data = new Data(rowsData, {}, persistedState);
expect(data.hasNullValues()).to.be(false);
});

Expand All @@ -409,7 +411,7 @@ describe('Vislib Data Class Test Suite', function () {
]
});

var data = new Data(nullRowData, {});
var data = new Data(nullRowData, {}, persistedState);
expect(data.hasNullValues()).to.be(true);
});
});
Expand Down
Loading