mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
fixing the data converter
This commit is contained in:
parent
cf1c1973a3
commit
3e7da78171
3 changed files with 67 additions and 20 deletions
2
TODOS.md
2
TODOS.md
|
@ -443,6 +443,8 @@
|
|||
- Now that all calls to _data and _removeData have been replaced
|
||||
- **[src/kibana/components/index_patterns/_mapper.js](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/components/index_patterns/_mapper.js)**
|
||||
- Change index to be the resolved in some way, last three months, last hour, last year, whatever
|
||||
- **[src/kibana/components/vis_types/converters/pie.js](https://github.com/elasticsearch/kibana4/blob/master/src/kibana/components/vis_types/converters/pie.js)**
|
||||
- cleanup code, simplify and document
|
||||
- **[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)**
|
||||
|
|
|
@ -96,14 +96,21 @@ define(function (require) {
|
|||
return out;
|
||||
};
|
||||
|
||||
var slices = chart.slices = {};
|
||||
var name = slices.name = chart.xAxisLabel + ' ' + chart.yAxisLabel;
|
||||
var slices = chart.slices = {
|
||||
name: chart.xAxisLabel + ' ' + chart.yAxisLabel
|
||||
};
|
||||
var children = slices.children = [];
|
||||
var slicesByName = {};
|
||||
|
||||
function appendS(array, name) {
|
||||
return array.push({
|
||||
name: name,
|
||||
children: []
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: cleanup code, simplify and document
|
||||
rows.forEach(function (row) {
|
||||
var sliceName = hasColor && row[iColor];
|
||||
var s = hasColor ? slicesByName[sliceName] : undefined;
|
||||
var rowLength = row.length;
|
||||
|
||||
var datum = {
|
||||
name: (row[iX] == null) ? '_all' : row[iX],
|
||||
|
@ -115,22 +122,57 @@ define(function (require) {
|
|||
datum.size = datum.size * colX.metricScale;
|
||||
}
|
||||
|
||||
if (!s) {
|
||||
if (hasColor) {
|
||||
s = {
|
||||
name: sliceName,
|
||||
children: []
|
||||
};
|
||||
slicesByName[sliceName] = s;
|
||||
|
||||
children.push(s);
|
||||
} else {
|
||||
children.push(datum);
|
||||
}
|
||||
if (rowLength <= 2) {
|
||||
return children.push(datum);
|
||||
} else {
|
||||
s.children.push(datum);
|
||||
|
||||
var startIndex = 1;
|
||||
var stopIndex = rowLength - 1;
|
||||
var names = row.slice(startIndex, stopIndex).reverse();
|
||||
var namesLength = names.length - 1;
|
||||
var currentArray = children;
|
||||
var prevName;
|
||||
|
||||
names.forEach(function (name, i) {
|
||||
var prevNameIndex;
|
||||
var currentNameIndex;
|
||||
|
||||
if (!prevName) {
|
||||
// Find the index of the name within the children array
|
||||
currentNameIndex = _.findIndex(currentArray, { name: name });
|
||||
|
||||
// if not iName, append s object to current array
|
||||
if (currentNameIndex === -1) {
|
||||
appendS(currentArray, name);
|
||||
}
|
||||
} else {
|
||||
// Get the previous object index
|
||||
prevNameIndex = _.findIndex(currentArray, {name: prevName});
|
||||
|
||||
// Update the currentArray
|
||||
currentArray = currentArray[prevNameIndex].children;
|
||||
|
||||
// Get current object index
|
||||
currentNameIndex = _.findIndex(currentArray, { name: name });
|
||||
|
||||
// if current object does not exist, append to the current array
|
||||
if (currentNameIndex === -1) {
|
||||
appendS(currentArray, name);
|
||||
}
|
||||
}
|
||||
|
||||
if (i === namesLength) {
|
||||
// Find index of name in current array
|
||||
currentNameIndex = _.findIndex(currentArray, { name: name });
|
||||
currentArray[currentNameIndex].children.push(datum);
|
||||
}
|
||||
|
||||
// Set prevName to current Name
|
||||
prevName = name;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
|
@ -19,7 +19,10 @@ define(function (require) {
|
|||
name: 'metric',
|
||||
title: 'Slice Size',
|
||||
min: 1,
|
||||
max: 1
|
||||
max: 1,
|
||||
defaults: [
|
||||
{ schema: 'metric', type: 'count' }
|
||||
]
|
||||
},
|
||||
{
|
||||
group: 'buckets',
|
||||
|
@ -27,7 +30,7 @@ define(function (require) {
|
|||
icon: 'fa fa-scissors',
|
||||
title: 'Slices',
|
||||
min: 0,
|
||||
max: 1
|
||||
max: Infinity
|
||||
},
|
||||
{
|
||||
group: 'buckets',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue