Merge pull request #3918 from stormpython/pieHighlighting

Fixes issues with highlighting of numeric and date values in pie charts
This commit is contained in:
Lukas Olson 2015-05-21 12:57:45 -07:00
commit 3c28b3d870
4 changed files with 11 additions and 27 deletions

View file

@ -13,19 +13,12 @@ define(function () {
|| (col && col.label)
|| ('level ' + item.depth);
// Set the bucket name, and use the converter to format the field if
// the field exists.
var bucket = item.name;
if (col) {
bucket = col.fieldFormatter()(bucket);
}
// Add the row to the tooltipScope.rows
memo.unshift({
aggConfig: col,
depth: depth,
field: field,
bucket: bucket,
bucket: item.name,
metric: item.size,
item: item
});

View file

@ -5,19 +5,16 @@ define(function (require) {
var AggConfigResult = require('components/vis/_agg_config_result');
return function transformAggregation(agg, metric, aggData, parent) {
return _.map(extractBuckets(aggData), function (bucket) {
// Pick the appropriate value, if the metric doesn't exist then we just
// use the count.
var value = bucket.doc_count;
if (bucket[metric.id] && !_.isUndefined(bucket[metric.id].value)) {
value = bucket[metric.id].value;
}
var aggConfigResult = new AggConfigResult(
agg,
parent && parent.aggConfigResult,
metric.getValue(bucket),
agg.getKey(bucket)
);
// Create the new branch record
var $parent = parent && parent.aggConfigResult;
var aggConfigResult = new AggConfigResult(agg, $parent, value, agg.getKey(bucket));
var branch = {
name: bucket.key,
size: value,
name: agg.fieldFormatter()(bucket.key),
size: aggConfigResult.value,
aggConfig: agg,
aggConfigResult: aggConfigResult
};

View file

@ -461,8 +461,7 @@ define(function (require) {
var self = this;
_.forEach(array, function (obj) {
var fieldFormatter = obj.aggConfig ? obj.aggConfig.fieldFormatter() : String;
names.push({ key: fieldFormatter(obj.name), index: index });
names.push({ key: obj.name, index: index });
if (obj.children) {
var plusIndex = index + 1;

View file

@ -106,11 +106,6 @@ define(function (require) {
var tooltip = self.tooltip;
var isTooltip = self._attr.addTooltip;
var format = function (d, label) {
var formatter = d.aggConfig ? d.aggConfig.fieldFormatter() : String;
return formatter(label);
};
var partition = d3.layout.partition()
.sort(null)
.value(function (d) {
@ -155,7 +150,7 @@ define(function (require) {
.style('stroke', '#fff')
.style('fill', function (d) {
if (d.depth === 0) { return 'none'; }
return color(format(d, d.name));
return color(d.name);
});
if (isTooltip) {