Skip to content

Commit

Permalink
Revert "Merge pull request #319 from simianhacker/filter-bar-terms"
Browse files Browse the repository at this point in the history
This reverts commit 1cae258, reversing
changes made to 1c8ca3e.

Conflicts:
	src/kibana/components/vislib/visualizations/column_chart.js
  • Loading branch information
simianhacker committed Sep 22, 2014
1 parent 774603a commit d2d52fc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 68 deletions.
1 change: 0 additions & 1 deletion TODOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@
- **[src/kibana/components/vislib/vis.js](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/components/vislib/vis.js)**
- need to come up with a solution for resizing when no data is available
- **[src/kibana/components/vislib/visualizations/column_chart.js](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/components/vislib/visualizations/column_chart.js)**
- Replace the following code with something more robust for finding the field
- refactor so that this is called from the data module
- **[src/kibana/components/visualize/visualize.js](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/components/visualize/visualize.js)**
- we need to have some way to clean up result requests
Expand Down
3 changes: 1 addition & 2 deletions src/kibana/apps/visualize/editor/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
config-object="conf">
</config>

<filter-bar state="state"></filter-bar>

<div class="vis-editor-content">
<vis-editor-sidebar
Expand All @@ -85,4 +84,4 @@
</div>
</div>

</div>
</div>
38 changes: 1 addition & 37 deletions src/kibana/apps/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ define(function (require) {
var savedVisState = vis.getState();

var $state = appStateFactory.create({
vis: savedVisState,
filters: _.cloneDeep(searchSource.get('filter'))
vis: savedVisState
});

if (!angular.equals($state.vis, savedVisState)) {
Expand Down Expand Up @@ -123,12 +122,6 @@ define(function (require) {
searchSource.set('query', null);
}

if ($state.filters) {
searchSource.set('filter', $state.filters);
} else {
searchSource.set('filter', null);
}

$scope.fetch();

});
Expand All @@ -143,37 +136,8 @@ define(function (require) {
$scope.$on('$destroy', function () {
savedVis.destroy();
});

if (!vis.listeners) vis.listeners = {};
vis.listeners.click = function (e) {
// This code is only inplace for the beta release this will all get refactored
// after we get the release out.
if (e.aggConfig && e.aggConfig.aggType && e.aggConfig.aggType.name === 'terms') {
var filter;
var filters = _.flatten([$state.filters || []], true);
var previous = _.find(filters, function (item) {
if (item && item.query) {
return item.query.match[e.field].query === e.label;
}
});
if (!previous) {
filter = { query: { match: {} } };
filter.query.match[e.field] = { query: e.label, type: 'phrase' };
filters.push(filter);
$state.filters = filters;
}
} else {
notify.info('Filtering is only supported for Term aggergations at the time, others are coming soon.');
}
};
}

$scope.$watch('state.filters', function (filters) {
searchSource.set('filter', filters);
$state.save();
$scope.fetch();
});

$scope.fetch = function () {
searchSource.fetch();
};
Expand Down
6 changes: 1 addition & 5 deletions src/kibana/components/vis_types/converters/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,8 @@ define(function (require) {
datum.y = datum.y * colX.metricScale;
}

if (hasColor) {
datum.aggConfigs = [columns[iX], columns[iColor]];
}

s.values.push(datum);
});
};
};
});
});
27 changes: 4 additions & 23 deletions src/kibana/components/vislib/visualizations/column_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,16 @@ define(function (require) {

// Response to `click` and `hover` events
ColumnChart.prototype.eventResponse = function (d, i) {

// Adding a look up for the field. Currently this relies on filtering the
// data for the label then using that with the pointIndex to get the aggConfig.
// It works for now... but we need something a little more robust. That will
// come after the first beta. :)
//
// TODO: Replace the following code with something more robust for finding the field
var field, series, aggConfig;
if (d.label) {
series = _.find(this.chartData.series, { label: d.label });
aggConfig = _.last(series.values[i].aggConfigs);
if (aggConfig.aggType.name === 'terms') {
field = aggConfig.field.name;
}
}

return {
value: this._attr.yValue(d, i),
point: d,
label: d.label,
color: this.vis.data.getColorFunc()(d.label),
pointIndex: i,
series: this.chartData.series,
config: this._attr,
data: this.chartData,
e: d3.event,
field: field,
aggConfig: aggConfig,
vis: this.vis
series : this.chartData.series,
config : this._attr,
data : this.chartData,
e : d3.event
};
};

Expand Down

0 comments on commit d2d52fc

Please sign in to comment.