UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

29 lines (23 loc) 686 B
import _ from 'lodash'; export default function FlattenDataObjectUtilService() { /* * Accepts a Kibana data object, flattens the data.series values array, * and returns an array of values objects. */ return function (obj) { let charts; if (!_.isObject(obj) || !obj.rows && !obj.columns && !obj.series) { throw new TypeError('FlattenDataObjUtilService expects an object with a series, rows, or columns key'); } if (!obj.series) { charts = obj.rows ? obj.rows : obj.columns; } return _(charts ? charts : [obj]) .pluck('series') .flattenDeep() .pluck('values') .flattenDeep() .filter(Boolean) .value(); }; };