Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed linechart zero-injection, closes #2102 #2118

Merged
merged 3 commits into from
Dec 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ define(function (require) {

/*
* Accepts a Kibana data object and returns
* an array of x axis values ordered by their index number.
* an array of x axis values.
* values sorted by timestamp if isDate and Date Histogram agg
* else values sorted by index
*/

return function (obj) {
Expand All @@ -18,8 +20,9 @@ define(function (require) {
return _.chain(objKeys)
.pairs()
.sortBy(function (d) {

// sort by index
if (d[1].isDate) {
return +d[0];
}
return d[1].index;
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add comments to the top of this return statement regarding why if its date, we sort by date and if its not, we sort by index.

.map(function (d) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define(function (require) {
}

var flattenedData = flattenDataArray(obj);
var isDate = (obj.ordered && obj.ordered.date);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this var statement to line 20, right after

var flattenedData = flattenDataArray(obj);

var uniqueXValues = {};

flattenedData.forEach(function (d, i) {
Expand All @@ -25,14 +26,17 @@ define(function (require) {
if (uniqueXValues[key] === void 0) {
uniqueXValues[key] = {
index: i,
isDate: isDate,
isNumber: _.isNumber(key)
};
} else {
uniqueXValues[key] = {
index: Math.min(i, uniqueXValues[key].index),
isDate: isDate,
isNumber: _.isNumber(key)
};
}

});

return uniqueXValues;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also update the comments at the top of the file.

Expand Down