mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Merge branch 'master' of github.com:elasticsearch/kibana4
This commit is contained in:
commit
c024963c72
5 changed files with 67 additions and 59 deletions
|
@ -108,6 +108,7 @@ define(function (require) {
|
|||
{
|
||||
name: 'date_histogram',
|
||||
display: 'Date Histogram',
|
||||
ordinal: {},
|
||||
params: {
|
||||
interval: {
|
||||
required: true,
|
||||
|
|
|
@ -2,7 +2,7 @@ define(function (require) {
|
|||
return function BuildChartDataFn(Notifier, Private, courier) {
|
||||
var _ = require('lodash');
|
||||
var aggs = Private(require('./_aggs'));
|
||||
var converters = require('./resp_converters/index');
|
||||
var converters = Private(require('./resp_converters/index'));
|
||||
|
||||
var notify = new Notifier();
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
define(function () {
|
||||
var _ = require('lodash');
|
||||
var aggKeyPrefix = '_agg_';
|
||||
});
|
|
@ -1,61 +1,70 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
return function HistogramConverterFn(Private) {
|
||||
var _ = require('lodash');
|
||||
var aggs = Private(require('../_aggs'));
|
||||
|
||||
return function (chart, columns, rows) {
|
||||
// index of color
|
||||
var iColor = _.findIndex(columns, { categoryName: 'group' });
|
||||
var hasColor = iColor !== -1;
|
||||
return function (chart, columns, rows) {
|
||||
// index of color
|
||||
var iColor = _.findIndex(columns, { categoryName: 'group' });
|
||||
var hasColor = iColor !== -1;
|
||||
|
||||
// index of x-axis
|
||||
var iX = _.findIndex(columns, { categoryName: 'segment'});
|
||||
// index of y-axis
|
||||
var iY = _.findIndex(columns, { categoryName: 'metric'});
|
||||
// index of x-axis
|
||||
var iX = _.findIndex(columns, { categoryName: 'segment'});
|
||||
// index of y-axis
|
||||
var iY = _.findIndex(columns, { categoryName: 'metric'});
|
||||
|
||||
// when we don't have an x-axis, just push everything into '_all'
|
||||
if (iX === -1) {
|
||||
iX = columns.push({
|
||||
label: ''
|
||||
}) - 1;
|
||||
}
|
||||
|
||||
// X-axis description
|
||||
chart.xAxisLabel = columns[iX].label;
|
||||
if (columns[iX].field) chart.xAxisFormatter = columns[iX].field.format.convert;
|
||||
|
||||
// Legend value
|
||||
chart.label = columns[iY].label;
|
||||
|
||||
// Y-axis description
|
||||
chart.yAxisLabel = columns[iY].label;
|
||||
if (columns[iY].field) chart.yAxisFormatter = columns[iY].field.format.convert;
|
||||
|
||||
var series = chart.series = [];
|
||||
var seriesByLabel = {};
|
||||
|
||||
rows.forEach(function (row) {
|
||||
var seriesLabel = hasColor && row[iColor];
|
||||
var s = hasColor ? seriesByLabel[seriesLabel] : series[0];
|
||||
|
||||
if (!s) {
|
||||
// I know this could be simplified but I wanted to keep the key order
|
||||
if (hasColor) {
|
||||
s = {
|
||||
label: seriesLabel,
|
||||
values: []
|
||||
};
|
||||
seriesByLabel[seriesLabel] = s;
|
||||
} else {
|
||||
s = {
|
||||
values: []
|
||||
};
|
||||
}
|
||||
series.push(s);
|
||||
// when we don't have an x-axis, just push everything into '_all'
|
||||
if (iX === -1) {
|
||||
iX = columns.push({
|
||||
label: ''
|
||||
}) - 1;
|
||||
}
|
||||
|
||||
s.values.push({
|
||||
x: row[iX] || '_all',
|
||||
y: row[iY === -1 ? row.length - 1 : iY] // y-axis value
|
||||
var agg = columns[iX].agg && aggs.byName[columns[iX].agg];
|
||||
if (agg && agg.ordinal) {
|
||||
// TODO: add interval, min, max data here for the chart
|
||||
chart.ordinal = {};
|
||||
}
|
||||
|
||||
// X-axis description
|
||||
chart.xAxisLabel = columns[iX].label;
|
||||
if (columns[iX].field) chart.xAxisFormatter = columns[iX].field.format.convert;
|
||||
|
||||
// Legend value
|
||||
chart.label = columns[iY].label;
|
||||
|
||||
// Y-axis description
|
||||
chart.yAxisLabel = columns[iY].label;
|
||||
if (columns[iY].field) chart.yAxisFormatter = columns[iY].field.format.convert;
|
||||
|
||||
var series = chart.series = [];
|
||||
var seriesByLabel = {};
|
||||
|
||||
rows.forEach(function (row) {
|
||||
var seriesLabel = hasColor && row[iColor];
|
||||
var s = hasColor ? seriesByLabel[seriesLabel] : series[0];
|
||||
|
||||
if (!s) {
|
||||
// I know this could be simplified but I wanted to keep the key order
|
||||
if (hasColor) {
|
||||
s = {
|
||||
label: seriesLabel,
|
||||
values: []
|
||||
};
|
||||
seriesByLabel[seriesLabel] = s;
|
||||
} else {
|
||||
s = {
|
||||
values: []
|
||||
};
|
||||
}
|
||||
series.push(s);
|
||||
}
|
||||
|
||||
s.values.push({
|
||||
x: row[iX] || '_all',
|
||||
y: row[iY === -1 ? row.length - 1 : iY] // y-axis value
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
});
|
|
@ -1,5 +1,7 @@
|
|||
define(function (require) {
|
||||
return {
|
||||
histogram: require('./histogram')
|
||||
return function RespConvertersService(Private) {
|
||||
return {
|
||||
histogram: Private(require('./histogram'))
|
||||
};
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue