return function (vis, resp) { nodes = {}; links = {}; lastNode = -1; var metric = vis.aggs.bySchemaGroup.metrics[0]; var buckets = vis.aggs.bySchemaGroup.buckets; buckets = arrayToLinkedList(buckets); if (!buckets) { return {'slices':{'nodes':[],'links':[]}}; } var firstAgg = buckets[0]; var aggData = resp.aggregations[firstAgg.id]; if (!firstAgg._next) { notify.error('need more than one sub aggs'); } processEntry(firstAgg, metric, aggData, -1); var invertNodes = _.invert(nodes); var chart = { 'slices': { 'nodes' : _.map(_.keys(invertNodes), function (k) { return {'name':invertNodes[k]}; }), 'links' : _.map(_.keys(links), function (k) { var s = k.split('sankeysplitchar'); return {'source': parseInt(s[0]), 'target': parseInt(s[1]), 'value': links[k]}; }) } }; return chart; };
beforeEach(function () { results = arrayToLinkedList([ { id: 1 }, { id: 2 }, { id: 3 } ]); });
return function (vis, resp) { var metric = vis.aggs.bySchemaGroup.metrics[0]; var children = vis.aggs.bySchemaGroup.buckets; children = arrayToLinkedList(children); if (!children) { return { 'children' : { 'children' : null }}; } var firstAgg = children[0]; var aggData = resp.aggregations[firstAgg.id]; nodes = []; processEntryRecursive(aggData, nodes); var chart = { 'name' :'flare', 'children' : nodes, 'size' : 0 }; return chart; };
return function (vis, resp) { var metric = vis.aggs.bySchemaGroup.metrics[0]; var children = vis.aggs.bySchemaGroup.buckets; children = arrayToLinkedList(children); var firstAgg = children[0]; var aggData = resp.aggregations[firstAgg.id]; var max_value = 0; var min_value = 0; var bool_first = true; nodes = []; _.each(aggData.buckets, function (d, i) { var min = 0; var max = 0; if (d[vis.aggs.byTypeName["max"][0].id].value >= d[vis.aggs.byTypeName["min"][0].id].value) { min = d[vis.aggs.byTypeName["min"][0].id].value; max = d[vis.aggs.byTypeName["max"][0].id].value; } else { min = d[vis.aggs.byTypeName["max"][0].id].value; max = d[vis.aggs.byTypeName["min"][0].id].value; } if (bool_first) { max_value = max; min_value = min; bool_first = false; } else { if (min < min_value) min_value = min; if (max > max_value) max_value = max; } nodes.push({ 'bucket': d.key, 'doc_count': d.doc_count, 'mean' : d[vis.aggs.byTypeName["avg"][0].id].value, 'min': min, 'max': max, 'percentiles': d[vis.aggs.byTypeName["percentiles"][0].id].values }); }); var chart = { 'max_value' : max_value, 'min_value' : min_value, 'data': nodes }; return chart; };
beforeEach(function () { let id = 1; vis = new Vis(indexPattern, { type: 'pie', aggs: [ { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, { type: 'terms', schema: 'split', params: { field: 'extension' }}, { type: 'terms', schema: 'segment', params: { field: 'machine.os' }}, { type: 'terms', schema: 'segment', params: { field: 'geo.src' }} ] }); let buckets = arrayToLinkedList(vis.aggs.bySchemaGroup.buckets); // We need to set the aggs to a known value. _.each(vis.aggs, function (agg) { agg.id = 'agg_' + id++; }); results = createRawData(vis, fixtures.threeTermBuckets); });
return function (vis, resp) { var metric = vis.aggs.bySchemaGroup.metrics[0]; var children = vis.aggs.bySchemaGroup.buckets; children = arrayToLinkedList(children); var firstAgg = children[0]; var aggData = resp.aggregations[firstAgg.id]; var max_value = 0; var min_value = 0; var bool_first = true; nodes = []; var id_aggregation = children[1].id; var labels = null; try { labels = JSON.parse(vis.params.jsonLabels); //[ { 'text' : 'CUENTA'} ] } catch (e) { labels = ""; } var pos = 0; var aggs = []; _.each(aggData.buckets, function (d, i) { var results = []; var min = 0; var max = 0; if (d[id_aggregation]) { if (d[id_aggregation].buckets) { var ordered_results = d[id_aggregation].buckets.sort(d3.ascending); max = ordered_results[ordered_results.length-1].key; min = ordered_results[0].key; _.each(d[id_aggregation].buckets, function(d1, i1) { for(var t=0; t < d1.doc_count; t++) { results.push(d1.key); } }); if (bool_first) { max_value = max; min_value = min; bool_first = false; } else { if (min < min_value) min_value = min; if (max > max_value) max_value = max; } } } var textLabel = d.key; if (labels.length > pos) { textLabel = (labels[pos].text ? labels[pos].text : textLabel); } nodes.push({ 'boxplot_key' : d.key, 'textLabel' : textLabel, 'results' : results }); pos++; }); var chart = { 'max_value' : max_value, 'min_value' : min_value, 'data': nodes }; return chart; };
return function (vis, resp) { // Create a refrenece to the buckets var buckets = vis.aggs.bySchemaGroup.buckets; // Find the metric so it's easier to reference. // TODO: Change this to support multiple metrics. var metric = vis.aggs.bySchemaGroup.metrics[0]; // Link each agg to the next agg. This will be // to identify the next bucket aggregation buckets = arrayToLinkedList(buckets); // Create the raw data to be used in the spy panel var raw = createRawData(vis, resp); // If buckets is falsy then we should just return the aggs if (!buckets) { var value = resp.aggregations && resp.aggregations[metric.id] && resp.aggregations[metric.id].value || resp.hits.total; return { hits: resp.hits.total, raw: raw, names: ['_all'], tooltipFormatter: tooltipFormatter(raw.columns), slices: { children: [ { name: '_all', size: value } ] } }; } var firstAgg = buckets[0]; var aggData = resp.aggregations[firstAgg.id]; if (!firstAgg._next && firstAgg.schema.name === 'split') { notify.error('Splitting charts without splitting slices is not supported. Pretending that we are just splitting slices.'); } // start with splitting slices if (!firstAgg._next || firstAgg.schema.name === 'segment') { var split = buildSplit(firstAgg, metric, aggData); split.hits = resp.hits.total; split.raw = raw; split.tooltipFormatter = tooltipFormatter(raw.columns); return split; } // map the split aggregations into rows. var rows = _.map(extractBuckets(aggData), function (bucket) { var agg = firstAgg._next; var split = buildSplit(agg, metric, bucket[agg.id]); // Since splits display labels we need to set it. split.label = firstAgg.fieldFormatter()(bucket.key); var displayName = firstAgg.fieldDisplayName(); if (!_.isEmpty(displayName)) split.label += ': ' + displayName; split.tooltipFormatter = tooltipFormatter(raw.columns); var aggConfigResult = new AggConfigResult(firstAgg, null, null, firstAgg.getKey(bucket)); split.split = { aggConfig: firstAgg, aggConfigResult: aggConfigResult, key: bucket.key }; _.each(split.slices.children, function (child) { child.aggConfigResult.$parent = aggConfigResult; }); return split; }); var result = { hits: resp.hits.total, raw: raw }; if (firstAgg.params.row) { result.rows = rows; } else { result.columns = rows; } return result; };