diff --git a/src/core_plugins/kbn_vislib_vis_types/public/area.js b/src/core_plugins/kbn_vislib_vis_types/public/area.js index 9d0c8bb515dfa..8f405387c25ff 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/area.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/area.js @@ -83,6 +83,7 @@ export default function PointSeriesVisType(Private) { addTimeMarker: false, }, }, + responseHandler: 'series_data', editorConfig: { collections: { positions: ['top', 'left', 'right', 'bottom'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/gauge.js b/src/core_plugins/kbn_vislib_vis_types/public/gauge.js index f5550ba39d81c..f47accf84930b 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/gauge.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/gauge.js @@ -62,6 +62,7 @@ export default function GaugeVisType(Private) { } }, }, + responseHandler: 'series_data', editorConfig: { collections: { gaugeTypes: ['Arc', 'Circle', 'Metric'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/goal.js b/src/core_plugins/kbn_vislib_vis_types/public/goal.js index 6ea27f770403c..df3c361e3fc4e 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/goal.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/goal.js @@ -56,6 +56,7 @@ export default function GoalVisType(Private) { } }, }, + responseHandler: 'series_data', editorConfig: { collections: { gaugeTypes: ['Arc', 'Circle', 'Metric'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/heatmap.js b/src/core_plugins/kbn_vislib_vis_types/public/heatmap.js index 8370d1f6869d2..e2b88aa63af55 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/heatmap.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/heatmap.js @@ -45,6 +45,7 @@ export default function HeatmapVisType(Private) { }] }, }, + responseHandler: 'series_data', editorConfig: { collections: { legendPositions: [{ diff --git a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js index cfd29461a6e53..409e2bea5e6c2 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/histogram.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/histogram.js @@ -84,6 +84,7 @@ export default function PointSeriesVisType(Private) { addTimeMarker: false, }, }, + responseHandler: 'series_data', editorConfig: { collections: { positions: ['top', 'left', 'right', 'bottom'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js b/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js index 9a1c8f9daf51b..0b2008a2e03ac 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js @@ -86,6 +86,7 @@ export default function PointSeriesVisType(Private) { addTimeMarker: false, }, }, + responseHandler: 'series_data', editorConfig: { collections: { positions: ['top', 'left', 'right', 'bottom'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/line.js b/src/core_plugins/kbn_vislib_vis_types/public/line.js index ac8e41c17e21c..6a876b336fc73 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/line.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/line.js @@ -84,6 +84,7 @@ export default function PointSeriesVisType(Private) { addTimeMarker: false, }, }, + responseHandler: 'series_data', editorConfig: { collections: { positions: ['top', 'left', 'right', 'bottom'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/metric.js b/src/core_plugins/kbn_vislib_vis_types/public/metric.js index 65e599d520133..8b9b7628e11b3 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/metric.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/metric.js @@ -55,6 +55,7 @@ export default function MetricVisType(Private) { } }, }, + responseHandler: 'series_data', editorConfig: { collections: { gaugeTypes: ['Arc', 'Circle', 'Metric'], diff --git a/src/core_plugins/kbn_vislib_vis_types/public/pie.js b/src/core_plugins/kbn_vislib_vis_types/public/pie.js index 817f7d46d9b44..ed29b2a4ab339 100644 --- a/src/core_plugins/kbn_vislib_vis_types/public/pie.js +++ b/src/core_plugins/kbn_vislib_vis_types/public/pie.js @@ -23,6 +23,7 @@ export default function HistogramVisType(Private) { isDonut: false }, }, + responseHandler: 'hierarchical_data', editorConfig: { collections: { legendPositions: [{ diff --git a/src/core_plugins/kibana/public/discover/controllers/discover.js b/src/core_plugins/kibana/public/discover/controllers/discover.js index 5d6a3237e8fc0..14dc2207ca68f 100644 --- a/src/core_plugins/kibana/public/discover/controllers/discover.js +++ b/src/core_plugins/kibana/public/discover/controllers/discover.js @@ -16,7 +16,7 @@ import 'ui/timefilter'; import 'ui/share'; import 'ui/query_bar'; import { VisProvider } from 'ui/vis'; -import { BasicResponseHandlerProvider } from 'ui/vis/response_handlers/basic'; +import { seriesResponseHandlerProvider } from 'ui/vis/response_handlers/series_data'; import { DocTitleProvider } from 'ui/doc_title'; import PluginsKibanaDiscoverHitSortFnProvider from 'plugins/kibana/discover/_hit_sort_fn'; import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter'; @@ -117,7 +117,7 @@ function discoverController( const docTitle = Private(DocTitleProvider); const HitSortFn = Private(PluginsKibanaDiscoverHitSortFnProvider); const queryFilter = Private(FilterBarQueryFilterProvider); - const responseHandler = Private(BasicResponseHandlerProvider).handler; + const responseHandler = Private(seriesResponseHandlerProvider).handler; const notify = new Notifier({ location: 'Discover' }); diff --git a/src/fixtures/agg_resp/date_term_filter.js b/src/fixtures/agg_resp/date_term_filter.js new file mode 100644 index 0000000000000..785d391a0b669 --- /dev/null +++ b/src/fixtures/agg_resp/date_term_filter.js @@ -0,0 +1,957 @@ +const response = { + 'took': 128, + 'timed_out': false, + '_shards': { + 'total': 1, + 'successful': 1, + 'skipped': 0, + 'failed': 0 + }, + 'hits': { + 'total': 11125, + 'max_score': 0, + 'hits': [] + }, + 'aggregations': { + '2': { + 'buckets': [{ + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 40 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 40 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 3 + } + } + }, + 'key': '404', + 'doc_count': 3 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 1 + }] + }, + 'key_as_string': '2017-07-25T00:00:00.000+02:00', + 'key': 1500933600000, + 'doc_count': 44 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 148 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 148 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 8 + } + } + }, + 'key': '404', + 'doc_count': 8 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 2 + }] + }, + 'key_as_string': '2017-07-25T03:00:00.000+02:00', + 'key': 1500944400000, + 'doc_count': 158 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 613 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '200', + 'doc_count': 613 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 3 + }, + '404': { + 'doc_count': 29 + } + } + }, + 'key': '404', + 'doc_count': 29 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 20 + }] + }, + 'key_as_string': '2017-07-25T06:00:00.000+02:00', + 'key': 1500955200000, + 'doc_count': 662 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 1281 + }, + '404': { + 'doc_count': 3 + } + } + }, + 'key': '200', + 'doc_count': 1281 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 5 + }, + '404': { + 'doc_count': 83 + } + } + }, + 'key': '404', + 'doc_count': 83 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 3 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 36 + }] + }, + 'key_as_string': '2017-07-25T09:00:00.000+02:00', + 'key': 1500966000000, + 'doc_count': 1400 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 1276 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '200', + 'doc_count': 1276 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 65 + } + } + }, + 'key': '404', + 'doc_count': 65 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 6 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 46 + }] + }, + 'key_as_string': '2017-07-25T12:00:00.000+02:00', + 'key': 1500976800000, + 'doc_count': 1387 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 705 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '200', + 'doc_count': 705 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 24 + } + } + }, + 'key': '404', + 'doc_count': 24 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '503', + 'doc_count': 17 + }] + }, + 'key_as_string': '2017-07-25T15:00:00.000+02:00', + 'key': 1500987600000, + 'doc_count': 746 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 200 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 200 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 15 + } + } + }, + 'key': '404', + 'doc_count': 15 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 11 + }] + }, + 'key_as_string': '2017-07-25T18:00:00.000+02:00', + 'key': 1500998400000, + 'doc_count': 226 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 37 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 37 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 3 + } + } + }, + 'key': '404', + 'doc_count': 3 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 2 + }] + }, + 'key_as_string': '2017-07-25T21:00:00.000+02:00', + 'key': 1501009200000, + 'doc_count': 42 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 40 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 40 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '404', + 'doc_count': 1 + }] + }, + 'key_as_string': '2017-07-26T00:00:00.000+02:00', + 'key': 1501020000000, + 'doc_count': 41 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 183 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 183 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 14 + } + } + }, + 'key': '404', + 'doc_count': 14 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 4 + }] + }, + 'key_as_string': '2017-07-26T03:00:00.000+02:00', + 'key': 1501030800000, + 'doc_count': 201 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 662 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 662 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 34 + } + } + }, + 'key': '404', + 'doc_count': 34 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 19 + }] + }, + 'key_as_string': '2017-07-26T06:00:00.000+02:00', + 'key': 1501041600000, + 'doc_count': 715 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 1286 + }, + '404': { + 'doc_count': 3 + } + } + }, + 'key': '200', + 'doc_count': 1286 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 5 + }, + '404': { + 'doc_count': 66 + } + } + }, + 'key': '404', + 'doc_count': 66 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 50 + }] + }, + 'key_as_string': '2017-07-26T09:00:00.000+02:00', + 'key': 1501052400000, + 'doc_count': 1402 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 1272 + }, + '404': { + 'doc_count': 3 + } + } + }, + 'key': '200', + 'doc_count': 1272 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 6 + }, + '404': { + 'doc_count': 73 + } + } + }, + 'key': '404', + 'doc_count': 73 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '503', + 'doc_count': 45 + }] + }, + 'key_as_string': '2017-07-26T12:00:00.000+02:00', + 'key': 1501063200000, + 'doc_count': 1390 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 662 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 662 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 34 + } + } + }, + 'key': '404', + 'doc_count': 34 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 1 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 14 + }] + }, + 'key_as_string': '2017-07-26T15:00:00.000+02:00', + 'key': 1501074000000, + 'doc_count': 710 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 159 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 159 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 12 + } + } + }, + 'key': '404', + 'doc_count': 12 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 1 + }] + }, + 'key_as_string': '2017-07-26T18:00:00.000+02:00', + 'key': 1501084800000, + 'doc_count': 172 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 33 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 33 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 2 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '404', + 'doc_count': 1 + }] + }, + 'key_as_string': '2017-07-26T21:00:00.000+02:00', + 'key': 1501095600000, + 'doc_count': 36 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 33 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 33 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '404', + 'doc_count': 1 + }] + }, + 'key_as_string': '2017-07-27T00:00:00.000+02:00', + 'key': 1501106400000, + 'doc_count': 34 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 159 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '200', + 'doc_count': 159 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 11 + } + } + }, + 'key': '404', + 'doc_count': 11 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 8 + }] + }, + 'key_as_string': '2017-07-27T03:00:00.000+02:00', + 'key': 1501117200000, + 'doc_count': 178 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 676 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '200', + 'doc_count': 676 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 45 + } + } + }, + 'key': '404', + 'doc_count': 45 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 0 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 21 + }] + }, + 'key_as_string': '2017-07-27T06:00:00.000+02:00', + 'key': 1501128000000, + 'doc_count': 742 + }, { + '3': { + 'doc_count_error_upper_bound': 0, + 'sum_other_doc_count': 0, + 'buckets': [{ + '4': { + 'buckets': { + '200': { + 'doc_count': 778 + }, + '404': { + 'doc_count': 1 + } + } + }, + 'key': '200', + 'doc_count': 778 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 42 + } + } + }, + 'key': '404', + 'doc_count': 42 + }, { + '4': { + 'buckets': { + '200': { + 'doc_count': 2 + }, + '404': { + 'doc_count': 0 + } + } + }, + 'key': '503', + 'doc_count': 19 + }] + }, + 'key_as_string': '2017-07-27T09:00:00.000+02:00', + 'key': 1501138800000, + 'doc_count': 839 + }] + } + }, + 'status': 200 +}; + +export default response; diff --git a/src/fixtures/agg_resp/histogram_range_iprange.js b/src/fixtures/agg_resp/histogram_range_iprange.js new file mode 100644 index 0000000000000..d1f09b5bab655 --- /dev/null +++ b/src/fixtures/agg_resp/histogram_range_iprange.js @@ -0,0 +1,1083 @@ +const response = { + 'took': 8, + 'timed_out': false, + '_shards': { + 'total': 1, + 'successful': 1, + 'skipped': 0, + 'failed': 0 + }, + 'hits': { + 'total': 11205, + 'max_score': 0, + 'hits': [] + }, + 'aggregations': { + '2': { + 'buckets': [{ + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 20 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 8 + }] + }, + 'to': 100000, + 'doc_count': 38 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 0, + 'doc_count': 1087 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 21 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 7 + }] + }, + 'to': 100000, + 'doc_count': 36 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 1000, + 'doc_count': 569 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 10 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 5 + }] + }, + 'to': 100000, + 'doc_count': 18 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 11 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 4 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 21 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 2000, + 'doc_count': 1128 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 13 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 10 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 31 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 3000, + 'doc_count': 1092 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 17 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 9 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 35 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 4000, + 'doc_count': 1124 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 19 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 11 + }] + }, + 'from': 200000, + 'doc_count': 37 + } + } + }, + 'key': 5000, + 'doc_count': 1133 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 22 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 15 + }] + }, + 'from': 200000, + 'doc_count': 45 + } + } + }, + 'key': 6000, + 'doc_count': 1150 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 18 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 9 + }] + }, + 'from': 200000, + 'doc_count': 34 + } + } + }, + 'key': 7000, + 'doc_count': 1093 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 23 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 12 + }] + }, + 'from': 200000, + 'doc_count': 43 + } + } + }, + 'key': 8000, + 'doc_count': 1187 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 16 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 11 + }] + }, + 'from': 200000, + 'doc_count': 33 + } + } + }, + 'key': 9000, + 'doc_count': 1091 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 10000, + 'doc_count': 64 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 11000, + 'doc_count': 41 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 12000, + 'doc_count': 63 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 13000, + 'doc_count': 40 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 14000, + 'doc_count': 52 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 15000, + 'doc_count': 53 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 16000, + 'doc_count': 65 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 17000, + 'doc_count': 50 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 18000, + 'doc_count': 50 + }, { + '3': { + 'buckets': { + '*-100000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'to': 100000, + 'doc_count': 0 + }, + '100000.0-200000.0': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 100000, + 'to': 200000, + 'doc_count': 0 + }, + '200000.0-*': { + '4': { + 'buckets': [{ + 'from': '0.0.0.0', + 'to': '127.255.255.255', + 'doc_count': 0 + }, { + 'from': '128.0.0.0', + 'to': '191.255.255.255', + 'doc_count': 0 + }] + }, + 'from': 200000, + 'doc_count': 0 + } + } + }, + 'key': 19000, + 'doc_count': 73 + }] + } + }, + 'status': 200 +}; + +export { response }; diff --git a/src/fixtures/response_handlers/series/filter_date_term.js b/src/fixtures/response_handlers/series/filter_date_term.js new file mode 100644 index 0000000000000..2961579325df8 --- /dev/null +++ b/src/fixtures/response_handlers/series/filter_date_term.js @@ -0,0 +1,847 @@ +const response = { + 'charts': [{ + 'label': 'filters', + 'series': [{ + 'aggId': '1', + 'label': '200', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '200', + 'rawValue': '200' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '200', + 'rawValue': '200' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 40, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 148, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 613, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 1281, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 1276, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 705, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 200, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 37, + 'z': null + }, { + 'x_as_string': 1501020000000, + 'x_raw': 1501020000000, + 'x': 1501020000000, + 'y': 40, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 183, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 662, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 1286, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 1272, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 662, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 159, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 33, + 'z': null + }, { + 'x_as_string': 1501106400000, + 'x_raw': 1501106400000, + 'x': 1501106400000, + 'y': 33, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 159, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 676, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 778, + 'z': null + }] + }, { + 'aggId': '1', + 'label': '404', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '200', + 'rawValue': '200' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '404', + 'rawValue': '404' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 5, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 2, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501020000000, + 'x_raw': 1501020000000, + 'x': 1501020000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 5, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 6, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501106400000, + 'x_raw': 1501106400000, + 'x': 1501106400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 2, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 2, + 'z': null + }] + }, { + 'aggId': '1', + 'label': '503', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '200', + 'rawValue': '200' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '503', + 'rawValue': '503' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 2, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 6, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 2, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 2, + 'z': null + }] + }] + }, { + 'label': 'filters', + 'series': [{ + 'aggId': '1', + 'label': '200', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '404', + 'rawValue': '404' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '200', + 'rawValue': '200' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501020000000, + 'x_raw': 1501020000000, + 'x': 1501020000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501106400000, + 'x_raw': 1501106400000, + 'x': 1501106400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 1, + 'z': null + }] + }, { + 'aggId': '1', + 'label': '404', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '404', + 'rawValue': '404' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '404', + 'rawValue': '404' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 8, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 29, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 83, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 65, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 24, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 15, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 3, + 'z': null + }, { + 'x_as_string': 1501020000000, + 'x_raw': 1501020000000, + 'x': 1501020000000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 14, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 34, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 66, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 73, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 34, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 12, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501106400000, + 'x_raw': 1501106400000, + 'x': 1501106400000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 11, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 45, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 42, + 'z': null + }] + }, { + 'aggId': '1', + 'label': '503', + 'aggs': [{ + 'id': '1', + 'label': 'Count', + 'value': 'y' + }, { + 'id': '4', + 'label': 'filters', + 'value': '404', + 'rawValue': '404' + }, { + 'id': '3', + 'label': 'response.raw: descending', + 'value': '503', + 'rawValue': '503' + }, { + 'id': '2', + 'label': '@timestamp per 2h', + 'value': 'x_as_string' + }], + 'values': [{ + 'x_as_string': 1500933600000, + 'x_raw': 1500933600000, + 'x': 1500933600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500944400000, + 'x_raw': 1500944400000, + 'x': 1500944400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500955200000, + 'x_raw': 1500955200000, + 'x': 1500955200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500966000000, + 'x_raw': 1500966000000, + 'x': 1500966000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500976800000, + 'x_raw': 1500976800000, + 'x': 1500976800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1500987600000, + 'x_raw': 1500987600000, + 'x': 1500987600000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1500998400000, + 'x_raw': 1500998400000, + 'x': 1500998400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501009200000, + 'x_raw': 1501009200000, + 'x': 1501009200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501030800000, + 'x_raw': 1501030800000, + 'x': 1501030800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501041600000, + 'x_raw': 1501041600000, + 'x': 1501041600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501052400000, + 'x_raw': 1501052400000, + 'x': 1501052400000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501063200000, + 'x_raw': 1501063200000, + 'x': 1501063200000, + 'y': 1, + 'z': null + }, { + 'x_as_string': 1501074000000, + 'x_raw': 1501074000000, + 'x': 1501074000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501084800000, + 'x_raw': 1501084800000, + 'x': 1501084800000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501095600000, + 'x_raw': 1501095600000, + 'x': 1501095600000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501117200000, + 'x_raw': 1501117200000, + 'x': 1501117200000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501128000000, + 'x_raw': 1501128000000, + 'x': 1501128000000, + 'y': 0, + 'z': null + }, { + 'x_as_string': 1501138800000, + 'x_raw': 1501138800000, + 'x': 1501138800000, + 'y': 0, + 'z': null + }] + }] + }], + 'split': 'row', + 'hits': 11125 +}; + +export default response; diff --git a/src/fixtures/vislib/mock_data/date_histogram/_columns.js b/src/fixtures/vislib/mock_data/date_histogram/_columns.js index 60166ba592684..a84b4683c3200 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_columns.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_columns.js @@ -1,7 +1,8 @@ import moment from 'moment'; export default { - 'columns': [ + 'split': 'columns', + 'charts': [ { 'label': '200: response', 'xAxisLabel': '@timestamp per 30 sec', diff --git a/src/fixtures/vislib/mock_data/date_histogram/_rows.js b/src/fixtures/vislib/mock_data/date_histogram/_rows.js index b9b6df6c0916a..2849ce7657057 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_rows.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_rows.js @@ -1,7 +1,8 @@ import moment from 'moment'; export default { - 'rows': [ + 'split': 'rows', + 'charts': [ { 'label': '0.0-1000.0: bytes', 'xAxisLabel': '@timestamp per 30 sec', diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series.js b/src/fixtures/vislib/mock_data/date_histogram/_series.js index b26c687c6c86e..cad7fcc7b4668 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series.js @@ -1,151 +1,153 @@ import moment from 'moment'; export default { - 'label': '', - 'xAxisLabel': '@timestamp per 30 sec', - 'ordered': { - 'date': true, - 'min': 1411761457636, - 'max': 1411762357636, - 'interval': 30000 - }, - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': 1411761450000, - 'y': 41 - }, - { - 'x': 1411761480000, - 'y': 18 - }, - { - 'x': 1411761510000, - 'y': 22 - }, - { - 'x': 1411761540000, - 'y': 17 - }, - { - 'x': 1411761570000, - 'y': 17 - }, - { - 'x': 1411761600000, - 'y': 21 - }, - { - 'x': 1411761630000, - 'y': 16 - }, - { - 'x': 1411761660000, - 'y': 17 - }, - { - 'x': 1411761690000, - 'y': 15 - }, - { - 'x': 1411761720000, - 'y': 19 - }, - { - 'x': 1411761750000, - 'y': 11 - }, - { - 'x': 1411761780000, - 'y': 13 - }, - { - 'x': 1411761810000, - 'y': 24 - }, - { - 'x': 1411761840000, - 'y': 20 - }, - { - 'x': 1411761870000, - 'y': 20 - }, - { - 'x': 1411761900000, - 'y': 21 - }, - { - 'x': 1411761930000, - 'y': 17 - }, - { - 'x': 1411761960000, - 'y': 20 - }, - { - 'x': 1411761990000, - 'y': 13 - }, - { - 'x': 1411762020000, - 'y': 14 - }, - { - 'x': 1411762050000, - 'y': 25 - }, - { - 'x': 1411762080000, - 'y': 17 - }, - { - 'x': 1411762110000, - 'y': 14 - }, - { - 'x': 1411762140000, - 'y': 22 - }, - { - 'x': 1411762170000, - 'y': 14 - }, - { - 'x': 1411762200000, - 'y': 19 - }, - { - 'x': 1411762230000, - 'y': 22 - }, - { - 'x': 1411762260000, - 'y': 17 - }, - { - 'x': 1411762290000, - 'y': 8 - }, - { - 'x': 1411762320000, - 'y': 15 - }, - { - 'x': 1411762350000, - 'y': 4 - } - ] + 'charts': [{ + 'label': '', + 'xAxisLabel': '@timestamp per 30 sec', + 'ordered': { + 'date': true, + 'min': 1411761457636, + 'max': 1411762357636, + 'interval': 30000 + }, + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': 1411761450000, + 'y': 41 + }, + { + 'x': 1411761480000, + 'y': 18 + }, + { + 'x': 1411761510000, + 'y': 22 + }, + { + 'x': 1411761540000, + 'y': 17 + }, + { + 'x': 1411761570000, + 'y': 17 + }, + { + 'x': 1411761600000, + 'y': 21 + }, + { + 'x': 1411761630000, + 'y': 16 + }, + { + 'x': 1411761660000, + 'y': 17 + }, + { + 'x': 1411761690000, + 'y': 15 + }, + { + 'x': 1411761720000, + 'y': 19 + }, + { + 'x': 1411761750000, + 'y': 11 + }, + { + 'x': 1411761780000, + 'y': 13 + }, + { + 'x': 1411761810000, + 'y': 24 + }, + { + 'x': 1411761840000, + 'y': 20 + }, + { + 'x': 1411761870000, + 'y': 20 + }, + { + 'x': 1411761900000, + 'y': 21 + }, + { + 'x': 1411761930000, + 'y': 17 + }, + { + 'x': 1411761960000, + 'y': 20 + }, + { + 'x': 1411761990000, + 'y': 13 + }, + { + 'x': 1411762020000, + 'y': 14 + }, + { + 'x': 1411762050000, + 'y': 25 + }, + { + 'x': 1411762080000, + 'y': 17 + }, + { + 'x': 1411762110000, + 'y': 14 + }, + { + 'x': 1411762140000, + 'y': 22 + }, + { + 'x': 1411762170000, + 'y': 14 + }, + { + 'x': 1411762200000, + 'y': 19 + }, + { + 'x': 1411762230000, + 'y': 22 + }, + { + 'x': 1411762260000, + 'y': 17 + }, + { + 'x': 1411762290000, + 'y': 8 + }, + { + 'x': 1411762320000, + 'y': 15 + }, + { + 'x': 1411762350000, + 'y': 4 + } + ] + } + ], + 'xAxisFormatter': function (thing) { + return moment(thing); + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 533, - 'xAxisFormatter': function (thing) { - return moment(thing); - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 533 }; diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js b/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js index 15d08b1b0ac7f..348fecfe05fe8 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js @@ -1,151 +1,153 @@ import moment from 'moment'; export default { - 'label': '', - 'xAxisLabel': '@timestamp per 30 sec', - 'ordered': { - 'date': true, - 'min': 1411761457636, - 'max': 1411762357636, - 'interval': 30000 - }, - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': 1411761450000, - 'y': -41 - }, - { - 'x': 1411761480000, - 'y': -18 - }, - { - 'x': 1411761510000, - 'y': -22 - }, - { - 'x': 1411761540000, - 'y': -17 - }, - { - 'x': 1411761570000, - 'y': -17 - }, - { - 'x': 1411761600000, - 'y': -21 - }, - { - 'x': 1411761630000, - 'y': -16 - }, - { - 'x': 1411761660000, - 'y': -17 - }, - { - 'x': 1411761690000, - 'y': -15 - }, - { - 'x': 1411761720000, - 'y': -19 - }, - { - 'x': 1411761750000, - 'y': -11 - }, - { - 'x': 1411761780000, - 'y': -13 - }, - { - 'x': 1411761810000, - 'y': -24 - }, - { - 'x': 1411761840000, - 'y': -20 - }, - { - 'x': 1411761870000, - 'y': -20 - }, - { - 'x': 1411761900000, - 'y': -21 - }, - { - 'x': 1411761930000, - 'y': -17 - }, - { - 'x': 1411761960000, - 'y': -20 - }, - { - 'x': 1411761990000, - 'y': -13 - }, - { - 'x': 1411762020000, - 'y': -14 - }, - { - 'x': 1411762050000, - 'y': -25 - }, - { - 'x': 1411762080000, - 'y': -17 - }, - { - 'x': 1411762110000, - 'y': -14 - }, - { - 'x': 1411762140000, - 'y': -22 - }, - { - 'x': 1411762170000, - 'y': -14 - }, - { - 'x': 1411762200000, - 'y': -19 - }, - { - 'x': 1411762230000, - 'y': -22 - }, - { - 'x': 1411762260000, - 'y': -17 - }, - { - 'x': 1411762290000, - 'y': -8 - }, - { - 'x': 1411762320000, - 'y': -15 - }, - { - 'x': 1411762350000, - 'y': -4 - } - ] + 'charts': [{ + 'label': '', + 'xAxisLabel': '@timestamp per 30 sec', + 'ordered': { + 'date': true, + 'min': 1411761457636, + 'max': 1411762357636, + 'interval': 30000 + }, + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': 1411761450000, + 'y': -41 + }, + { + 'x': 1411761480000, + 'y': -18 + }, + { + 'x': 1411761510000, + 'y': -22 + }, + { + 'x': 1411761540000, + 'y': -17 + }, + { + 'x': 1411761570000, + 'y': -17 + }, + { + 'x': 1411761600000, + 'y': -21 + }, + { + 'x': 1411761630000, + 'y': -16 + }, + { + 'x': 1411761660000, + 'y': -17 + }, + { + 'x': 1411761690000, + 'y': -15 + }, + { + 'x': 1411761720000, + 'y': -19 + }, + { + 'x': 1411761750000, + 'y': -11 + }, + { + 'x': 1411761780000, + 'y': -13 + }, + { + 'x': 1411761810000, + 'y': -24 + }, + { + 'x': 1411761840000, + 'y': -20 + }, + { + 'x': 1411761870000, + 'y': -20 + }, + { + 'x': 1411761900000, + 'y': -21 + }, + { + 'x': 1411761930000, + 'y': -17 + }, + { + 'x': 1411761960000, + 'y': -20 + }, + { + 'x': 1411761990000, + 'y': -13 + }, + { + 'x': 1411762020000, + 'y': -14 + }, + { + 'x': 1411762050000, + 'y': -25 + }, + { + 'x': 1411762080000, + 'y': -17 + }, + { + 'x': 1411762110000, + 'y': -14 + }, + { + 'x': 1411762140000, + 'y': -22 + }, + { + 'x': 1411762170000, + 'y': -14 + }, + { + 'x': 1411762200000, + 'y': -19 + }, + { + 'x': 1411762230000, + 'y': -22 + }, + { + 'x': 1411762260000, + 'y': -17 + }, + { + 'x': 1411762290000, + 'y': -8 + }, + { + 'x': 1411762320000, + 'y': -15 + }, + { + 'x': 1411762350000, + 'y': -4 + } + ] + } + ], + 'xAxisFormatter': function (thing) { + return moment(thing); + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 533, - 'xAxisFormatter': function (thing) { - return moment(thing); - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 533 }; diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js b/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js index f85bb2b042d6f..0c03928fa92f8 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js @@ -1,151 +1,153 @@ import moment from 'moment'; export default { - 'label': '', - 'xAxisLabel': '@timestamp per 30 sec', - 'ordered': { - 'date': true, - 'min': 1411761457636, - 'max': 1411762357636, - 'interval': 30000 - }, - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': 1411761450000, - 'y': 41 - }, - { - 'x': 1411761480000, - 'y': 18 - }, - { - 'x': 1411761510000, - 'y': -22 - }, - { - 'x': 1411761540000, - 'y': -17 - }, - { - 'x': 1411761570000, - 'y': -17 - }, - { - 'x': 1411761600000, - 'y': -21 - }, - { - 'x': 1411761630000, - 'y': -16 - }, - { - 'x': 1411761660000, - 'y': 17 - }, - { - 'x': 1411761690000, - 'y': 15 - }, - { - 'x': 1411761720000, - 'y': 19 - }, - { - 'x': 1411761750000, - 'y': 11 - }, - { - 'x': 1411761780000, - 'y': -13 - }, - { - 'x': 1411761810000, - 'y': -24 - }, - { - 'x': 1411761840000, - 'y': -20 - }, - { - 'x': 1411761870000, - 'y': -20 - }, - { - 'x': 1411761900000, - 'y': -21 - }, - { - 'x': 1411761930000, - 'y': 17 - }, - { - 'x': 1411761960000, - 'y': 20 - }, - { - 'x': 1411761990000, - 'y': -13 - }, - { - 'x': 1411762020000, - 'y': -14 - }, - { - 'x': 1411762050000, - 'y': 25 - }, - { - 'x': 1411762080000, - 'y': -17 - }, - { - 'x': 1411762110000, - 'y': -14 - }, - { - 'x': 1411762140000, - 'y': -22 - }, - { - 'x': 1411762170000, - 'y': -14 - }, - { - 'x': 1411762200000, - 'y': 19 - }, - { - 'x': 1411762230000, - 'y': 22 - }, - { - 'x': 1411762260000, - 'y': 17 - }, - { - 'x': 1411762290000, - 'y': 8 - }, - { - 'x': 1411762320000, - 'y': -15 - }, - { - 'x': 1411762350000, - 'y': -4 - } - ] + 'charts': [{ + 'label': '', + 'xAxisLabel': '@timestamp per 30 sec', + 'ordered': { + 'date': true, + 'min': 1411761457636, + 'max': 1411762357636, + 'interval': 30000 + }, + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': 1411761450000, + 'y': 41 + }, + { + 'x': 1411761480000, + 'y': 18 + }, + { + 'x': 1411761510000, + 'y': -22 + }, + { + 'x': 1411761540000, + 'y': -17 + }, + { + 'x': 1411761570000, + 'y': -17 + }, + { + 'x': 1411761600000, + 'y': -21 + }, + { + 'x': 1411761630000, + 'y': -16 + }, + { + 'x': 1411761660000, + 'y': 17 + }, + { + 'x': 1411761690000, + 'y': 15 + }, + { + 'x': 1411761720000, + 'y': 19 + }, + { + 'x': 1411761750000, + 'y': 11 + }, + { + 'x': 1411761780000, + 'y': -13 + }, + { + 'x': 1411761810000, + 'y': -24 + }, + { + 'x': 1411761840000, + 'y': -20 + }, + { + 'x': 1411761870000, + 'y': -20 + }, + { + 'x': 1411761900000, + 'y': -21 + }, + { + 'x': 1411761930000, + 'y': 17 + }, + { + 'x': 1411761960000, + 'y': 20 + }, + { + 'x': 1411761990000, + 'y': -13 + }, + { + 'x': 1411762020000, + 'y': -14 + }, + { + 'x': 1411762050000, + 'y': 25 + }, + { + 'x': 1411762080000, + 'y': -17 + }, + { + 'x': 1411762110000, + 'y': -14 + }, + { + 'x': 1411762140000, + 'y': -22 + }, + { + 'x': 1411762170000, + 'y': -14 + }, + { + 'x': 1411762200000, + 'y': 19 + }, + { + 'x': 1411762230000, + 'y': 22 + }, + { + 'x': 1411762260000, + 'y': 17 + }, + { + 'x': 1411762290000, + 'y': 8 + }, + { + 'x': 1411762320000, + 'y': -15 + }, + { + 'x': 1411762350000, + 'y': -4 + } + ] + } + ], + 'xAxisFormatter': function (thing) { + return moment(thing); + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 533, - 'xAxisFormatter': function (thing) { - return moment(thing); - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 533 }; diff --git a/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js b/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js index 8c77336f997b7..50b415cab6d05 100644 --- a/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js +++ b/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js @@ -1,1483 +1,1485 @@ import moment from 'moment'; export default { - 'label': '', - 'xAxisLabel': '@timestamp per 10 min', - 'ordered': { - 'date': true, - 'min': 1413544140087, - 'max': 1413587340087, - 'interval': 600000 - }, - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'html', - 'values': [ - { - 'x': 1413543600000, - 'y': 140 - }, - { - 'x': 1413544200000, - 'y': 1388 - }, - { - 'x': 1413544800000, - 'y': 1308 - }, - { - 'x': 1413545400000, - 'y': 1356 - }, - { - 'x': 1413546000000, - 'y': 1314 - }, - { - 'x': 1413546600000, - 'y': 1343 - }, - { - 'x': 1413547200000, - 'y': 1353 - }, - { - 'x': 1413547800000, - 'y': 1353 - }, - { - 'x': 1413548400000, - 'y': 1334 - }, - { - 'x': 1413549000000, - 'y': 1433 - }, - { - 'x': 1413549600000, - 'y': 1331 - }, - { - 'x': 1413550200000, - 'y': 1349 - }, - { - 'x': 1413550800000, - 'y': 1323 - }, - { - 'x': 1413551400000, - 'y': 1203 - }, - { - 'x': 1413552000000, - 'y': 1231 - }, - { - 'x': 1413552600000, - 'y': 1227 - }, - { - 'x': 1413553200000, - 'y': 1187 - }, - { - 'x': 1413553800000, - 'y': 1119 - }, - { - 'x': 1413554400000, - 'y': 1159 - }, - { - 'x': 1413555000000, - 'y': 1117 - }, - { - 'x': 1413555600000, - 'y': 1152 - }, - { - 'x': 1413556200000, - 'y': 1057 - }, - { - 'x': 1413556800000, - 'y': 1009 - }, - { - 'x': 1413557400000, - 'y': 979 - }, - { - 'x': 1413558000000, - 'y': 975 - }, - { - 'x': 1413558600000, - 'y': 848 - }, - { - 'x': 1413559200000, - 'y': 873 - }, - { - 'x': 1413559800000, - 'y': 808 - }, - { - 'x': 1413560400000, - 'y': 784 - }, - { - 'x': 1413561000000, - 'y': 799 - }, - { - 'x': 1413561600000, - 'y': 684 - }, - { - 'x': 1413562200000, - 'y': 727 - }, - { - 'x': 1413562800000, - 'y': 621 - }, - { - 'x': 1413563400000, - 'y': 615 - }, - { - 'x': 1413564000000, - 'y': 569 - }, - { - 'x': 1413564600000, - 'y': 523 - }, - { - 'x': 1413565200000, - 'y': 474 - }, - { - 'x': 1413565800000, - 'y': 470 - }, - { - 'x': 1413566400000, - 'y': 466 - }, - { - 'x': 1413567000000, - 'y': 394 - }, - { - 'x': 1413567600000, - 'y': 404 - }, - { - 'x': 1413568200000, - 'y': 389 - }, - { - 'x': 1413568800000, - 'y': 312 - }, - { - 'x': 1413569400000, - 'y': 274 - }, - { - 'x': 1413570000000, - 'y': 285 - }, - { - 'x': 1413570600000, - 'y': 299 - }, - { - 'x': 1413571200000, - 'y': 207 - }, - { - 'x': 1413571800000, - 'y': 213 - }, - { - 'x': 1413572400000, - 'y': 119 - }, - { - 'x': 1413573600000, - 'y': 122 - }, - { - 'x': 1413574200000, - 'y': 169 - }, - { - 'x': 1413574800000, - 'y': 151 - }, - { - 'x': 1413575400000, - 'y': 152 - }, - { - 'x': 1413576000000, - 'y': 115 - }, - { - 'x': 1413576600000, - 'y': 117 - }, - { - 'x': 1413577200000, - 'y': 108 - }, - { - 'x': 1413577800000, - 'y': 100 - }, - { - 'x': 1413578400000, - 'y': 78 - }, - { - 'x': 1413579000000, - 'y': 88 - }, - { - 'x': 1413579600000, - 'y': 63 - }, - { - 'x': 1413580200000, - 'y': 58 - }, - { - 'x': 1413580800000, - 'y': 45 - }, - { - 'x': 1413581400000, - 'y': 57 - }, - { - 'x': 1413582000000, - 'y': 34 - }, - { - 'x': 1413582600000, - 'y': 41 - }, - { - 'x': 1413583200000, - 'y': 24 - }, - { - 'x': 1413583800000, - 'y': 27 - }, - { - 'x': 1413584400000, - 'y': 19 - }, - { - 'x': 1413585000000, - 'y': 24 - }, - { - 'x': 1413585600000, - 'y': 18 - }, - { - 'x': 1413586200000, - 'y': 17 - }, - { - 'x': 1413586800000, - 'y': 14 - } - ] + 'charts': [{ + 'label': '', + 'xAxisLabel': '@timestamp per 10 min', + 'ordered': { + 'date': true, + 'min': 1413544140087, + 'max': 1413587340087, + 'interval': 600000 }, - { - 'label': 'php', - 'values': [ - { - 'x': 1413543600000, - 'y': 90 - }, - { - 'x': 1413544200000, - 'y': 949 - }, - { - 'x': 1413544800000, - 'y': 1012 - }, - { - 'x': 1413545400000, - 'y': 1027 - }, - { - 'x': 1413546000000, - 'y': 1073 - }, - { - 'x': 1413546600000, - 'y': 992 - }, - { - 'x': 1413547200000, - 'y': 1005 - }, - { - 'x': 1413547800000, - 'y': 1014 - }, - { - 'x': 1413548400000, - 'y': 987 - }, - { - 'x': 1413549000000, - 'y': 982 - }, - { - 'x': 1413549600000, - 'y': 1086 - }, - { - 'x': 1413550200000, - 'y': 998 - }, - { - 'x': 1413550800000, - 'y': 935 - }, - { - 'x': 1413551400000, - 'y': 995 - }, - { - 'x': 1413552000000, - 'y': 926 - }, - { - 'x': 1413552600000, - 'y': 897 - }, - { - 'x': 1413553200000, - 'y': 873 - }, - { - 'x': 1413553800000, - 'y': 885 - }, - { - 'x': 1413554400000, - 'y': 859 - }, - { - 'x': 1413555000000, - 'y': 852 - }, - { - 'x': 1413555600000, - 'y': 779 - }, - { - 'x': 1413556200000, - 'y': 739 - }, - { - 'x': 1413556800000, - 'y': 783 - }, - { - 'x': 1413557400000, - 'y': 784 - }, - { - 'x': 1413558000000, - 'y': 687 - }, - { - 'x': 1413558600000, - 'y': 660 - }, - { - 'x': 1413559200000, - 'y': 672 - }, - { - 'x': 1413559800000, - 'y': 600 - }, - { - 'x': 1413560400000, - 'y': 659 - }, - { - 'x': 1413561000000, - 'y': 540 - }, - { - 'x': 1413561600000, - 'y': 539 - }, - { - 'x': 1413562200000, - 'y': 481 - }, - { - 'x': 1413562800000, - 'y': 498 - }, - { - 'x': 1413563400000, - 'y': 444 - }, - { - 'x': 1413564000000, - 'y': 452 - }, - { - 'x': 1413564600000, - 'y': 408 - }, - { - 'x': 1413565200000, - 'y': 358 - }, - { - 'x': 1413565800000, - 'y': 321 - }, - { - 'x': 1413566400000, - 'y': 305 - }, - { - 'x': 1413567000000, - 'y': 292 - }, - { - 'x': 1413567600000, - 'y': 289 - }, - { - 'x': 1413568200000, - 'y': 239 - }, - { - 'x': 1413568800000, - 'y': 256 - }, - { - 'x': 1413569400000, - 'y': 220 - }, - { - 'x': 1413570000000, - 'y': 205 - }, - { - 'x': 1413570600000, - 'y': 201 - }, - { - 'x': 1413571200000, - 'y': 183 - }, - { - 'x': 1413571800000, - 'y': 172 - }, - { - 'x': 1413572400000, - 'y': 73 - }, - { - 'x': 1413573600000, - 'y': 90 - }, - { - 'x': 1413574200000, - 'y': 130 - }, - { - 'x': 1413574800000, - 'y': 104 - }, - { - 'x': 1413575400000, - 'y': 108 - }, - { - 'x': 1413576000000, - 'y': 92 - }, - { - 'x': 1413576600000, - 'y': 79 - }, - { - 'x': 1413577200000, - 'y': 90 - }, - { - 'x': 1413577800000, - 'y': 72 - }, - { - 'x': 1413578400000, - 'y': 68 - }, - { - 'x': 1413579000000, - 'y': 52 - }, - { - 'x': 1413579600000, - 'y': 60 - }, - { - 'x': 1413580200000, - 'y': 51 - }, - { - 'x': 1413580800000, - 'y': 32 - }, - { - 'x': 1413581400000, - 'y': 37 - }, - { - 'x': 1413582000000, - 'y': 30 - }, - { - 'x': 1413582600000, - 'y': 29 - }, - { - 'x': 1413583200000, - 'y': 24 - }, - { - 'x': 1413583800000, - 'y': 16 - }, - { - 'x': 1413584400000, - 'y': 15 - }, - { - 'x': 1413585000000, - 'y': 15 - }, - { - 'x': 1413585600000, - 'y': 10 - }, - { - 'x': 1413586200000, - 'y': 9 - }, - { - 'x': 1413586800000, - 'y': 9 - } - ] + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'html', + 'values': [ + { + 'x': 1413543600000, + 'y': 140 + }, + { + 'x': 1413544200000, + 'y': 1388 + }, + { + 'x': 1413544800000, + 'y': 1308 + }, + { + 'x': 1413545400000, + 'y': 1356 + }, + { + 'x': 1413546000000, + 'y': 1314 + }, + { + 'x': 1413546600000, + 'y': 1343 + }, + { + 'x': 1413547200000, + 'y': 1353 + }, + { + 'x': 1413547800000, + 'y': 1353 + }, + { + 'x': 1413548400000, + 'y': 1334 + }, + { + 'x': 1413549000000, + 'y': 1433 + }, + { + 'x': 1413549600000, + 'y': 1331 + }, + { + 'x': 1413550200000, + 'y': 1349 + }, + { + 'x': 1413550800000, + 'y': 1323 + }, + { + 'x': 1413551400000, + 'y': 1203 + }, + { + 'x': 1413552000000, + 'y': 1231 + }, + { + 'x': 1413552600000, + 'y': 1227 + }, + { + 'x': 1413553200000, + 'y': 1187 + }, + { + 'x': 1413553800000, + 'y': 1119 + }, + { + 'x': 1413554400000, + 'y': 1159 + }, + { + 'x': 1413555000000, + 'y': 1117 + }, + { + 'x': 1413555600000, + 'y': 1152 + }, + { + 'x': 1413556200000, + 'y': 1057 + }, + { + 'x': 1413556800000, + 'y': 1009 + }, + { + 'x': 1413557400000, + 'y': 979 + }, + { + 'x': 1413558000000, + 'y': 975 + }, + { + 'x': 1413558600000, + 'y': 848 + }, + { + 'x': 1413559200000, + 'y': 873 + }, + { + 'x': 1413559800000, + 'y': 808 + }, + { + 'x': 1413560400000, + 'y': 784 + }, + { + 'x': 1413561000000, + 'y': 799 + }, + { + 'x': 1413561600000, + 'y': 684 + }, + { + 'x': 1413562200000, + 'y': 727 + }, + { + 'x': 1413562800000, + 'y': 621 + }, + { + 'x': 1413563400000, + 'y': 615 + }, + { + 'x': 1413564000000, + 'y': 569 + }, + { + 'x': 1413564600000, + 'y': 523 + }, + { + 'x': 1413565200000, + 'y': 474 + }, + { + 'x': 1413565800000, + 'y': 470 + }, + { + 'x': 1413566400000, + 'y': 466 + }, + { + 'x': 1413567000000, + 'y': 394 + }, + { + 'x': 1413567600000, + 'y': 404 + }, + { + 'x': 1413568200000, + 'y': 389 + }, + { + 'x': 1413568800000, + 'y': 312 + }, + { + 'x': 1413569400000, + 'y': 274 + }, + { + 'x': 1413570000000, + 'y': 285 + }, + { + 'x': 1413570600000, + 'y': 299 + }, + { + 'x': 1413571200000, + 'y': 207 + }, + { + 'x': 1413571800000, + 'y': 213 + }, + { + 'x': 1413572400000, + 'y': 119 + }, + { + 'x': 1413573600000, + 'y': 122 + }, + { + 'x': 1413574200000, + 'y': 169 + }, + { + 'x': 1413574800000, + 'y': 151 + }, + { + 'x': 1413575400000, + 'y': 152 + }, + { + 'x': 1413576000000, + 'y': 115 + }, + { + 'x': 1413576600000, + 'y': 117 + }, + { + 'x': 1413577200000, + 'y': 108 + }, + { + 'x': 1413577800000, + 'y': 100 + }, + { + 'x': 1413578400000, + 'y': 78 + }, + { + 'x': 1413579000000, + 'y': 88 + }, + { + 'x': 1413579600000, + 'y': 63 + }, + { + 'x': 1413580200000, + 'y': 58 + }, + { + 'x': 1413580800000, + 'y': 45 + }, + { + 'x': 1413581400000, + 'y': 57 + }, + { + 'x': 1413582000000, + 'y': 34 + }, + { + 'x': 1413582600000, + 'y': 41 + }, + { + 'x': 1413583200000, + 'y': 24 + }, + { + 'x': 1413583800000, + 'y': 27 + }, + { + 'x': 1413584400000, + 'y': 19 + }, + { + 'x': 1413585000000, + 'y': 24 + }, + { + 'x': 1413585600000, + 'y': 18 + }, + { + 'x': 1413586200000, + 'y': 17 + }, + { + 'x': 1413586800000, + 'y': 14 + } + ] + }, + { + 'label': 'php', + 'values': [ + { + 'x': 1413543600000, + 'y': 90 + }, + { + 'x': 1413544200000, + 'y': 949 + }, + { + 'x': 1413544800000, + 'y': 1012 + }, + { + 'x': 1413545400000, + 'y': 1027 + }, + { + 'x': 1413546000000, + 'y': 1073 + }, + { + 'x': 1413546600000, + 'y': 992 + }, + { + 'x': 1413547200000, + 'y': 1005 + }, + { + 'x': 1413547800000, + 'y': 1014 + }, + { + 'x': 1413548400000, + 'y': 987 + }, + { + 'x': 1413549000000, + 'y': 982 + }, + { + 'x': 1413549600000, + 'y': 1086 + }, + { + 'x': 1413550200000, + 'y': 998 + }, + { + 'x': 1413550800000, + 'y': 935 + }, + { + 'x': 1413551400000, + 'y': 995 + }, + { + 'x': 1413552000000, + 'y': 926 + }, + { + 'x': 1413552600000, + 'y': 897 + }, + { + 'x': 1413553200000, + 'y': 873 + }, + { + 'x': 1413553800000, + 'y': 885 + }, + { + 'x': 1413554400000, + 'y': 859 + }, + { + 'x': 1413555000000, + 'y': 852 + }, + { + 'x': 1413555600000, + 'y': 779 + }, + { + 'x': 1413556200000, + 'y': 739 + }, + { + 'x': 1413556800000, + 'y': 783 + }, + { + 'x': 1413557400000, + 'y': 784 + }, + { + 'x': 1413558000000, + 'y': 687 + }, + { + 'x': 1413558600000, + 'y': 660 + }, + { + 'x': 1413559200000, + 'y': 672 + }, + { + 'x': 1413559800000, + 'y': 600 + }, + { + 'x': 1413560400000, + 'y': 659 + }, + { + 'x': 1413561000000, + 'y': 540 + }, + { + 'x': 1413561600000, + 'y': 539 + }, + { + 'x': 1413562200000, + 'y': 481 + }, + { + 'x': 1413562800000, + 'y': 498 + }, + { + 'x': 1413563400000, + 'y': 444 + }, + { + 'x': 1413564000000, + 'y': 452 + }, + { + 'x': 1413564600000, + 'y': 408 + }, + { + 'x': 1413565200000, + 'y': 358 + }, + { + 'x': 1413565800000, + 'y': 321 + }, + { + 'x': 1413566400000, + 'y': 305 + }, + { + 'x': 1413567000000, + 'y': 292 + }, + { + 'x': 1413567600000, + 'y': 289 + }, + { + 'x': 1413568200000, + 'y': 239 + }, + { + 'x': 1413568800000, + 'y': 256 + }, + { + 'x': 1413569400000, + 'y': 220 + }, + { + 'x': 1413570000000, + 'y': 205 + }, + { + 'x': 1413570600000, + 'y': 201 + }, + { + 'x': 1413571200000, + 'y': 183 + }, + { + 'x': 1413571800000, + 'y': 172 + }, + { + 'x': 1413572400000, + 'y': 73 + }, + { + 'x': 1413573600000, + 'y': 90 + }, + { + 'x': 1413574200000, + 'y': 130 + }, + { + 'x': 1413574800000, + 'y': 104 + }, + { + 'x': 1413575400000, + 'y': 108 + }, + { + 'x': 1413576000000, + 'y': 92 + }, + { + 'x': 1413576600000, + 'y': 79 + }, + { + 'x': 1413577200000, + 'y': 90 + }, + { + 'x': 1413577800000, + 'y': 72 + }, + { + 'x': 1413578400000, + 'y': 68 + }, + { + 'x': 1413579000000, + 'y': 52 + }, + { + 'x': 1413579600000, + 'y': 60 + }, + { + 'x': 1413580200000, + 'y': 51 + }, + { + 'x': 1413580800000, + 'y': 32 + }, + { + 'x': 1413581400000, + 'y': 37 + }, + { + 'x': 1413582000000, + 'y': 30 + }, + { + 'x': 1413582600000, + 'y': 29 + }, + { + 'x': 1413583200000, + 'y': 24 + }, + { + 'x': 1413583800000, + 'y': 16 + }, + { + 'x': 1413584400000, + 'y': 15 + }, + { + 'x': 1413585000000, + 'y': 15 + }, + { + 'x': 1413585600000, + 'y': 10 + }, + { + 'x': 1413586200000, + 'y': 9 + }, + { + 'x': 1413586800000, + 'y': 9 + } + ] + }, + { + 'label': 'png', + 'values': [ + { + 'x': 1413543600000, + 'y': 44 + }, + { + 'x': 1413544200000, + 'y': 495 + }, + { + 'x': 1413544800000, + 'y': 489 + }, + { + 'x': 1413545400000, + 'y': 492 + }, + { + 'x': 1413546000000, + 'y': 556 + }, + { + 'x': 1413546600000, + 'y': 536 + }, + { + 'x': 1413547200000, + 'y': 511 + }, + { + 'x': 1413547800000, + 'y': 479 + }, + { + 'x': 1413548400000, + 'y': 544 + }, + { + 'x': 1413549000000, + 'y': 513 + }, + { + 'x': 1413549600000, + 'y': 501 + }, + { + 'x': 1413550200000, + 'y': 532 + }, + { + 'x': 1413550800000, + 'y': 440 + }, + { + 'x': 1413551400000, + 'y': 455 + }, + { + 'x': 1413552000000, + 'y': 455 + }, + { + 'x': 1413552600000, + 'y': 471 + }, + { + 'x': 1413553200000, + 'y': 428 + }, + { + 'x': 1413553800000, + 'y': 457 + }, + { + 'x': 1413554400000, + 'y': 450 + }, + { + 'x': 1413555000000, + 'y': 418 + }, + { + 'x': 1413555600000, + 'y': 398 + }, + { + 'x': 1413556200000, + 'y': 397 + }, + { + 'x': 1413556800000, + 'y': 359 + }, + { + 'x': 1413557400000, + 'y': 398 + }, + { + 'x': 1413558000000, + 'y': 339 + }, + { + 'x': 1413558600000, + 'y': 363 + }, + { + 'x': 1413559200000, + 'y': 297 + }, + { + 'x': 1413559800000, + 'y': 323 + }, + { + 'x': 1413560400000, + 'y': 302 + }, + { + 'x': 1413561000000, + 'y': 260 + }, + { + 'x': 1413561600000, + 'y': 276 + }, + { + 'x': 1413562200000, + 'y': 249 + }, + { + 'x': 1413562800000, + 'y': 248 + }, + { + 'x': 1413563400000, + 'y': 235 + }, + { + 'x': 1413564000000, + 'y': 234 + }, + { + 'x': 1413564600000, + 'y': 188 + }, + { + 'x': 1413565200000, + 'y': 192 + }, + { + 'x': 1413565800000, + 'y': 173 + }, + { + 'x': 1413566400000, + 'y': 160 + }, + { + 'x': 1413567000000, + 'y': 137 + }, + { + 'x': 1413567600000, + 'y': 158 + }, + { + 'x': 1413568200000, + 'y': 111 + }, + { + 'x': 1413568800000, + 'y': 145 + }, + { + 'x': 1413569400000, + 'y': 118 + }, + { + 'x': 1413570000000, + 'y': 104 + }, + { + 'x': 1413570600000, + 'y': 80 + }, + { + 'x': 1413571200000, + 'y': 79 + }, + { + 'x': 1413571800000, + 'y': 86 + }, + { + 'x': 1413572400000, + 'y': 47 + }, + { + 'x': 1413573600000, + 'y': 49 + }, + { + 'x': 1413574200000, + 'y': 68 + }, + { + 'x': 1413574800000, + 'y': 78 + }, + { + 'x': 1413575400000, + 'y': 77 + }, + { + 'x': 1413576000000, + 'y': 50 + }, + { + 'x': 1413576600000, + 'y': 51 + }, + { + 'x': 1413577200000, + 'y': 40 + }, + { + 'x': 1413577800000, + 'y': 42 + }, + { + 'x': 1413578400000, + 'y': 29 + }, + { + 'x': 1413579000000, + 'y': 24 + }, + { + 'x': 1413579600000, + 'y': 30 + }, + { + 'x': 1413580200000, + 'y': 18 + }, + { + 'x': 1413580800000, + 'y': 15 + }, + { + 'x': 1413581400000, + 'y': 19 + }, + { + 'x': 1413582000000, + 'y': 18 + }, + { + 'x': 1413582600000, + 'y': 13 + }, + { + 'x': 1413583200000, + 'y': 11 + }, + { + 'x': 1413583800000, + 'y': 11 + }, + { + 'x': 1413584400000, + 'y': 13 + }, + { + 'x': 1413585000000, + 'y': 9 + }, + { + 'x': 1413585600000, + 'y': 9 + }, + { + 'x': 1413586200000, + 'y': 9 + }, + { + 'x': 1413586800000, + 'y': 3 + } + ] + }, + { + 'label': 'css', + 'values': [ + { + 'x': 1413543600000, + 'y': 35 + }, + { + 'x': 1413544200000, + 'y': 360 + }, + { + 'x': 1413544800000, + 'y': 343 + }, + { + 'x': 1413545400000, + 'y': 329 + }, + { + 'x': 1413546000000, + 'y': 345 + }, + { + 'x': 1413546600000, + 'y': 336 + }, + { + 'x': 1413547200000, + 'y': 330 + }, + { + 'x': 1413547800000, + 'y': 334 + }, + { + 'x': 1413548400000, + 'y': 326 + }, + { + 'x': 1413549000000, + 'y': 351 + }, + { + 'x': 1413549600000, + 'y': 334 + }, + { + 'x': 1413550200000, + 'y': 351 + }, + { + 'x': 1413550800000, + 'y': 337 + }, + { + 'x': 1413551400000, + 'y': 306 + }, + { + 'x': 1413552000000, + 'y': 346 + }, + { + 'x': 1413552600000, + 'y': 317 + }, + { + 'x': 1413553200000, + 'y': 298 + }, + { + 'x': 1413553800000, + 'y': 288 + }, + { + 'x': 1413554400000, + 'y': 283 + }, + { + 'x': 1413555000000, + 'y': 262 + }, + { + 'x': 1413555600000, + 'y': 245 + }, + { + 'x': 1413556200000, + 'y': 259 + }, + { + 'x': 1413556800000, + 'y': 267 + }, + { + 'x': 1413557400000, + 'y': 230 + }, + { + 'x': 1413558000000, + 'y': 218 + }, + { + 'x': 1413558600000, + 'y': 241 + }, + { + 'x': 1413559200000, + 'y': 213 + }, + { + 'x': 1413559800000, + 'y': 239 + }, + { + 'x': 1413560400000, + 'y': 208 + }, + { + 'x': 1413561000000, + 'y': 187 + }, + { + 'x': 1413561600000, + 'y': 166 + }, + { + 'x': 1413562200000, + 'y': 154 + }, + { + 'x': 1413562800000, + 'y': 184 + }, + { + 'x': 1413563400000, + 'y': 148 + }, + { + 'x': 1413564000000, + 'y': 153 + }, + { + 'x': 1413564600000, + 'y': 149 + }, + { + 'x': 1413565200000, + 'y': 102 + }, + { + 'x': 1413565800000, + 'y': 110 + }, + { + 'x': 1413566400000, + 'y': 121 + }, + { + 'x': 1413567000000, + 'y': 120 + }, + { + 'x': 1413567600000, + 'y': 86 + }, + { + 'x': 1413568200000, + 'y': 96 + }, + { + 'x': 1413568800000, + 'y': 71 + }, + { + 'x': 1413569400000, + 'y': 92 + }, + { + 'x': 1413570000000, + 'y': 65 + }, + { + 'x': 1413570600000, + 'y': 54 + }, + { + 'x': 1413571200000, + 'y': 68 + }, + { + 'x': 1413571800000, + 'y': 57 + }, + { + 'x': 1413572400000, + 'y': 33 + }, + { + 'x': 1413573600000, + 'y': 47 + }, + { + 'x': 1413574200000, + 'y': 42 + }, + { + 'x': 1413574800000, + 'y': 39 + }, + { + 'x': 1413575400000, + 'y': 25 + }, + { + 'x': 1413576000000, + 'y': 31 + }, + { + 'x': 1413576600000, + 'y': 37 + }, + { + 'x': 1413577200000, + 'y': 35 + }, + { + 'x': 1413577800000, + 'y': 19 + }, + { + 'x': 1413578400000, + 'y': 15 + }, + { + 'x': 1413579000000, + 'y': 21 + }, + { + 'x': 1413579600000, + 'y': 16 + }, + { + 'x': 1413580200000, + 'y': 18 + }, + { + 'x': 1413580800000, + 'y': 10 + }, + { + 'x': 1413581400000, + 'y': 13 + }, + { + 'x': 1413582000000, + 'y': 14 + }, + { + 'x': 1413582600000, + 'y': 11 + }, + { + 'x': 1413583200000, + 'y': 4 + }, + { + 'x': 1413583800000, + 'y': 6 + }, + { + 'x': 1413584400000, + 'y': 3 + }, + { + 'x': 1413585000000, + 'y': 6 + }, + { + 'x': 1413585600000, + 'y': 6 + }, + { + 'x': 1413586200000, + 'y': 2 + }, + { + 'x': 1413586800000, + 'y': 3 + } + ] + }, + { + 'label': 'gif', + 'values': [ + { + 'x': 1413543600000, + 'y': 21 + }, + { + 'x': 1413544200000, + 'y': 191 + }, + { + 'x': 1413544800000, + 'y': 176 + }, + { + 'x': 1413545400000, + 'y': 166 + }, + { + 'x': 1413546000000, + 'y': 183 + }, + { + 'x': 1413546600000, + 'y': 170 + }, + { + 'x': 1413547200000, + 'y': 153 + }, + { + 'x': 1413547800000, + 'y': 202 + }, + { + 'x': 1413548400000, + 'y': 175 + }, + { + 'x': 1413549000000, + 'y': 161 + }, + { + 'x': 1413549600000, + 'y': 174 + }, + { + 'x': 1413550200000, + 'y': 167 + }, + { + 'x': 1413550800000, + 'y': 171 + }, + { + 'x': 1413551400000, + 'y': 176 + }, + { + 'x': 1413552000000, + 'y': 139 + }, + { + 'x': 1413552600000, + 'y': 145 + }, + { + 'x': 1413553200000, + 'y': 157 + }, + { + 'x': 1413553800000, + 'y': 148 + }, + { + 'x': 1413554400000, + 'y': 149 + }, + { + 'x': 1413555000000, + 'y': 135 + }, + { + 'x': 1413555600000, + 'y': 118 + }, + { + 'x': 1413556200000, + 'y': 142 + }, + { + 'x': 1413556800000, + 'y': 141 + }, + { + 'x': 1413557400000, + 'y': 146 + }, + { + 'x': 1413558000000, + 'y': 114 + }, + { + 'x': 1413558600000, + 'y': 115 + }, + { + 'x': 1413559200000, + 'y': 136 + }, + { + 'x': 1413559800000, + 'y': 106 + }, + { + 'x': 1413560400000, + 'y': 92 + }, + { + 'x': 1413561000000, + 'y': 97 + }, + { + 'x': 1413561600000, + 'y': 90 + }, + { + 'x': 1413562200000, + 'y': 69 + }, + { + 'x': 1413562800000, + 'y': 66 + }, + { + 'x': 1413563400000, + 'y': 93 + }, + { + 'x': 1413564000000, + 'y': 75 + }, + { + 'x': 1413564600000, + 'y': 68 + }, + { + 'x': 1413565200000, + 'y': 55 + }, + { + 'x': 1413565800000, + 'y': 73 + }, + { + 'x': 1413566400000, + 'y': 57 + }, + { + 'x': 1413567000000, + 'y': 48 + }, + { + 'x': 1413567600000, + 'y': 41 + }, + { + 'x': 1413568200000, + 'y': 39 + }, + { + 'x': 1413568800000, + 'y': 32 + }, + { + 'x': 1413569400000, + 'y': 33 + }, + { + 'x': 1413570000000, + 'y': 39 + }, + { + 'x': 1413570600000, + 'y': 35 + }, + { + 'x': 1413571200000, + 'y': 25 + }, + { + 'x': 1413571800000, + 'y': 28 + }, + { + 'x': 1413572400000, + 'y': 8 + }, + { + 'x': 1413573600000, + 'y': 13 + }, + { + 'x': 1413574200000, + 'y': 23 + }, + { + 'x': 1413574800000, + 'y': 19 + }, + { + 'x': 1413575400000, + 'y': 16 + }, + { + 'x': 1413576000000, + 'y': 22 + }, + { + 'x': 1413576600000, + 'y': 13 + }, + { + 'x': 1413577200000, + 'y': 21 + }, + { + 'x': 1413577800000, + 'y': 11 + }, + { + 'x': 1413578400000, + 'y': 12 + }, + { + 'x': 1413579000000, + 'y': 10 + }, + { + 'x': 1413579600000, + 'y': 7 + }, + { + 'x': 1413580200000, + 'y': 4 + }, + { + 'x': 1413580800000, + 'y': 5 + }, + { + 'x': 1413581400000, + 'y': 7 + }, + { + 'x': 1413582000000, + 'y': 9 + }, + { + 'x': 1413582600000, + 'y': 2 + }, + { + 'x': 1413583200000, + 'y': 2 + }, + { + 'x': 1413583800000, + 'y': 4 + }, + { + 'x': 1413584400000, + 'y': 6 + }, + { + 'x': 1413585600000, + 'y': 2 + }, + { + 'x': 1413586200000, + 'y': 4 + }, + { + 'x': 1413586800000, + 'y': 4 + } + ] + } + ], + 'xAxisFormatter': function (thing) { + return moment(thing); }, - { - 'label': 'png', - 'values': [ - { - 'x': 1413543600000, - 'y': 44 - }, - { - 'x': 1413544200000, - 'y': 495 - }, - { - 'x': 1413544800000, - 'y': 489 - }, - { - 'x': 1413545400000, - 'y': 492 - }, - { - 'x': 1413546000000, - 'y': 556 - }, - { - 'x': 1413546600000, - 'y': 536 - }, - { - 'x': 1413547200000, - 'y': 511 - }, - { - 'x': 1413547800000, - 'y': 479 - }, - { - 'x': 1413548400000, - 'y': 544 - }, - { - 'x': 1413549000000, - 'y': 513 - }, - { - 'x': 1413549600000, - 'y': 501 - }, - { - 'x': 1413550200000, - 'y': 532 - }, - { - 'x': 1413550800000, - 'y': 440 - }, - { - 'x': 1413551400000, - 'y': 455 - }, - { - 'x': 1413552000000, - 'y': 455 - }, - { - 'x': 1413552600000, - 'y': 471 - }, - { - 'x': 1413553200000, - 'y': 428 - }, - { - 'x': 1413553800000, - 'y': 457 - }, - { - 'x': 1413554400000, - 'y': 450 - }, - { - 'x': 1413555000000, - 'y': 418 - }, - { - 'x': 1413555600000, - 'y': 398 - }, - { - 'x': 1413556200000, - 'y': 397 - }, - { - 'x': 1413556800000, - 'y': 359 - }, - { - 'x': 1413557400000, - 'y': 398 - }, - { - 'x': 1413558000000, - 'y': 339 - }, - { - 'x': 1413558600000, - 'y': 363 - }, - { - 'x': 1413559200000, - 'y': 297 - }, - { - 'x': 1413559800000, - 'y': 323 - }, - { - 'x': 1413560400000, - 'y': 302 - }, - { - 'x': 1413561000000, - 'y': 260 - }, - { - 'x': 1413561600000, - 'y': 276 - }, - { - 'x': 1413562200000, - 'y': 249 - }, - { - 'x': 1413562800000, - 'y': 248 - }, - { - 'x': 1413563400000, - 'y': 235 - }, - { - 'x': 1413564000000, - 'y': 234 - }, - { - 'x': 1413564600000, - 'y': 188 - }, - { - 'x': 1413565200000, - 'y': 192 - }, - { - 'x': 1413565800000, - 'y': 173 - }, - { - 'x': 1413566400000, - 'y': 160 - }, - { - 'x': 1413567000000, - 'y': 137 - }, - { - 'x': 1413567600000, - 'y': 158 - }, - { - 'x': 1413568200000, - 'y': 111 - }, - { - 'x': 1413568800000, - 'y': 145 - }, - { - 'x': 1413569400000, - 'y': 118 - }, - { - 'x': 1413570000000, - 'y': 104 - }, - { - 'x': 1413570600000, - 'y': 80 - }, - { - 'x': 1413571200000, - 'y': 79 - }, - { - 'x': 1413571800000, - 'y': 86 - }, - { - 'x': 1413572400000, - 'y': 47 - }, - { - 'x': 1413573600000, - 'y': 49 - }, - { - 'x': 1413574200000, - 'y': 68 - }, - { - 'x': 1413574800000, - 'y': 78 - }, - { - 'x': 1413575400000, - 'y': 77 - }, - { - 'x': 1413576000000, - 'y': 50 - }, - { - 'x': 1413576600000, - 'y': 51 - }, - { - 'x': 1413577200000, - 'y': 40 - }, - { - 'x': 1413577800000, - 'y': 42 - }, - { - 'x': 1413578400000, - 'y': 29 - }, - { - 'x': 1413579000000, - 'y': 24 - }, - { - 'x': 1413579600000, - 'y': 30 - }, - { - 'x': 1413580200000, - 'y': 18 - }, - { - 'x': 1413580800000, - 'y': 15 - }, - { - 'x': 1413581400000, - 'y': 19 - }, - { - 'x': 1413582000000, - 'y': 18 - }, - { - 'x': 1413582600000, - 'y': 13 - }, - { - 'x': 1413583200000, - 'y': 11 - }, - { - 'x': 1413583800000, - 'y': 11 - }, - { - 'x': 1413584400000, - 'y': 13 - }, - { - 'x': 1413585000000, - 'y': 9 - }, - { - 'x': 1413585600000, - 'y': 9 - }, - { - 'x': 1413586200000, - 'y': 9 - }, - { - 'x': 1413586800000, - 'y': 3 - } - ] - }, - { - 'label': 'css', - 'values': [ - { - 'x': 1413543600000, - 'y': 35 - }, - { - 'x': 1413544200000, - 'y': 360 - }, - { - 'x': 1413544800000, - 'y': 343 - }, - { - 'x': 1413545400000, - 'y': 329 - }, - { - 'x': 1413546000000, - 'y': 345 - }, - { - 'x': 1413546600000, - 'y': 336 - }, - { - 'x': 1413547200000, - 'y': 330 - }, - { - 'x': 1413547800000, - 'y': 334 - }, - { - 'x': 1413548400000, - 'y': 326 - }, - { - 'x': 1413549000000, - 'y': 351 - }, - { - 'x': 1413549600000, - 'y': 334 - }, - { - 'x': 1413550200000, - 'y': 351 - }, - { - 'x': 1413550800000, - 'y': 337 - }, - { - 'x': 1413551400000, - 'y': 306 - }, - { - 'x': 1413552000000, - 'y': 346 - }, - { - 'x': 1413552600000, - 'y': 317 - }, - { - 'x': 1413553200000, - 'y': 298 - }, - { - 'x': 1413553800000, - 'y': 288 - }, - { - 'x': 1413554400000, - 'y': 283 - }, - { - 'x': 1413555000000, - 'y': 262 - }, - { - 'x': 1413555600000, - 'y': 245 - }, - { - 'x': 1413556200000, - 'y': 259 - }, - { - 'x': 1413556800000, - 'y': 267 - }, - { - 'x': 1413557400000, - 'y': 230 - }, - { - 'x': 1413558000000, - 'y': 218 - }, - { - 'x': 1413558600000, - 'y': 241 - }, - { - 'x': 1413559200000, - 'y': 213 - }, - { - 'x': 1413559800000, - 'y': 239 - }, - { - 'x': 1413560400000, - 'y': 208 - }, - { - 'x': 1413561000000, - 'y': 187 - }, - { - 'x': 1413561600000, - 'y': 166 - }, - { - 'x': 1413562200000, - 'y': 154 - }, - { - 'x': 1413562800000, - 'y': 184 - }, - { - 'x': 1413563400000, - 'y': 148 - }, - { - 'x': 1413564000000, - 'y': 153 - }, - { - 'x': 1413564600000, - 'y': 149 - }, - { - 'x': 1413565200000, - 'y': 102 - }, - { - 'x': 1413565800000, - 'y': 110 - }, - { - 'x': 1413566400000, - 'y': 121 - }, - { - 'x': 1413567000000, - 'y': 120 - }, - { - 'x': 1413567600000, - 'y': 86 - }, - { - 'x': 1413568200000, - 'y': 96 - }, - { - 'x': 1413568800000, - 'y': 71 - }, - { - 'x': 1413569400000, - 'y': 92 - }, - { - 'x': 1413570000000, - 'y': 65 - }, - { - 'x': 1413570600000, - 'y': 54 - }, - { - 'x': 1413571200000, - 'y': 68 - }, - { - 'x': 1413571800000, - 'y': 57 - }, - { - 'x': 1413572400000, - 'y': 33 - }, - { - 'x': 1413573600000, - 'y': 47 - }, - { - 'x': 1413574200000, - 'y': 42 - }, - { - 'x': 1413574800000, - 'y': 39 - }, - { - 'x': 1413575400000, - 'y': 25 - }, - { - 'x': 1413576000000, - 'y': 31 - }, - { - 'x': 1413576600000, - 'y': 37 - }, - { - 'x': 1413577200000, - 'y': 35 - }, - { - 'x': 1413577800000, - 'y': 19 - }, - { - 'x': 1413578400000, - 'y': 15 - }, - { - 'x': 1413579000000, - 'y': 21 - }, - { - 'x': 1413579600000, - 'y': 16 - }, - { - 'x': 1413580200000, - 'y': 18 - }, - { - 'x': 1413580800000, - 'y': 10 - }, - { - 'x': 1413581400000, - 'y': 13 - }, - { - 'x': 1413582000000, - 'y': 14 - }, - { - 'x': 1413582600000, - 'y': 11 - }, - { - 'x': 1413583200000, - 'y': 4 - }, - { - 'x': 1413583800000, - 'y': 6 - }, - { - 'x': 1413584400000, - 'y': 3 - }, - { - 'x': 1413585000000, - 'y': 6 - }, - { - 'x': 1413585600000, - 'y': 6 - }, - { - 'x': 1413586200000, - 'y': 2 - }, - { - 'x': 1413586800000, - 'y': 3 - } - ] - }, - { - 'label': 'gif', - 'values': [ - { - 'x': 1413543600000, - 'y': 21 - }, - { - 'x': 1413544200000, - 'y': 191 - }, - { - 'x': 1413544800000, - 'y': 176 - }, - { - 'x': 1413545400000, - 'y': 166 - }, - { - 'x': 1413546000000, - 'y': 183 - }, - { - 'x': 1413546600000, - 'y': 170 - }, - { - 'x': 1413547200000, - 'y': 153 - }, - { - 'x': 1413547800000, - 'y': 202 - }, - { - 'x': 1413548400000, - 'y': 175 - }, - { - 'x': 1413549000000, - 'y': 161 - }, - { - 'x': 1413549600000, - 'y': 174 - }, - { - 'x': 1413550200000, - 'y': 167 - }, - { - 'x': 1413550800000, - 'y': 171 - }, - { - 'x': 1413551400000, - 'y': 176 - }, - { - 'x': 1413552000000, - 'y': 139 - }, - { - 'x': 1413552600000, - 'y': 145 - }, - { - 'x': 1413553200000, - 'y': 157 - }, - { - 'x': 1413553800000, - 'y': 148 - }, - { - 'x': 1413554400000, - 'y': 149 - }, - { - 'x': 1413555000000, - 'y': 135 - }, - { - 'x': 1413555600000, - 'y': 118 - }, - { - 'x': 1413556200000, - 'y': 142 - }, - { - 'x': 1413556800000, - 'y': 141 - }, - { - 'x': 1413557400000, - 'y': 146 - }, - { - 'x': 1413558000000, - 'y': 114 - }, - { - 'x': 1413558600000, - 'y': 115 - }, - { - 'x': 1413559200000, - 'y': 136 - }, - { - 'x': 1413559800000, - 'y': 106 - }, - { - 'x': 1413560400000, - 'y': 92 - }, - { - 'x': 1413561000000, - 'y': 97 - }, - { - 'x': 1413561600000, - 'y': 90 - }, - { - 'x': 1413562200000, - 'y': 69 - }, - { - 'x': 1413562800000, - 'y': 66 - }, - { - 'x': 1413563400000, - 'y': 93 - }, - { - 'x': 1413564000000, - 'y': 75 - }, - { - 'x': 1413564600000, - 'y': 68 - }, - { - 'x': 1413565200000, - 'y': 55 - }, - { - 'x': 1413565800000, - 'y': 73 - }, - { - 'x': 1413566400000, - 'y': 57 - }, - { - 'x': 1413567000000, - 'y': 48 - }, - { - 'x': 1413567600000, - 'y': 41 - }, - { - 'x': 1413568200000, - 'y': 39 - }, - { - 'x': 1413568800000, - 'y': 32 - }, - { - 'x': 1413569400000, - 'y': 33 - }, - { - 'x': 1413570000000, - 'y': 39 - }, - { - 'x': 1413570600000, - 'y': 35 - }, - { - 'x': 1413571200000, - 'y': 25 - }, - { - 'x': 1413571800000, - 'y': 28 - }, - { - 'x': 1413572400000, - 'y': 8 - }, - { - 'x': 1413573600000, - 'y': 13 - }, - { - 'x': 1413574200000, - 'y': 23 - }, - { - 'x': 1413574800000, - 'y': 19 - }, - { - 'x': 1413575400000, - 'y': 16 - }, - { - 'x': 1413576000000, - 'y': 22 - }, - { - 'x': 1413576600000, - 'y': 13 - }, - { - 'x': 1413577200000, - 'y': 21 - }, - { - 'x': 1413577800000, - 'y': 11 - }, - { - 'x': 1413578400000, - 'y': 12 - }, - { - 'x': 1413579000000, - 'y': 10 - }, - { - 'x': 1413579600000, - 'y': 7 - }, - { - 'x': 1413580200000, - 'y': 4 - }, - { - 'x': 1413580800000, - 'y': 5 - }, - { - 'x': 1413581400000, - 'y': 7 - }, - { - 'x': 1413582000000, - 'y': 9 - }, - { - 'x': 1413582600000, - 'y': 2 - }, - { - 'x': 1413583200000, - 'y': 2 - }, - { - 'x': 1413583800000, - 'y': 4 - }, - { - 'x': 1413584400000, - 'y': 6 - }, - { - 'x': 1413585600000, - 'y': 2 - }, - { - 'x': 1413586200000, - 'y': 4 - }, - { - 'x': 1413586800000, - 'y': 4 - } - ] + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 108970, - 'xAxisFormatter': function (thing) { - return moment(thing); - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 108970 }; diff --git a/src/fixtures/vislib/mock_data/histogram/_columns.js b/src/fixtures/vislib/mock_data/histogram/_columns.js index 422e2b56d4c05..b23c1508db924 100644 --- a/src/fixtures/vislib/mock_data/histogram/_columns.js +++ b/src/fixtures/vislib/mock_data/histogram/_columns.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'columns': [ + 'split': 'columns', + 'charts': [ { 'label': '404: response', 'xAxisLabel': 'machine.ram', diff --git a/src/fixtures/vislib/mock_data/histogram/_rows.js b/src/fixtures/vislib/mock_data/histogram/_rows.js index 8a9a08db2c29f..43546cc886066 100644 --- a/src/fixtures/vislib/mock_data/histogram/_rows.js +++ b/src/fixtures/vislib/mock_data/histogram/_rows.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'rows': [ + 'split': 'rows', + 'charts': [ { 'label': '404: response', 'xAxisLabel': 'machine.ram', diff --git a/src/fixtures/vislib/mock_data/histogram/_series.js b/src/fixtures/vislib/mock_data/histogram/_series.js index 90995a00a11ef..9adfec11c8ba0 100644 --- a/src/fixtures/vislib/mock_data/histogram/_series.js +++ b/src/fixtures/vislib/mock_data/histogram/_series.js @@ -1,104 +1,106 @@ import _ from 'lodash'; export default { - 'label': '', - 'xAxisLabel': 'machine.ram', - 'ordered': { - 'interval': 100 - }, - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': 3221225400, - 'y': 5 - }, - { - 'x': 4294967200, - 'y': 2 - }, - { - 'x': 5368709100, - 'y': 5 - }, - { - 'x': 6442450900, - 'y': 4 - }, - { - 'x': 7516192700, - 'y': 1 - }, - { - 'x': 9663676400, - 'y': 9 - }, - { - 'x': 10737418200, - 'y': 5 - }, - { - 'x': 11811160000, - 'y': 5 - }, - { - 'x': 12884901800, - 'y': 2 - }, - { - 'x': 13958643700, - 'y': 3 - }, - { - 'x': 15032385500, - 'y': 3 - }, - { - 'x': 16106127300, - 'y': 3 - }, - { - 'x': 17179869100, - 'y': 1 - }, - { - 'x': 18253611000, - 'y': 6 - }, - { - 'x': 19327352800, - 'y': 3 - }, - { - 'x': 20401094600, - 'y': 3 - }, - { - 'x': 21474836400, - 'y': 7 - }, - { - 'x': 32212254700, - 'y': 4 - } - ] + 'charts': [{ + 'label': '', + 'xAxisLabel': 'machine.ram', + 'ordered': { + 'interval': 100 + }, + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': 3221225400, + 'y': 5 + }, + { + 'x': 4294967200, + 'y': 2 + }, + { + 'x': 5368709100, + 'y': 5 + }, + { + 'x': 6442450900, + 'y': 4 + }, + { + 'x': 7516192700, + 'y': 1 + }, + { + 'x': 9663676400, + 'y': 9 + }, + { + 'x': 10737418200, + 'y': 5 + }, + { + 'x': 11811160000, + 'y': 5 + }, + { + 'x': 12884901800, + 'y': 2 + }, + { + 'x': 13958643700, + 'y': 3 + }, + { + 'x': 15032385500, + 'y': 3 + }, + { + 'x': 16106127300, + 'y': 3 + }, + { + 'x': 17179869100, + 'y': 1 + }, + { + 'x': 18253611000, + 'y': 6 + }, + { + 'x': 19327352800, + 'y': 3 + }, + { + 'x': 20401094600, + 'y': 3 + }, + { + 'x': 21474836400, + 'y': 7 + }, + { + 'x': 32212254700, + 'y': 4 + } + ] + } + ], + 'xAxisFormatter': function (val) { + if (_.isObject(val)) { + return JSON.stringify(val); + } + else if (val == null) { + return ''; + } + else { + return '' + val; + } + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 71, - 'xAxisFormatter': function (val) { - if (_.isObject(val)) { - return JSON.stringify(val); - } - else if (val == null) { - return ''; - } - else { - return '' + val; - } - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 71 }; diff --git a/src/fixtures/vislib/mock_data/pie/_histogram.js b/src/fixtures/vislib/mock_data/pie/_histogram.js new file mode 100644 index 0000000000000..2117134d75870 --- /dev/null +++ b/src/fixtures/vislib/mock_data/pie/_histogram.js @@ -0,0 +1,39 @@ + +export default { + 'charts': [{ + 'label': 'chart title', + 'children': [ + { + 'label': 0, + 'values': [{ + 'value': 378611 + }], + }, + { + 'name': 1000, + 'values': [{ + 'value': 205997 + }] + }, + { + 'name': 2000, + 'values': [{ + 'value': 397189 + }] + }, + { + 'name': 3000, + 'values': [{ + 'value': 397195 + }] + }, + { + 'name': 4000, + 'values': [{ + 'value': 398429 + }] + }, + ] + }], + 'hits': 3967374 +}; diff --git a/src/fixtures/vislib/mock_data/range/_columns.js b/src/fixtures/vislib/mock_data/range/_columns.js index d75f80d8fcec8..9abcb8dbfbaa4 100644 --- a/src/fixtures/vislib/mock_data/range/_columns.js +++ b/src/fixtures/vislib/mock_data/range/_columns.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'columns': [ + 'split': 'columns', + 'charts': [ { 'label': 'apache: _type', 'xAxisLabel': 'bytes ranges', diff --git a/src/fixtures/vislib/mock_data/range/_rows.js b/src/fixtures/vislib/mock_data/range/_rows.js index 35a938851b130..6d922158c5791 100644 --- a/src/fixtures/vislib/mock_data/range/_rows.js +++ b/src/fixtures/vislib/mock_data/range/_rows.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'rows': [ + 'split': 'rows', + 'charts': [ { 'label': 'Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1: agent.raw', 'xAxisLabel': 'bytes ranges', diff --git a/src/fixtures/vislib/mock_data/range/_series.js b/src/fixtures/vislib/mock_data/range/_series.js index 34454bbb2020b..ae5e81e7c54a7 100644 --- a/src/fixtures/vislib/mock_data/range/_series.js +++ b/src/fixtures/vislib/mock_data/range/_series.js @@ -1,37 +1,39 @@ import _ from 'lodash'; export default { - 'label': '', - 'xAxisLabel': 'bytes ranges', - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': '0.0-1000.0', - 'y': 16576 - }, - { - 'x': '1000.0-2000.0', - 'y': 9005 - } - ] + charts: [{ + 'label': '', + 'xAxisLabel': 'bytes ranges', + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': '0.0-1000.0', + 'y': 16576 + }, + { + 'x': '1000.0-2000.0', + 'y': 9005 + } + ] + } + ], + 'xAxisFormatter': function (val) { + if (_.isObject(val)) { + return JSON.stringify(val); + } + else if (val == null) { + return ''; + } + else { + return '' + val; + } + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 171500, - 'xAxisFormatter': function (val) { - if (_.isObject(val)) { - return JSON.stringify(val); - } - else if (val == null) { - return ''; - } - else { - return '' + val; - } - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 171500 }; diff --git a/src/fixtures/vislib/mock_data/terms/_columns.js b/src/fixtures/vislib/mock_data/terms/_columns.js index fdcaf9987351d..b2c4a127d82d0 100644 --- a/src/fixtures/vislib/mock_data/terms/_columns.js +++ b/src/fixtures/vislib/mock_data/terms/_columns.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'columns': [ + 'split': 'columns', + 'charts': [ { 'label': 'logstash: index', 'xAxisLabel': 'Top 5 extension', diff --git a/src/fixtures/vislib/mock_data/terms/_rows.js b/src/fixtures/vislib/mock_data/terms/_rows.js index 7564258ddee8a..efbc8cb899661 100644 --- a/src/fixtures/vislib/mock_data/terms/_rows.js +++ b/src/fixtures/vislib/mock_data/terms/_rows.js @@ -1,7 +1,8 @@ import _ from 'lodash'; export default { - 'rows': [ + 'split': 'rows', + 'charts': [ { 'label': '0.0-1000.0: bytes', 'xAxisLabel': 'Top 5 extension', diff --git a/src/fixtures/vislib/mock_data/terms/_series.js b/src/fixtures/vislib/mock_data/terms/_series.js index 90db8af86fa57..d41ce760d7c2b 100644 --- a/src/fixtures/vislib/mock_data/terms/_series.js +++ b/src/fixtures/vislib/mock_data/terms/_series.js @@ -1,49 +1,51 @@ import _ from 'lodash'; export default { - 'label': '', - 'xAxisLabel': 'Top 5 extension', - 'yAxisLabel': 'Count of documents', - 'series': [ - { - 'label': 'Count', - 'values': [ - { - 'x': 'jpg', - 'y': 110710 - }, - { - 'x': 'css', - 'y': 27389 - }, - { - 'x': 'png', - 'y': 16661 - }, - { - 'x': 'gif', - 'y': 11269 - }, - { - 'x': 'php', - 'y': 5447 - } - ] + charts: [{ + 'label': '', + 'xAxisLabel': 'Top 5 extension', + 'yAxisLabel': 'Count of documents', + 'series': [ + { + 'label': 'Count', + 'values': [ + { + 'x': 'jpg', + 'y': 110710 + }, + { + 'x': 'css', + 'y': 27389 + }, + { + 'x': 'png', + 'y': 16661 + }, + { + 'x': 'gif', + 'y': 11269 + }, + { + 'x': 'php', + 'y': 5447 + } + ] + } + ], + 'xAxisFormatter': function (val) { + if (_.isObject(val)) { + return JSON.stringify(val); + } + else if (val == null) { + return ''; + } + else { + return '' + val; + } + }, + 'tooltipFormatter': function (d) { + return d; } - ], - 'hits': 171476, - 'xAxisFormatter': function (val) { - if (_.isObject(val)) { - return JSON.stringify(val); - } - else if (val == null) { - return ''; - } - else { - return '' + val; - } - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 171476 }; diff --git a/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js b/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js index d2b2864760346..5a69d7eeecbd3 100644 --- a/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js +++ b/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js @@ -1,71 +1,73 @@ import _ from 'lodash'; export default { - 'yAxisLabel': 'Count', - 'zAxisLabel': 'machine.os.raw: Descending', - 'yScale': null, - 'series': [{ - 'label': 'ios', - 'aggLabel': 'Count', - 'aggId': '1', - 'values': [{ - 'x': '_all', - 'y': 2820, - 'series': 'ios' - }] - }, { - 'label': 'win 7', - 'aggLabel': 'Count', - 'aggId': '1', - 'values': [{ - 'x': '_all', - 'y': 2319, - 'series': 'win 7' - }] - }, { - 'label': 'win 8', - 'aggLabel': 'Count', - 'aggId': '1', - 'values': [{ - 'x': '_all', - 'y': 1835, - 'series': 'win 8' - }] - }, { - 'label': 'win xp', - 'aggLabel': 'Count', - 'aggId': '1', - 'values': [{ - 'x': '_all', - 'y': 734, - 'series': 'win xp' - }] - }, { - 'label': 'osx', - 'aggLabel': 'Count', - 'aggId': '1', - 'values': [{ - 'x': '_all', - 'y': 1352, - 'series': 'osx' - }] - }], - 'hits': 14005, - 'xAxisFormatter': function (val) { - if (_.isObject(val)) { - return JSON.stringify(val); - } - else if (val == null) { - return ''; + charts: [{ + 'yAxisLabel': 'Count', + 'zAxisLabel': 'machine.os.raw: Descending', + 'yScale': null, + 'series': [{ + 'label': 'ios', + 'aggLabel': 'Count', + 'aggId': '1', + 'values': [{ + 'x': '_all', + 'y': 2820, + 'series': 'ios' + }] + }, { + 'label': 'win 7', + 'aggLabel': 'Count', + 'aggId': '1', + 'values': [{ + 'x': '_all', + 'y': 2319, + 'series': 'win 7' + }] + }, { + 'label': 'win 8', + 'aggLabel': 'Count', + 'aggId': '1', + 'values': [{ + 'x': '_all', + 'y': 1835, + 'series': 'win 8' + }] + }, { + 'label': 'win xp', + 'aggLabel': 'Count', + 'aggId': '1', + 'values': [{ + 'x': '_all', + 'y': 734, + 'series': 'win xp' + }] + }, { + 'label': 'osx', + 'aggLabel': 'Count', + 'aggId': '1', + 'values': [{ + 'x': '_all', + 'y': 1352, + 'series': 'osx' + }] + }], + 'xAxisFormatter': function (val) { + if (_.isObject(val)) { + return JSON.stringify(val); + } + else if (val == null) { + return ''; + } + else { + return '' + val; + } + }, + 'yAxisFormatter': function (val) { + return val; + }, + 'tooltipFormatter': function (d) { + return d; } - else { - return '' + val; - } - }, - 'yAxisFormatter': function (val) { - return val; - }, - 'tooltipFormatter': function (d) { - return d; - } + }], + 'hits': 14005 }; diff --git a/src/ui/public/vis/components/tooltip/formatter.js b/src/ui/public/vis/components/tooltip/formatter.js new file mode 100644 index 0000000000000..dfac32857020b --- /dev/null +++ b/src/ui/public/vis/components/tooltip/formatter.js @@ -0,0 +1,23 @@ +const tooltipFormatter = (event) => { + const getValue = (agg) => { + if (agg.value === 'y') { + return agg.formatter ? agg.formatter(event.point.y || event.point) : event.point.y || event.point; + } else if (agg.value === 'x') { + return agg.formatter ? agg.formatter(event.point.x) : event.point.x; + } else if (agg.value === 'x_as_string') { + return agg.formatter ? agg.formatter(event.point.x_as_string) : event.point.x_as_string; + } else if (agg.value === 'val') { + return event.point.val; + } else { + return agg.value; + } + }; + if (!event.aggs) return; + const aggs = event.aggs.map(agg => { + const value = getValue(agg); + return `${agg.label}${value}`; + }).join(''); + return '' + aggs + '
'; +}; + +export { tooltipFormatter }; diff --git a/src/ui/public/vis/response_handlers/__tests__/series_data.js b/src/ui/public/vis/response_handlers/__tests__/series_data.js new file mode 100644 index 0000000000000..671d9b8cb66ad --- /dev/null +++ b/src/ui/public/vis/response_handlers/__tests__/series_data.js @@ -0,0 +1,85 @@ +import expect from 'expect.js'; +import { seriesResponseHandlerProvider } from '../series_data'; + +const responseHandler = seriesResponseHandlerProvider().handler; + +describe('Series Response Handler', function () { + + describe('date_histogram terms and filter data', function () { + const data = require('fixtures/agg_resp/date_term_filter'); + //const expectedData = require('fixtures/response_handlers/series/filter_date_term'); + const vis = { + aggs: [{ + 'id': '1', + 'enabled': true, + 'type': { name: 'count' }, + 'schema': { name: 'metric', group: 'metrics' }, + 'params': {}, + fieldFormatter: () => x => x, + makeLabel: () => 'Count', + getValue: bucket => bucket.doc_count + }, { + 'id': '2', + 'enabled': true, + 'type': { name: 'date_histogram' }, + 'schema': { name: 'segment', group: 'buckets' }, + 'params': { + 'field': '@timestamp', + 'interval': 'auto', + 'customInterval': '2h', + 'min_doc_count': 1, + 'extended_bounds': {} + }, + fieldFormatter: () => x => x, + write: () => { return {}; }, + makeLabel: () => '@timestamp per 2h' + }, { + 'id': '3', + 'enabled': true, + 'type': { name: 'terms' }, + 'schema': { name: 'group', group: 'buckets' }, + 'params': { + 'field': 'response.raw', + 'size': 5, + 'order': 'desc', + 'orderBy': '1' + }, + fieldFormatter: () => x => x, + makeLabel: () => 'response.raw: descending' + }, { + 'id': '4', + 'enabled': true, + 'type': { name: 'filters' }, + 'schema': { name: 'split', group: 'buckets' }, + 'params': { + 'filters': [ + { label: '404', 'input': { 'query': '404' } }, + { label: '200', 'input': { 'query': '200' } } + ], + 'row': true + }, + fieldFormatter: () => x => x, + makeLabel: () => 'filters', + }] + }; + let convertedData; + + beforeEach(() => { + return responseHandler(vis, data).then(response => { + convertedData = JSON.parse(JSON.stringify(response)); + }); + }); + + it('converts data to point series', function () { + expect(convertedData.charts.length).to.greaterThan(0); + expect(convertedData.charts[0].series.length).to.greaterThan(0); + expect(convertedData.charts[0].series[0].values.length).to.greaterThan(0); + }); + + it('data matches expected results', function () { + + //expect(convertedData).to.equal(expectedData); + }); + }); + +}); diff --git a/src/ui/public/vis/response_handlers/hierarchical_data.js b/src/ui/public/vis/response_handlers/hierarchical_data.js new file mode 100644 index 0000000000000..10531ae728f24 --- /dev/null +++ b/src/ui/public/vis/response_handlers/hierarchical_data.js @@ -0,0 +1,150 @@ +import _ from 'lodash'; +import { VisResponseHandlersRegistryProvider } from 'ui/registry/vis_response_handlers'; + +const HierarchicalResponseHandlerProvider = function () { + /*** + * Prepares hierarchical data out of esResponse. + * each split bucket will create multiple charts + * everything else will create sub buckets on the children property + * + * @param vis + * @param esResponse + */ + return { + name: 'hierarchical_data', + handler: (vis, esResponse) => { + + const metrics = vis.aggs.filter(agg => agg.schema.group === 'metrics'); + const buckets = vis.aggs.filter(agg => agg.schema.group === 'buckets'); + const lastBucket = _.last(buckets); + + const charts = {}; + const getValues = (data, aggs = []) => { + const getValue = (metric) => { + if (metric.type.name === 'count') return data.doc_count; + if (data[metric.id].value) return data[metric.id].value; + if (data[metric.id].values) { + if (data[metric.id].values.length && !isNaN(data[metric.id].values[0].value)) { + return data[metric.id].values[0].value; + } + } + return 0; + }; + + return metrics.map(metric => { + const newAggs = aggs.concat({ + id: metric.id, + label: metric.makeLabel(), + formatter: metric.fieldFormatter('text'), + value: getValue(metric) + }); + + return { + aggs: newAggs.slice().reverse(), + value: getValue(metric) + }; + }); + }; + + const getSlices = (data, chart, aggs = [], done = false) => { + if (done) return; + _.map(data, (agg, id) => { + if (!_.isObject(agg)) return; + const aggConfig = vis.aggs.find(agg => agg.id === id); + if (!aggConfig) throw 'undefined aggregation while converting series data'; + + if (aggConfig.schema.name === 'split') { + agg.buckets.forEach(bucket => { + if (!charts[bucket.key]) { + charts[bucket.key] = { + label: bucket.key + ': ' + aggConfig.makeLabel(bucket.key), + children: [] + }; + } + chart = charts[bucket.key]; + const newAggs = aggs.concat({ + id: aggConfig.id, + label: aggConfig.makeLabel(), + value: aggConfig.fieldFormatter('html')(bucket.key), + rawValue: bucket.key + }); + return getSlices(bucket, chart, newAggs, id === lastBucket.id); + }); + } else if (aggConfig.schema.group === 'buckets') { + if (!chart) { + charts[0] = { label: aggConfig.makeLabel(), children: [] }; + chart = charts[0]; + } + agg.buckets.forEach(bucket => { + const newAggs = aggs.concat({ + id: aggConfig.id, + label: aggConfig.makeLabel(), + value: aggConfig.fieldFormatter('html')(bucket.key), + rawValue: bucket.key + }); + const slice = { + label: bucket.key, + aggs: newAggs.slice().reverse(), + values: getValues(bucket, newAggs), + children: [] + }; + chart.children.push(slice); + return getSlices(bucket, slice, newAggs, id === lastBucket.id); + }); + } + }); + }; + + let result; + if (buckets.length === 0) { + if (metrics.length > 1 || metrics[0].type.name !== 'count') { + esResponse.aggregations.doc_count = esResponse.hits.total; + result = { + charts: [ + { + label: '', + children: [ + { + values: getValues(esResponse) + } + ] + } + ] + }; + } else { + result = { + charts: [{ + label: 'All', + children: [{ + label: 'Count', + aggs: [{ label: 'Count', value: esResponse.hits.total }], + values: [{ + id: metrics[0].id, + label: metrics[0].makeLabel(), + formatter: metrics[0].fieldFormatter('text'), + value: esResponse.hits.total + }] + }] + }] + }; + } + } else { + getSlices(esResponse.aggregations, 0); + result = { + charts: _.map(charts, chart => { + chart.children = _.values(chart.children); + return chart; + }) + }; + } + + result.hits = esResponse.hits.total; + + return Promise.resolve(result); + } + }; +}; + +VisResponseHandlersRegistryProvider.register(HierarchicalResponseHandlerProvider); + +export { HierarchicalResponseHandlerProvider }; diff --git a/src/ui/public/vis/response_handlers/series_data.js b/src/ui/public/vis/response_handlers/series_data.js new file mode 100644 index 0000000000000..ac92c94be9db9 --- /dev/null +++ b/src/ui/public/vis/response_handlers/series_data.js @@ -0,0 +1,252 @@ +import _ from 'lodash'; +import { VisResponseHandlersRegistryProvider } from 'ui/registry/vis_response_handlers'; + +const seriesResponseHandlerProvider = function () { + /*** + * Prepares series out of esResponse. + * each combination of metric, segment bucket and group bucket will add a series + * each split bucket will create multiple charts + * + * @param vis + * @param esResponse + */ + return { + name: 'series_data', + handler: (vis, esResponse) => { + + const clonedResponse = _.cloneDeep(esResponse); + + const metrics = vis.aggs.filter(agg => agg.schema.group === 'metrics'); + const buckets = vis.aggs.filter(agg => agg.schema.group === 'buckets'); + const segment = vis.aggs.find(agg => agg.schema.name === 'segment'); + const radius = vis.aggs.find(agg => agg.schema.name === 'radius'); + const lastBucket = _.last(buckets); + let chartSplit = 'column'; + let scale = 1; + let xAxisFormatter; + let yAxisFormatter; + const charts = {}; + + const getBucketKey = (aggConfig, bucket, key) => { + let value = bucket.key || key; + if (typeof bucket.from_as_string !== 'undefined') { + const from = aggConfig.params.field.format.convert(bucket.from); + const to = aggConfig.params.field.format.convert(bucket.to); + value = `${from} to ${to}`; + } else if (typeof bucket.from !== 'undefined') { + value = aggConfig.fieldFormatter('text')({ gte: bucket.from, lt: bucket.to }); + if (typeof value === 'object') { + value = `${value.gte} to ${value.lt}`; + } + } else { + value = aggConfig.fieldFormatter('text')(value); + } + return value; + }; + + const getBucketRawKey = (aggConfig, bucket) => { + let value = bucket.key; + if (typeof bucket.from !== 'undefined') { + value = { gte: bucket.from, lt: bucket.to }; + } + return value; + }; + + const getBucketProps = (aggConfig, bucket, key) => { + const value = getBucketKey(aggConfig, bucket, key); + //const useRawValue = !['range', 'ip_range', 'date_range', 'filters'].includes(aggConfig.type.name); + const useRawValue = !['ip_range', 'date_range'].includes(aggConfig.type.name); + + return { + id: aggConfig.id, + label: aggConfig.makeLabel(), + value: value, + rawValue: useRawValue ? getBucketRawKey(aggConfig, bucket) : null + }; + }; + + const sortBuckets = (aggConfig, buckets) => { + if (['range', 'filters'].includes(aggConfig.type.name)) { + const sortedBuckets = []; + if (aggConfig.type.name === 'range') { + aggConfig.params.ranges.forEach(range => { + const key = _.findKey(buckets, bucket => bucket.from === range.from && bucket.to === range.to); + buckets[key].key = key; + sortedBuckets.push(buckets[key]); + }); + } else if (aggConfig.type.name === 'filters') { + aggConfig.params.filters.forEach(filter => { + const key = filter.label || filter.input.query.query_string.query; + buckets[key].key = key; + sortedBuckets.push(buckets[key]); + }); + } + return sortedBuckets; + } + return buckets; + }; + + const getSeriesName = (series, metric) => { + if (!series) return metric.makeLabel(); + if (metrics.length === 1) return series.trim().replace(/:+$/g, ''); + return series + metric.makeLabel(); + }; + + const getSeries = (data, chart, seri, category, aggs = [], done = false) => { + if (done) { + _.map(metrics, metric => { + if (metric.schema.name === 'radius') return; + const responseAggs = metric.getResponseAggs ? metric.getResponseAggs() : [metric]; + responseAggs.forEach(metric => { + const name = getSeriesName(seri, metric); + const value = metric.getValue(data) * scale; + if (!charts[chart]) { + charts[chart] = { + aggId: chart, + label: segment ? segment.makeLabel() : '', + series: {} + }; + + if (segment) { + const isDate = segment.type.name === 'date_histogram'; + const bounds = isDate ? segment.buckets.getBounds() : {}; + charts[chart].ordered = { + date: isDate, + interval: segment.buckets ? segment.buckets.getInterval().asMilliseconds() : segment.params.interval, + min: bounds.min ? bounds.min._d.valueOf() : null, + max: bounds.max ? bounds.max._d.valueOf() : null + }; + } + } + if (!charts[chart].series[name]) { + const metricAgg = { + id: metric.parentId || metric.id, + label: metric.makeLabel(), + formatter: metric.fieldFormatter('text'), + value: 'y' + }; + charts[chart].series[name] = { + aggId: metric.parentId || metric.id, + label: name, + formatter: metric.fieldFormatter('text'), + aggs: aggs.concat(metricAgg).slice().reverse(), + values: [] + }; + } + yAxisFormatter = metric.fieldFormatter('text'); + charts[chart].xAxisFormatter = xAxisFormatter; + charts[chart].yAxisFormatter = yAxisFormatter; + charts[chart].series[name].values.push({ + ...category, + y: value, + z: radius ? radius.getValue(data) * scale : null + }); + }); + + }); + return; + } + + _.map(data, (agg, id) => { + if (!_.isObject(agg)) return; + const aggConfig = vis.aggs.find(agg => agg.id === id); + + if (!aggConfig) throw 'undefined aggregation while converting series data'; + if (agg.buckets) { + agg.buckets = sortBuckets(aggConfig, agg.buckets); + } + + if (aggConfig.schema.name === 'split') { + chartSplit = aggConfig.params.row ? 'row' : 'column'; + _.map(agg.buckets, (bucket, key) => { + const bucketProps = getBucketProps(aggConfig, bucket, key); + + chart = bucketProps.value; + if (!charts[chart]) { + charts[chart] = { + label: aggConfig.makeLabel(chart), + series: {} + }; + } + + return getSeries(bucket, chart, seri, category, aggs.concat(bucketProps), id === lastBucket.id); + }); + } else if (aggConfig.schema.name === 'segment') { + xAxisFormatter = aggConfig.fieldFormatter('text'); + scale = aggConfig.write().metricScale || 1; + + _.map(agg.buckets, (bucket, key) => { + const useRawValue = !['range', 'ip_range', 'date_range', 'filters'].includes(aggConfig.type.name); + const value = { + x_as_string: getBucketKey(aggConfig, bucket, key), + x_raw: getBucketRawKey(aggConfig, bucket), + x: useRawValue ? getBucketRawKey(aggConfig, bucket) : getBucketKey(aggConfig, bucket, key) + }; + const newAggs = aggs.concat({ + id: aggConfig.id, + label: aggConfig.makeLabel(), + value: 'x_as_string' + }); + + if (aggConfig.type.name === 'range') { + xAxisFormatter = x => x; + } + + return getSeries(bucket, chart, seri, value, newAggs, id === lastBucket.id); + }); + + } else if (aggConfig.schema.group === 'buckets') { + _.map(agg.buckets, (bucket, key) => { + const bucketProps = getBucketProps(aggConfig, bucket, key); + return getSeries(bucket, chart, seri + bucketProps.value + ': ', category, aggs.concat(bucketProps), id === lastBucket.id); + }); + } + + }); + }; + + let result; + if (buckets.length === 0) { + if (metrics.length > 1 || metrics[0].type.name !== 'count') { + clonedResponse.aggregations.doc_count = clonedResponse.hits.total; + getSeries(clonedResponse.aggregations, 0, '', null, [], true); + result = { + charts: _.map(charts, chart => { + chart.series = _.values(chart.series); + return chart; + }) + }; + } else { + result = { + charts: [{ + label: '', + series: [{ + label: 'Count', + aggs: [{ label: 'Count', value: clonedResponse.hits.total }], + formatter: metrics[0].fieldFormatter('text'), + values: [ { x: 'all', y: clonedResponse.hits.total } ] + }] + }] + }; + } + } else { + getSeries(clonedResponse.aggregations, 0, ''); + result = { + charts: _.map(charts, chart => { + chart.series = _.values(chart.series); + return chart; + }) + }; + } + + result.split = chartSplit; + result.hits = clonedResponse.hits.total; + + return Promise.resolve(result); + } + }; +}; + +VisResponseHandlersRegistryProvider.register(seriesResponseHandlerProvider); + +export { seriesResponseHandlerProvider }; diff --git a/src/ui/public/vis/vis_types/vislib_vis_type.js b/src/ui/public/vis/vis_types/vislib_vis_type.js index 719959471f13e..1087e0fea90df 100644 --- a/src/ui/public/vis/vis_types/vislib_vis_type.js +++ b/src/ui/public/vis/vis_types/vislib_vis_type.js @@ -4,10 +4,34 @@ import 'plugins/kbn_vislib_vis_types/controls/line_interpolation_option'; import 'plugins/kbn_vislib_vis_types/controls/heatmap_options'; import 'plugins/kbn_vislib_vis_types/controls/gauge_options'; import 'plugins/kbn_vislib_vis_types/controls/point_series'; +import AggConfigResult from 'ui/vis/agg_config_result'; import { VisTypeProvider } from './base_vis_type'; import { AggResponsePointSeriesProvider } from 'ui/agg_response/point_series/point_series'; import VislibProvider from 'ui/vislib'; +const buildAggConfigResult = (aggs, e, vis) => { + const getValue = (agg) => { + if (agg.value === 'y') { + return e.point.y; + } else if (agg.value === 'x') { + return e.point.x; + } else if (agg.value === 'x_as_string') { + return e.point.x; + } else { + return agg.rawValue || agg.value; + } + }; + let aggConfigResult; + aggs.reverse().forEach(agg => { + let value = getValue(agg); + const aggConfig = vis.aggs.find(aggCfg => aggCfg.id === agg.id); + if (aggConfig.type.name === 'range' && aggConfig.schema.name === 'segment') value = e.point.x_raw; + aggConfigResult = new AggConfigResult(aggConfig, aggConfigResult, value, value); + }); + + return aggConfigResult; +}; + export function VislibVisTypeProvider(Private) { const VisType = Private(VisTypeProvider); const pointSeries = Private(AggResponsePointSeriesProvider); @@ -30,8 +54,15 @@ export function VislibVisTypeProvider(Private) { return new Promise((resolve, reject) => { if (!this._response) return reject(); this.vis.vislibVis = new vislib.Vis(this.el, this.vis.params); - this.vis.vislibVis.on('brush', this.vis.API.events.brush); - this.vis.vislibVis.on('click', this.vis.API.events.filter); + this.vis.vislibVis.on('brush', e => { + e.data.xAxisField = this.vis.aggs.find(agg => agg.schema.name === 'segment').params.field; + e.data.indexPattern = this.vis.indexPattern; + this.vis.API.events.brush(e); + }); + this.vis.vislibVis.on('click', e => { + e.point.aggConfigResult = buildAggConfigResult(e.aggs.slice(), e, this.vis); + this.vis.API.events.filter(e); + }); this.vis.vislibVis.on('renderComplete', resolve); this.vis.vislibVis.render(esResponse, this.vis.getUiState()); this.vis.refreshLegend++; diff --git a/src/ui/public/vislib/__tests__/lib/axis/axis.js b/src/ui/public/vislib/__tests__/lib/axis/axis.js index 1e835d5c08873..c27ec6981b076 100644 --- a/src/ui/public/vislib/__tests__/lib/axis/axis.js +++ b/src/ui/public/vislib/__tests__/lib/axis/axis.js @@ -18,69 +18,71 @@ describe('Vislib Axis Class Test Suite', function () { const data = { hits: 621, - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: [ - { - label: 'Count', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734130000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - } - ] + charts: [{ + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 }, - { - label: 'Count2', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734140000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - } - ] - } - ], - xAxisFormatter: function (thing) { - return new Date(thing); - }, - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + series: [ + { + label: 'Count', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734130000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + } + ] + }, + { + label: 'Count2', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734140000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + } + ] + } + ], + xAxisFormatter: function (thing) { + return new Date(thing); + }, + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); @@ -104,7 +106,7 @@ describe('Vislib Axis Class Test Suite', function () { id: 'ValueAxis-1' }); - seriesData = data.series.map(series => { + seriesData = data.charts[0].series.map(series => { return series.values; }); })); diff --git a/src/ui/public/vislib/__tests__/lib/axis_title.js b/src/ui/public/vislib/__tests__/lib/axis_title.js index 21cac5e4c4931..782428ffe2ae2 100644 --- a/src/ui/public/vislib/__tests__/lib/axis_title.js +++ b/src/ui/public/vislib/__tests__/lib/axis_title.js @@ -20,61 +20,63 @@ describe('Vislib AxisTitle Class Test Suite', function () { let yTitle; const data = { hits: 621, - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: [ - { - label: 'Count', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts: [{ + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 + }, + series: [ + { + label: 'Count', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); diff --git a/src/ui/public/vislib/__tests__/lib/chart_title.js b/src/ui/public/vislib/__tests__/lib/chart_title.js index 38935c48f52e1..aa335022fb603 100644 --- a/src/ui/public/vislib/__tests__/lib/chart_title.js +++ b/src/ui/public/vislib/__tests__/lib/chart_title.js @@ -14,61 +14,63 @@ describe('Vislib ChartTitle Class Test Suite', function () { let el; const data = { hits: 621, - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: [ - { - label: 'Count', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts:[{ + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 + }, + series: [ + { + label: 'Count', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); diff --git a/src/ui/public/vislib/__tests__/lib/data.js b/src/ui/public/vislib/__tests__/lib/data.js index d910b5e908d9d..f4d90b3a72fda 100644 --- a/src/ui/public/vislib/__tests__/lib/data.js +++ b/src/ui/public/vislib/__tests__/lib/data.js @@ -6,17 +6,20 @@ import { VislibLibDataProvider } from 'ui/vislib/lib/data'; import 'ui/persisted_state'; const seriesData = { - 'label': '', - 'series': [ - { - 'label': '100', - 'values': [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 2, y: 3 }] - } - ] + 'charts': [{ + 'label': '', + 'series': [ + { + 'label': '100', + 'values': [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 2, y: 3 }] + } + ] + }] }; const rowsData = { - 'rows': [ + 'split': 'rows', + 'charts': [ { 'label': 'a', 'series': [ @@ -57,7 +60,8 @@ const rowsData = { }; const colsData = { - 'columns': [ + 'split': 'columns', + 'charts': [ { 'label': 'a', 'series': [ @@ -122,13 +126,13 @@ describe('Vislib Data Class Test Suite', function () { describe('_removeZeroSlices', function () { let data; const pieData = { - slices: { + charts: [{ children: [ - { size: 30 }, - { size: 20 }, - { size: 0 } + { values: [{ value: 30 }] }, + { values: [{ value: 20 }] }, + { values: [{ value: 0 }] } ] - } + }] }; beforeEach(function () { @@ -136,7 +140,7 @@ describe('Vislib Data Class Test Suite', function () { }); it('should remove zero values', function () { - const slices = data._removeZeroSlices(data.data.slices); + const slices = data._removeZeroSlices(data.data.columns[0]); expect(slices.children.length).to.be(2); }); }); @@ -172,65 +176,6 @@ describe('Vislib Data Class Test Suite', function () { } }); - describe('geohashGrid methods', function () { - let data; - const geohashGridData = { - hits: 3954, - rows: [{ - title: 'Top 5 _type: apache', - label: 'Top 5 _type: apache', - geoJson: { - type: 'FeatureCollection', - features: [], - properties: { - min: 2, - max: 331, - zoom: 3, - center: [ - 47.517200697839414, - -112.06054687499999 - ] - } - }, - }, { - title: 'Top 5 _type: nginx', - label: 'Top 5 _type: nginx', - geoJson: { - type: 'FeatureCollection', - features: [], - properties: { - min: 1, - max: 88, - zoom: 3, - center: [ - 47.517200697839414, - -112.06054687499999 - ] - } - }, - }] - }; - - beforeEach(function () { - data = new Data(geohashGridData, persistedState); - }); - - describe('getVisData', function () { - it('should return the rows property', function () { - const visData = data.getVisData(); - expect(visData).to.eql(geohashGridData.rows); - }); - }); - - describe('getGeoExtents', function () { - it('should return the min and max geoJson properties', function () { - const minMax = data.getGeoExtents(); - expect(minMax.min).to.be(1); - expect(minMax.max).to.be(331); - }); - }); - }); - describe('null value check', function () { it('should return false', function () { const data = new Data(rowsData, persistedState); @@ -238,8 +183,8 @@ describe('Vislib Data Class Test Suite', function () { }); it('should return true', function () { - const nullRowData = { rows: rowsData.rows.slice(0) }; - nullRowData.rows.push({ + const nullRowData = { charts: rowsData.charts.slice(0) }; + nullRowData.charts.push({ 'label': 'e', 'series': [ { diff --git a/src/ui/public/vislib/__tests__/lib/handler/handler.js b/src/ui/public/vislib/__tests__/lib/handler/handler.js index 9eb65b1bf1197..17cd307c02675 100644 --- a/src/ui/public/vislib/__tests__/lib/handler/handler.js +++ b/src/ui/public/vislib/__tests__/lib/handler/handler.js @@ -21,133 +21,134 @@ const names = [ 'rows', 'stackedSeries' ]; +describe('', function () { + dateHistogramArray.forEach(function (data, i) { + describe('Vislib Handler Test Suite for ' + names[i] + ' Data', function () { + let vis; + let persistedState; + const events = [ + 'click', + 'brush' + ]; + + beforeEach(ngMock.module('kibana')); + beforeEach(ngMock.inject(function (Private, $injector) { + vis = Private(FixturesVislibVisFixtureProvider)(); + persistedState = new ($injector.get('PersistedState'))(); + vis.render(data, persistedState); + })); + + afterEach(function () { + vis.destroy(); + }); -dateHistogramArray.forEach(function (data, i) { - describe('Vislib Handler Test Suite for ' + names[i] + ' Data', function () { - let vis; - let persistedState; - const events = [ - 'click', - 'brush' - ]; - - beforeEach(ngMock.module('kibana')); - beforeEach(ngMock.inject(function (Private, $injector) { - vis = Private(FixturesVislibVisFixtureProvider)(); - persistedState = new ($injector.get('PersistedState'))(); - vis.render(data, persistedState); - })); - - afterEach(function () { - vis.destroy(); - }); - - describe('render Method', function () { - it('should render charts', function () { - expect(vis.handler.charts.length).to.be.greaterThan(0); - vis.handler.charts.forEach(function (chart) { - expect($(chart.chartEl).find('svg').length).to.be(1); + describe('render Method', function () { + it('should render charts', function () { + expect(vis.handler.charts.length).to.be.greaterThan(0); + vis.handler.charts.forEach(function (chart) { + expect($(chart.chartEl).find('svg').length).to.be(1); + }); }); }); - }); - describe('enable Method', function () { - let charts; + describe('enable Method', function () { + let charts; - beforeEach(function () { - charts = vis.handler.charts; + beforeEach(function () { + charts = vis.handler.charts; - charts.forEach(function (chart) { - events.forEach(function (event) { - vis.handler.enable(event, chart); + charts.forEach(function (chart) { + events.forEach(function (event) { + vis.handler.enable(event, chart); + }); }); }); - }); - it('should add events to chart and emit to the Events class', function () { - charts.forEach(function (chart) { - events.forEach(function (event) { - expect(chart.events.listenerCount(event)).to.be.above(0); + it('should add events to chart and emit to the Events class', function () { + charts.forEach(function (chart) { + events.forEach(function (event) { + expect(chart.events.listenerCount(event)).to.be.above(0); + }); }); }); }); - }); - describe('disable Method', function () { - let charts; + describe('disable Method', function () { + let charts; - beforeEach(function () { - charts = vis.handler.charts; + beforeEach(function () { + charts = vis.handler.charts; - charts.forEach(function (chart) { - events.forEach(function (event) { - vis.handler.disable(event, chart); + charts.forEach(function (chart) { + events.forEach(function (event) { + vis.handler.disable(event, chart); + }); }); }); - }); - it('should remove events from the chart', function () { - charts.forEach(function (chart) { - events.forEach(function (event) { - expect(chart.events.listenerCount(event)).to.be(0); + it('should remove events from the chart', function () { + charts.forEach(function (chart) { + events.forEach(function (event) { + expect(chart.events.listenerCount(event)).to.be(0); + }); }); }); + }); - }); + describe('removeAll Method', function () { + beforeEach(function () { + ngMock.inject(function () { + vis.handler.removeAll(vis.el); + }); + }); - describe('removeAll Method', function () { - beforeEach(function () { - ngMock.inject(function () { - vis.handler.removeAll(vis.el); + it('should remove all DOM elements from the el', function () { + expect($(vis.el).children().length).to.be(0); }); }); - it('should remove all DOM elements from the el', function () { - expect($(vis.el).children().length).to.be(0); - }); - }); + describe('error Method', function () { + beforeEach(function () { + vis.handler.error('This is an error!'); + }); - describe('error Method', function () { - beforeEach(function () { - vis.handler.error('This is an error!'); + it('should return an error classed DOM element with a text message', function () { + expect($(vis.el).find('.error').length).to.be(1); + expect($('.error h4').html()).to.be('This is an error!'); + }); }); - it('should return an error classed DOM element with a text message', function () { - expect($(vis.el).find('.error').length).to.be(1); - expect($('.error h4').html()).to.be('This is an error!'); - }); - }); + describe('destroy Method', function () { + beforeEach(function () { + vis.handler.destroy(); + }); - describe('destroy Method', function () { - beforeEach(function () { - vis.handler.destroy(); + it('should destroy all the charts in the visualization', function () { + expect(vis.handler.charts.length).to.be(0); + }); }); - it('should destroy all the charts in the visualization', function () { - expect(vis.handler.charts.length).to.be(0); - }); - }); + describe('event proxying', function () { - describe('event proxying', function () { + it('should only pass the original event object to downstream handlers', function (done) { + const event = {}; + const chart = vis.handler.charts[0]; - it('should only pass the original event object to downstream handlers', function (done) { - const event = {}; - const chart = vis.handler.charts[0]; + const mockEmitter = function () { + const args = Array.from(arguments); + expect(args.length).to.be(2); + expect(args[0]).to.be('click'); + expect(args[1]).to.be(event); + done(); + }; - const mockEmitter = function () { - const args = Array.from(arguments); - expect(args.length).to.be(2); - expect(args[0]).to.be('click'); - expect(args[1]).to.be(event); - done(); - }; + vis.emit = mockEmitter; + vis.handler.enable('click', chart); + chart.events.emit('click', event); + }); - vis.emit = mockEmitter; - vis.handler.enable('click', chart); - chart.events.emit('click', event); }); - }); }); }); diff --git a/src/ui/public/vislib/__tests__/lib/vis_config.js b/src/ui/public/vislib/__tests__/lib/vis_config.js index cbce4632f0c65..e428ce3edd548 100644 --- a/src/ui/public/vislib/__tests__/lib/vis_config.js +++ b/src/ui/public/vislib/__tests__/lib/vis_config.js @@ -9,61 +9,63 @@ describe('Vislib VisConfig Class Test Suite', function () { let el; const data = { hits: 621, - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: [ - { - label: 'Count', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts: [{ + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 + }, + series: [ + { + label: 'Count', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); diff --git a/src/ui/public/vislib/__tests__/lib/x_axis.js b/src/ui/public/vislib/__tests__/lib/x_axis.js index 6a6a45468e944..2531ee1ed0eca 100644 --- a/src/ui/public/vislib/__tests__/lib/x_axis.js +++ b/src/ui/public/vislib/__tests__/lib/x_axis.js @@ -16,64 +16,66 @@ describe('Vislib xAxis Class Test Suite', function () { let VisConfig; const data = { hits: 621, - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: [ - { - label: 'Count', - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - xAxisFormatter: function (thing) { - return new Date(thing); - }, - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts: [{ + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 + }, + series: [ + { + label: 'Count', + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + xAxisFormatter: function (thing) { + return new Date(thing); + }, + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); diff --git a/src/ui/public/vislib/__tests__/lib/y_axis.js b/src/ui/public/vislib/__tests__/lib/y_axis.js index 4eb9f4a6871ef..4480eb4af78f0 100644 --- a/src/ui/public/vislib/__tests__/lib/y_axis.js +++ b/src/ui/public/vislib/__tests__/lib/y_axis.js @@ -45,18 +45,20 @@ function makeSeriesData(data) { function createData(seriesData) { const data = { hits: 621, - label: 'test', - ordered: { - date: true, - interval: 30000, - max: 1408734982458, - min: 1408734082458 - }, - series: seriesData.map(function (series) { - return { values: makeSeriesData(series) }; - }), - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts: [{ + label: 'test', + ordered: { + date: true, + interval: 30000, + max: 1408734982458, + min: 1408734082458 + }, + series: seriesData.map(function (series) { + return { values: makeSeriesData(series) }; + }), + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; const node = $('
').css({ diff --git a/src/ui/public/vislib/__tests__/visualizations/area_chart.js b/src/ui/public/vislib/__tests__/visualizations/area_chart.js index d7286260d835c..1736a6de8af1a 100644 --- a/src/ui/public/vislib/__tests__/visualizations/area_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/area_chart.js @@ -22,187 +22,188 @@ const visLibParams = { mode: 'stacked' }; +describe('', function () { + _.forOwn(dataTypesArray, function (dataType, dataTypeName) { + describe('Vislib Area Chart Test Suite for ' + dataTypeName + ' Data', function () { + let vis; + let persistedState; + + beforeEach(ngMock.module('kibana')); + beforeEach(ngMock.inject(function (Private, $injector) { + vis = Private(FixturesVislibVisFixtureProvider)(visLibParams); + persistedState = new ($injector.get('PersistedState'))(); + vis.on('brush', _.noop); + vis.render(dataType, persistedState); + })); -_.forOwn(dataTypesArray, function (dataType, dataTypeName) { - describe('Vislib Area Chart Test Suite for ' + dataTypeName + ' Data', function () { - let vis; - let persistedState; - - beforeEach(ngMock.module('kibana')); - beforeEach(ngMock.inject(function (Private, $injector) { - vis = Private(FixturesVislibVisFixtureProvider)(visLibParams); - persistedState = new ($injector.get('PersistedState'))(); - vis.on('brush', _.noop); - vis.render(dataType, persistedState); - })); - - afterEach(function () { - vis.destroy(); - }); + afterEach(function () { + vis.destroy(); + }); - describe('stackData method', function () { - let stackedData; - let isStacked; + describe('stackData method', function () { + let stackedData; + let isStacked; - beforeEach(function () { - vis.handler.charts.forEach(function (chart) { - stackedData = chart.chartData; + beforeEach(function () { + vis.handler.charts.forEach(function (chart) { + stackedData = chart.chartData; - isStacked = stackedData.series.every(function (arr) { - return arr.values.every(function (d) { - return _.isNumber(d.y0); + isStacked = stackedData.series.every(function (arr) { + return arr.values.every(function (d) { + return _.isNumber(d.y0); + }); }); }); }); - }); - it('should append a d.y0 key to the data object', function () { - expect(isStacked).to.be(true); + it('should append a d.y0 key to the data object', function () { + expect(isStacked).to.be(true); + }); }); - }); - describe('addPath method', function () { - it('should append a area paths', function () { - vis.handler.charts.forEach(function (chart) { - expect($(chart.chartEl).find('path').length).to.be.greaterThan(0); + describe('addPath method', function () { + it('should append a area paths', function () { + vis.handler.charts.forEach(function (chart) { + expect($(chart.chartEl).find('path').length).to.be.greaterThan(0); + }); }); }); - }); - describe('addPathEvents method', function () { - let path; - let d3selectedPath; - let onMouseOver; + describe('addPathEvents method', function () { + let path; + let d3selectedPath; + let onMouseOver; - beforeEach(ngMock.inject(function () { - vis.handler.charts.forEach(function (chart) { - path = $(chart.chartEl).find('path')[0]; - d3selectedPath = d3.select(path)[0][0]; + beforeEach(ngMock.inject(function () { + vis.handler.charts.forEach(function (chart) { + path = $(chart.chartEl).find('path')[0]; + d3selectedPath = d3.select(path)[0][0]; - // d3 instance of click and hover - onMouseOver = (!!d3selectedPath.__onmouseover); - }); - })); + // d3 instance of click and hover + onMouseOver = (!!d3selectedPath.__onmouseover); + }); + })); - it('should attach a hover event', function () { - vis.handler.charts.forEach(function () { - expect(onMouseOver).to.be(true); + it('should attach a hover event', function () { + vis.handler.charts.forEach(function () { + expect(onMouseOver).to.be(true); + }); }); }); - }); - describe('addCircleEvents method', function () { - let circle; - let brush; - let d3selectedCircle; - let onBrush; - let onClick; - let onMouseOver; - - beforeEach(ngMock.inject(function () { - vis.handler.charts.forEach(function (chart) { - circle = $(chart.chartEl).find('circle')[0]; - brush = $(chart.chartEl).find('.brush'); - d3selectedCircle = d3.select(circle)[0][0]; - - // d3 instance of click and hover - onBrush = (!!brush); - onClick = (!!d3selectedCircle.__onclick); - onMouseOver = (!!d3selectedCircle.__onmouseover); + describe('addCircleEvents method', function () { + let circle; + let brush; + let d3selectedCircle; + let onBrush; + let onClick; + let onMouseOver; + + beforeEach(ngMock.inject(function () { + vis.handler.charts.forEach(function (chart) { + circle = $(chart.chartEl).find('circle')[0]; + brush = $(chart.chartEl).find('.brush'); + d3selectedCircle = d3.select(circle)[0][0]; + + // d3 instance of click and hover + onBrush = (!!brush); + onClick = (!!d3selectedCircle.__onclick); + onMouseOver = (!!d3selectedCircle.__onmouseover); + }); + })); + + // D3 brushing requires that a g element is appended that + // listens for mousedown events. This g element includes + // listeners, however, I was not able to test for the listener + // function being present. I will need to update this test + // in the future. + it('should attach a brush g element', function () { + vis.handler.charts.forEach(function () { + expect(onBrush).to.be(true); + }); }); - })); - // D3 brushing requires that a g element is appended that - // listens for mousedown events. This g element includes - // listeners, however, I was not able to test for the listener - // function being present. I will need to update this test - // in the future. - it('should attach a brush g element', function () { - vis.handler.charts.forEach(function () { - expect(onBrush).to.be(true); + it('should attach a click event', function () { + vis.handler.charts.forEach(function () { + expect(onClick).to.be(true); + }); }); - }); - it('should attach a click event', function () { - vis.handler.charts.forEach(function () { - expect(onClick).to.be(true); + it('should attach a hover event', function () { + vis.handler.charts.forEach(function () { + expect(onMouseOver).to.be(true); + }); }); }); - it('should attach a hover event', function () { - vis.handler.charts.forEach(function () { - expect(onMouseOver).to.be(true); + describe('addCircles method', function () { + it('should append circles', function () { + vis.handler.charts.forEach(function (chart) { + expect($(chart.chartEl).find('circle').length).to.be.greaterThan(0); + }); }); - }); - }); - describe('addCircles method', function () { - it('should append circles', function () { - vis.handler.charts.forEach(function (chart) { - expect($(chart.chartEl).find('circle').length).to.be.greaterThan(0); - }); - }); + it('should not draw circles where d.y === 0', function () { + vis.handler.charts.forEach(function (chart) { + const series = chart.chartData.series; + const isZero = series.some(function (d) { + return d.y === 0; + }); + const circles = $.makeArray($(chart.chartEl).find('circle')); + const isNotDrawn = circles.some(function (d) { + return d.__data__.y === 0; + }); - it('should not draw circles where d.y === 0', function () { - vis.handler.charts.forEach(function (chart) { - const series = chart.chartData.series; - const isZero = series.some(function (d) { - return d.y === 0; - }); - const circles = $.makeArray($(chart.chartEl).find('circle')); - const isNotDrawn = circles.some(function (d) { - return d.__data__.y === 0; + if (isZero) { + expect(isNotDrawn).to.be(false); + } }); - - if (isZero) { - expect(isNotDrawn).to.be(false); - } }); }); - }); - describe('draw method', function () { - it('should return a function', function () { - vis.handler.charts.forEach(function (chart) { - expect(_.isFunction(chart.draw())).to.be(true); + describe('draw method', function () { + it('should return a function', function () { + vis.handler.charts.forEach(function (chart) { + expect(_.isFunction(chart.draw())).to.be(true); + }); }); - }); - it('should return a yMin and yMax', function () { - vis.handler.charts.forEach(function (chart) { - const yAxis = chart.handler.valueAxes[0]; - const domain = yAxis.getScale().domain(); + it('should return a yMin and yMax', function () { + vis.handler.charts.forEach(function (chart) { + const yAxis = chart.handler.valueAxes[0]; + const domain = yAxis.getScale().domain(); - expect(domain[0]).to.not.be(undefined); - expect(domain[1]).to.not.be(undefined); + expect(domain[0]).to.not.be(undefined); + expect(domain[1]).to.not.be(undefined); + }); }); - }); - it('should render a zero axis line', function () { - vis.handler.charts.forEach(function (chart) { - const yAxis = chart.handler.valueAxes[0]; + it('should render a zero axis line', function () { + vis.handler.charts.forEach(function (chart) { + const yAxis = chart.handler.valueAxes[0]; - if (yAxis.yMin < 0 && yAxis.yMax > 0) { - expect($(chart.chartEl).find('line.zero-line').length).to.be(1); - } + if (yAxis.yMin < 0 && yAxis.yMax > 0) { + expect($(chart.chartEl).find('line.zero-line').length).to.be(1); + } + }); }); }); - }); - describe('defaultYExtents is true', function () { - beforeEach(function () { - vis.visConfigArgs.defaultYExtents = true; - vis.render(dataType, persistedState); - }); + describe('defaultYExtents is true', function () { + beforeEach(function () { + vis.visConfigArgs.defaultYExtents = true; + vis.render(dataType, persistedState); + }); - it('should return yAxis extents equal to data extents', function () { - vis.handler.charts.forEach(function (chart) { - const yAxis = chart.handler.valueAxes[0]; - const min = vis.handler.valueAxes[0].axisScale.getYMin(); - const max = vis.handler.valueAxes[0].axisScale.getYMax(); - const domain = yAxis.getScale().domain(); - expect(domain[0]).to.equal(min); - expect(domain[1]).to.equal(max); + it('should return yAxis extents equal to data extents', function () { + vis.handler.charts.forEach(function (chart) { + const yAxis = chart.handler.valueAxes[0]; + const min = vis.handler.valueAxes[0].axisScale.getYMin(); + const max = vis.handler.valueAxes[0].axisScale.getYMax(); + const domain = yAxis.getScale().domain(); + expect(domain[0]).to.equal(min); + expect(domain[1]).to.equal(max); + }); }); }); }); diff --git a/src/ui/public/vislib/__tests__/visualizations/chart.js b/src/ui/public/vislib/__tests__/visualizations/chart.js index 862991505d508..f6257497d83dc 100644 --- a/src/ui/public/vislib/__tests__/visualizations/chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/chart.js @@ -15,67 +15,69 @@ describe('Vislib _chart Test Suite', function () { let config; const data = { hits : 621, - label : '', - ordered : { - date: true, - interval: 30000, - max : 1408734982458, - min : 1408734082458 - }, - series : [ - { - values: [ - { - x: 1408734060000, - y: 8 - }, - { - x: 1408734090000, - y: 23 - }, - { - x: 1408734120000, - y: 30 - }, - { - x: 1408734150000, - y: 28 - }, - { - x: 1408734180000, - y: 36 - }, - { - x: 1408734210000, - y: 30 - }, - { - x: 1408734240000, - y: 26 - }, - { - x: 1408734270000, - y: 22 - }, - { - x: 1408734300000, - y: 29 - }, - { - x: 1408734330000, - y: 24 - } - ] - } - ], - tooltipFormatter: function (datapoint) { - return datapoint; - }, - xAxisFormatter: function (thing) { - return thing; - }, - xAxisLabel: 'Date Histogram', - yAxisLabel: 'Count' + charts: [{ + label : '', + ordered : { + date: true, + interval: 30000, + max : 1408734982458, + min : 1408734082458 + }, + series : [ + { + values: [ + { + x: 1408734060000, + y: 8 + }, + { + x: 1408734090000, + y: 23 + }, + { + x: 1408734120000, + y: 30 + }, + { + x: 1408734150000, + y: 28 + }, + { + x: 1408734180000, + y: 36 + }, + { + x: 1408734210000, + y: 30 + }, + { + x: 1408734240000, + y: 26 + }, + { + x: 1408734270000, + y: 22 + }, + { + x: 1408734300000, + y: 29 + }, + { + x: 1408734330000, + y: 24 + } + ] + } + ], + tooltipFormatter: function (datapoint) { + return datapoint; + }, + xAxisFormatter: function (thing) { + return thing; + }, + xAxisLabel: 'Date Histogram', + yAxisLabel: 'Count' + }] }; beforeEach(ngMock.module('kibana')); diff --git a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js index b4ba0ca5c6622..bbbb0f99c54da 100644 --- a/src/ui/public/vislib/__tests__/visualizations/pie_chart.js +++ b/src/ui/public/vislib/__tests__/visualizations/pie_chart.js @@ -2,45 +2,10 @@ import d3 from 'd3'; import expect from 'expect.js'; import ngMock from 'ng_mock'; import _ from 'lodash'; -import fixtures from 'fixtures/fake_hierarchical_data'; import $ from 'jquery'; import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture'; -import { VisProvider } from 'ui/vis'; import 'ui/persisted_state'; -import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -import { BuildHierarchicalDataProvider } from 'ui/agg_response/hierarchical/build_hierarchical_data'; - -const rowAgg = [ - { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, - { type: 'terms', schema: 'split', params: { field: 'extension', rows: true } }, - { type: 'terms', schema: 'segment', params: { field: 'machine.os' } }, - { type: 'terms', schema: 'segment', params: { field: 'geo.src' } } -]; - -const colAgg = [ - { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, - { type: 'terms', schema: 'split', params: { field: 'extension', row: false } }, - { type: 'terms', schema: 'segment', params: { field: 'machine.os' } }, - { type: 'terms', schema: 'segment', params: { field: 'geo.src' } } -]; - -const sliceAgg = [ - { type: 'avg', schema: 'metric', params: { field: 'bytes' } }, - { type: 'terms', schema: 'segment', params: { field: 'machine.os' } }, - { type: 'terms', schema: 'segment', params: { field: 'geo.src' } } -]; - -const aggArray = [ - rowAgg, - colAgg, - sliceAgg -]; - -const names = [ - 'rows', - 'columns', - 'slices' -]; +import pieData from 'fixtures/vislib/mock_data/pie/_histogram'; const sizes = [ 0, @@ -52,147 +17,64 @@ const sizes = [ ]; describe('No global chart settings', function () { - const visLibParams1 = { - el: '
', - type: 'pie', - addLegend: true, - addTooltip: true - }; - const visLibParams2 = { - el: '
', + const visLibParams = { + el: $('
'), type: 'pie', addLegend: true, addTooltip: true }; - let chart1; - let chart2; - let Vis; + let vis; let persistedState; - let indexPattern; - let buildHierarchicalData; - let data1; - let data2; beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private, $injector) { - chart1 = Private(FixturesVislibVisFixtureProvider)(visLibParams1); - chart2 = Private(FixturesVislibVisFixtureProvider)(visLibParams2); - Vis = Private(VisProvider); + vis = Private(FixturesVislibVisFixtureProvider)(visLibParams); persistedState = new ($injector.get('PersistedState'))(); - indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - buildHierarchicalData = Private(BuildHierarchicalDataProvider); - - let id1 = 1; - let id2 = 1; - const stubVis1 = new Vis(indexPattern, { - type: 'pie', - aggs: rowAgg - }); - const stubVis2 = new Vis(indexPattern, { - type: 'pie', - aggs: colAgg - }); - - // We need to set the aggs to a known value. - _.each(stubVis1.aggs, function (agg) { - agg.id = 'agg_' + id1++; - }); - _.each(stubVis2.aggs, function (agg) { - agg.id = 'agg_' + id2++; - }); - - data1 = buildHierarchicalData(stubVis1, fixtures.threeTermBuckets); - data2 = buildHierarchicalData(stubVis2, fixtures.threeTermBuckets); - - chart1.render(data1, persistedState); - chart2.render(data2, persistedState); + vis.on('brush', _.noop); + vis.render(pieData, persistedState); })); afterEach(function () { - chart1.destroy(); - chart2.destroy(); + vis.destroy(); }); it('should render chart titles for all charts', function () { - expect($(chart1.el).find('.y-axis-chart-title').length).to.be(1); - expect($(chart2.el).find('.x-axis-chart-title').length).to.be(1); + expect($(vis.el).find('.x-axis-chart-title').length).to.be(1); }); describe('_validatePieData method', function () { const allZeros = [ - { slices: { children: [] } }, - { slices: { children: [] } }, - { slices: { children: [] } } + { children: [] }, + { children: [] }, + { children: [] } ]; const someZeros = [ - { slices: { children: [{}] } }, - { slices: { children: [{}] } }, - { slices: { children: [] } } + { children: [{}] }, + { children: [{}] }, + { children: [] } ]; const noZeros = [ - { slices: { children: [{}] } }, - { slices: { children: [{}] } }, - { slices: { children: [{}] } } + { children: [{}] }, + { children: [{}] }, + { children: [{}] } ]; it('should throw an error when all charts contain zeros', function () { expect(function () { - chart1.handler.ChartClass.prototype._validatePieData(allZeros); + vis.handler.ChartClass.prototype._validatePieData(allZeros); }).to.throwError(); }); it('should not throw an error when only some or no charts contain zeros', function () { expect(function () { - chart1.handler.ChartClass.prototype._validatePieData(someZeros); + vis.handler.ChartClass.prototype._validatePieData(someZeros); }).to.not.throwError(); expect(function () { - chart1.handler.ChartClass.prototype._validatePieData(noZeros); + vis.handler.ChartClass.prototype._validatePieData(noZeros); }).to.not.throwError(); }); - }); -}); - -aggArray.forEach(function (dataAgg, i) { - describe('Vislib PieChart Class Test Suite for ' + names[i] + ' data', function () { - const visLibParams = { - type: 'pie', - addLegend: true, - addTooltip: true - }; - let vis; - let Vis; - let persistedState; - let indexPattern; - let buildHierarchicalData; - let data; - - beforeEach(ngMock.module('kibana')); - beforeEach(ngMock.inject(function (Private, $injector) { - vis = Private(FixturesVislibVisFixtureProvider)(visLibParams); - Vis = Private(VisProvider); - persistedState = new ($injector.get('PersistedState'))(); - indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider); - buildHierarchicalData = Private(BuildHierarchicalDataProvider); - - let id = 1; - const stubVis = new Vis(indexPattern, { - type: 'pie', - aggs: dataAgg - }); - - // We need to set the aggs to a known value. - _.each(stubVis.aggs, function (agg) { agg.id = 'agg_' + id++; }); - - data = buildHierarchicalData(stubVis, fixtures.threeTermBuckets); - - vis.render(data, persistedState); - })); - - afterEach(function () { - vis.destroy(); - }); describe('addPathEvents method', function () { let path; @@ -235,7 +117,7 @@ aggArray.forEach(function (dataAgg, i) { width = $(chart.chartEl).width(); height = $(chart.chartEl).height(); svg = d3.select($(chart.chartEl).find('svg')[0]); - slices = chart.chartData.slices; + slices = chart.chartData; }); })); @@ -292,6 +174,5 @@ aggArray.forEach(function (dataAgg, i) { }); }); }); - }); }); diff --git a/src/ui/public/vislib/__tests__/visualizations/time_marker.js b/src/ui/public/vislib/__tests__/visualizations/time_marker.js index fdc6273abeeec..883de31064a83 100644 --- a/src/ui/public/vislib/__tests__/visualizations/time_marker.js +++ b/src/ui/public/vislib/__tests__/visualizations/time_marker.js @@ -42,8 +42,8 @@ describe('Vislib Time Marker Test Suite', function () { beforeEach(ngMock.module('kibana')); beforeEach(ngMock.inject(function (Private) { TimeMarker = Private(VislibVisualizationsTimeMarkerProvider); - minDomain = getExtent(series.series, d3.min); - maxDomain = getExtent(series.series, d3.max); + minDomain = getExtent(series.charts[0].series, d3.min); + maxDomain = getExtent(series.charts[0].series, d3.max); domain = [minDomain, maxDomain]; xScale = d3.time.scale().domain(domain).range([0, 500]); defaultMarker = new TimeMarker(times, xScale, height); diff --git a/src/ui/public/vislib/lib/axis/axis_config.js b/src/ui/public/vislib/lib/axis/axis_config.js index f5c99b0fb3cb1..48dcf961a0c52 100644 --- a/src/ui/public/vislib/lib/axis/axis_config.js +++ b/src/ui/public/vislib/lib/axis/axis_config.js @@ -95,7 +95,7 @@ export function VislibLibAxisConfigProvider() { this.values = this._values.values; } if (!this._values.labels.axisFormatter) { - this._values.labels.axisFormatter = this.data.data.xAxisFormatter || this.data.get('xAxisFormatter'); + this._values.labels.axisFormatter = this.data.get('xAxisFormatter'); } } diff --git a/src/ui/public/vislib/lib/data.js b/src/ui/public/vislib/lib/data.js index 121314bc69644..bfd95eca755a0 100644 --- a/src/ui/public/vislib/lib/data.js +++ b/src/ui/public/vislib/lib/data.js @@ -1,15 +1,12 @@ import d3 from 'd3'; import _ from 'lodash'; import { VislibComponentsZeroInjectionInjectZerosProvider } from '../components/zero_injection/inject_zeros'; -import { VislibComponentsZeroInjectionOrderedXKeysProvider } from '../components/zero_injection/ordered_x_keys'; -import { VislibComponentsLabelsLabelsProvider } from '../components/labels/labels'; import { VislibComponentsColorColorProvider } from 'ui/vis/components/color/color'; +import { tooltipFormatter } from 'ui/vis/components/tooltip/formatter'; export function VislibLibDataProvider(Private) { const injectZeros = Private(VislibComponentsZeroInjectionInjectZerosProvider); - const orderKeys = Private(VislibComponentsZeroInjectionOrderedXKeysProvider); - const getLabels = Private(VislibComponentsLabelsLabelsProvider); const color = Private(VislibComponentsColorColorProvider); /** @@ -24,92 +21,47 @@ export function VislibLibDataProvider(Private) { class Data { constructor(data, uiState) { this.uiState = uiState; + this.type = this.getDataType(data); this.data = this.copyDataObj(data); - this.type = this.getDataType(); - this.labels = this._getLabels(this.data); + this.labels = this.getLabels(); this.color = this.labels ? color(this.labels, uiState.get('vis.colors')) : undefined; this._normalizeOrdered(); + + this.chartData()[0].tooltipFormatter = tooltipFormatter; } - copyDataObj(data) { - const copyChart = data => { - const newData = {}; - Object.keys(data).forEach(key => { - if (key !== 'series') { - newData[key] = data[key]; - } else { - newData[key] = data[key].map(seri => { - return { - label: seri.label, - aggLabel: seri.aggLabel, - aggId: seri.aggId, - values: seri.values.map(val => { - const newVal = _.clone(val); - newVal.aggConfig = val.aggConfig; - newVal.aggConfigResult = val.aggConfigResult; - newVal.extraMetrics = val.extraMetrics; - newVal.series = val.series || seri.label; - return newVal; - }) - }; - }); - } - }); - return newData; - }; + getDataType(data) { + if (!data.charts || !data.charts.length) return 'no data'; + if (data.charts[0].series) return 'series'; + if (data.charts[0].children) return 'slices'; + if (data.charts[0].cells) return 'table'; - if (!data.series) { - const newData = {}; - Object.keys(data).forEach(key => { - if (!['rows', 'columns'].includes(key)) { - newData[key] = data[key]; - } - else { - newData[key] = data[key].map(chart => { - return copyChart(chart); - }); - } - }); - return newData; - } - return copyChart(data); + throw ('vislib: invalid data format'); } - _getLabels(data) { - return this.type === 'series' ? getLabels(data) : this.pieNames(); + copyDataObj(data) { + if (data.split === 'row') { + return { rows: _.cloneDeep(data.charts) }; + } + return { columns: _.cloneDeep(data.charts) }; } - getDataType() { - const data = this.getVisData(); - let type; - - data.forEach(function (obj) { - if (obj.series) { - type = 'series'; - } else if (obj.slices) { - type = 'slices'; - } else if (obj.geoJson) { - type = 'geoJson'; - } - }); - - return type; + getLabels(data = this.chartData()) { + const getSeriesLabels = (data) => { + const labels = {}; + data.forEach(chart => { + _.each(chart.series, series => { + if (!labels[series.label]) labels[series.label] = 1; + }); + }); + return _.keys(labels); + }; + return this.type === 'series' ? getSeriesLabels(data) : this.pieNames(); } - /** - * Returns an array of the actual x and y data value objects - * from data with series keys - * - * @method chartData - * @returns {*} Array of data objects - */ chartData() { - if (!this.data.series) { - const arr = this.data.rows ? this.data.rows : this.data.columns; - return _.toArray(arr); - } - return [this.data]; + return this.data.columns || this.data.rows; } shouldBeStacked(seriesConfig) { @@ -141,65 +93,9 @@ export function VislibLibDataProvider(Private) { } stackData(handler) { - const data = this.data; - if (data.rows || data.columns) { - const charts = data.rows ? data.rows : data.columns; - charts.forEach((chart, i) => { - this.stackChartData(handler, chart.series, handler.visConfig.get(`charts[${i}]`)); - }); - } else { - this.stackChartData(handler, data.series, handler.visConfig.get('charts[0]')); - } - } - - /** - * Returns an array of chart data objects - * - * @method getVisData - * @returns {*} Array of chart data objects - */ - getVisData() { - let visData; - - if (this.data.rows) { - visData = this.data.rows; - } else if (this.data.columns) { - visData = this.data.columns; - } else { - visData = [this.data]; - } - - return visData; - } - - /** - * get min and max for all cols, rows of data - * - * @method getMaxMin - * @return {Object} - */ - getGeoExtents() { - const visData = this.getVisData(); - - return _.reduce(_.pluck(visData, 'geoJson.properties'), function (minMax, props) { - return { - min: Math.min(props.min, minMax.min), - max: Math.max(props.max, minMax.max) - }; - }, { min: Infinity, max: -Infinity }); - } - - /** - * Returns array of chart data objects for pie data objects - * - * @method pieData - * @returns {*} Array of chart data objects - */ - pieData() { - if (!this.data.slices) { - return this.data.rows ? this.data.rows : this.data.columns; - } - return [this.data]; + this.chartData().forEach((chart, i) => { + this.stackChartData(handler, chart.series, handler.visConfig.get(`charts[${i}]`)); + }); } /** @@ -213,7 +109,7 @@ export function VislibLibDataProvider(Private) { * @returns {*} Data object value */ get(thing, def) { - const source = (this.data.rows || this.data.columns || [this.data])[0]; + const source = this.chartData()[0]; return _.get(source, thing, def); } @@ -250,79 +146,17 @@ export function VislibLibDataProvider(Private) { .value(); } - /** - * Validates that the Y axis min value defined by user input - * is a number. - * - * @param val {Number} Y axis min value - * @returns {Number} Y axis min value - */ - validateUserDefinedYMin(val) { - if (!_.isNumber(val)) { - throw new Error('validateUserDefinedYMin expects a number'); - } - return val; - } - - /** - * Helper function for getNames - * Returns an array of objects with a name (key) value and an index value. - * The index value allows us to sort the names in the correct nested order. - * - * @method returnNames - * @param array {Array} Array of data objects - * @param index {Number} Number of times the object is nested - * @param columns {Object} Contains name formatter information - * @returns {Array} Array of labels (strings) - */ - returnNames(array, index, columns) { - const names = []; - const self = this; - - _.forEach(array, function (obj) { - names.push({ - label: obj.name, - values: obj, - index: index - }); - - if (obj.children) { - const plusIndex = index + 1; - - _.forEach(self.returnNames(obj.children, plusIndex, columns), function (namedObj) { - names.push(namedObj); + getNames(slices) { + return slices + .reduce((slices, slice) => { + if (slice.children && slice.children.length) { + slices = slices.concat(this.getNames(slice.children)); + } + slices.push({ + label: slice.label }); - } - }); - - return names; - } - - /** - * Flattens hierarchical data into an array of objects with a name and index value. - * The indexed value determines the order of nesting in the data. - * Returns an array with names sorted by the index value. - * - * @method getNames - * @param data {Object} Chart data object - * @param columns {Object} Contains formatter information - * @returns {Array} Array of names (strings) - */ - getNames(data, columns) { - const slices = data.slices; - - if (slices.children) { - const namedObj = this.returnNames(slices.children, 0, columns); - - return _(namedObj) - .sortBy(function (obj) { - return obj.index; - }) - .unique(function (d) { - return d.label; - }) - .value(); - } + return slices; + }, []); } /** @@ -330,20 +164,19 @@ export function VislibLibDataProvider(Private) { * @param slices * @returns {*} */ - _removeZeroSlices(slices) { + _removeZeroSlices(data) { const self = this; - if (!slices.children) return slices; + if (!data.children || !data.children.length) return data; - slices = _.clone(slices); - slices.children = slices.children.reduce(function (children, child) { - if (child.size !== 0) { + data.children = data.children.reduce(function (children, child) { + if (child.values[0].value !== 0) { children.push(self._removeZeroSlices(child)); } return children; }, []); - return slices; + return data; } /** @@ -358,10 +191,9 @@ export function VislibLibDataProvider(Private) { const names = []; _.forEach(data, function (obj) { - const columns = obj.raw ? obj.raw.columns : undefined; - obj.slices = self._removeZeroSlices(obj.slices); + obj = self._removeZeroSlices(obj); - _.forEach(self.getNames(obj, columns), function (name) { + _.forEach(self.getNames(obj.children), function (name) { names.push(name); }); }); @@ -386,19 +218,26 @@ export function VislibLibDataProvider(Private) { * @returns {Array} Array of x axis values */ xValues(orderBucketsBySum = false) { - return orderKeys(this.data, orderBucketsBySum); - } - - /** - * Return an array of unique labels - * Curently, only used for vertical bar and line charts, - * or any data object with series values - * - * @method getLabels - * @returns {Array} Array of labels (strings) - */ - getLabels() { - return getLabels(this.data); + const buckets = []; + this.chartData().forEach(chart => { + _.each(chart.series, series => { + series.values.forEach(value => { + const bucket = buckets.find(bucket => bucket.label === value.x); + if (bucket) { + bucket.value += value.y; + } else { + buckets.push({ + label: value.x, + value: value.y + }); + } + }); + }); + }); + if (orderBucketsBySum) { + return _.sortByOrder(buckets, 'value', 'desc').map(bucket => bucket.label); + } + return buckets.map(bucket => bucket.label); } /** @@ -424,7 +263,7 @@ export function VislibLibDataProvider(Private) { * @returns {Function} Performs lookup on string and returns hex color */ getPieColorFunc() { - return color(this.pieNames(this.getVisData()).map(function (d) { + return color(this.pieNames(this.chartData()).map(function (d) { return d.label; }), this.uiState.get('vis.colors')); } @@ -436,7 +275,7 @@ export function VislibLibDataProvider(Private) { * @return {undefined} */ _normalizeOrdered() { - const data = this.getVisData(); + const data = this.chartData(); const self = this; data.forEach(function (d) { @@ -447,29 +286,12 @@ export function VislibLibDataProvider(Private) { if (missingMax || missingMin) { const extent = d3.extent(self.xValues()); - if (missingMin) d.ordered.min = extent[0]; - if (missingMax) d.ordered.max = extent[1]; + if (missingMin) d.ordered.min = parseInt(extent[0]); + if (missingMax) d.ordered.max = parseInt(extent[1]); } }); } - /** - * Calculates min and max values for all map data - * series.rows is an array of arrays - * each row is an array of values - * last value in row array is bucket count - * - * @method mapDataExtents - * @param series {Array} Array of data objects - * @returns {Array} min and max values - */ - mapDataExtents(series) { - const values = _.map(series.rows, function (row) { - return row[row.length - 1]; - }); - return [_.min(values), _.max(values)]; - } - /** * Get the maximum number of series, considering each chart * individually. diff --git a/src/ui/public/vislib/lib/dispatch.js b/src/ui/public/vislib/lib/dispatch.js index 74edb63fe54c4..470b9d7b9099d 100644 --- a/src/ui/public/vislib/lib/dispatch.js +++ b/src/ui/public/vislib/lib/dispatch.js @@ -30,52 +30,40 @@ export function VislibLibDispatchProvider(Private, config) { * e: (d3.event|*), handler: (Object|*)}} Event response object */ eventResponse(d, i) { - const datum = d._input || d; - const data = d3.event.target.nearestViewportElement ? - d3.event.target.nearestViewportElement.__data__ : d3.event.target.__data__; - const label = d.label ? d.label : (d.series || 'Count'); - const isSeries = !!(data && data.series); - const isSlices = !!(data && data.slices); - const series = isSeries ? data.series : undefined; - const slices = isSlices ? data.slices : undefined; const handler = this.handler; - const color = _.get(handler, 'data.color'); + + const chartData = d3.event.target.nearestViewportElement ? + d3.event.target.nearestViewportElement.__data__ : d3.event.target.__data__; const eventData = { - value: d.y, - point: datum, - datum: datum, - label: label, - color: color ? color(label) : undefined, + point: d3.event.target.__data__, pointIndex: i, - series: series, - slices: slices, - config: handler && handler.visConfig, - data: data, + handler: handler, + chartData: chartData, e: d3.event, - handler: handler + label: 'Count', + color: _.get(handler, 'data.color') }; - if (isSeries) { - let percentageMode = false; - //only series charts work in percentage mode. - if (handler.charts && handler.charts[0] && handler.charts[0].getSeries && d3.event.target.parentElement.__data__) { - const aggId = d3.event.target.parentElement.__data__.aggId; - const seriesFromAggId = handler.charts[0].getSeries(aggId); - if (seriesFromAggId && seriesFromAggId.getValueAxis) { - percentageMode = seriesFromAggId.getValueAxis().axisConfig.isPercentage(); - } - } - - const object = _.find(series, { 'label': label }); - if (object) { - eventData.value = +object.values[i].y; - - if (percentageMode) { - // Add the formatted percentage to the point object - eventData.percent = (100 * d.y).toFixed(1) + '%'; + switch (handler.data.type) { + case 'series': + let element = d3.event.target.parentNode; + while (true) { + if (!element.__data__) throw('vislib dispatch: series data was not found'); + if (element.__data__.label) break; + element = element.parentNode; } - } + eventData.seriesData = element.__data__; + eventData.aggs = eventData.seriesData.aggs; + eventData.label = eventData.seriesData.label; + break; + case 'slices': + eventData.point = _.cloneDeep(d); + eventData.aggs = eventData.point.values[0].aggs || eventData.point.aggs; + delete eventData.point.values; + break; + default: + throw('vislib dispatch: unknown data type'); } return eventData; diff --git a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js index 014582b2ee135..dd6e652ca5741 100644 --- a/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js +++ b/src/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js @@ -41,7 +41,7 @@ export function VislibLibLayoutSplitsPieChartChartSplitProvider() { return divClass; }); - if (!data.slices) { + if (!data.children) { charts.call(split); } }); diff --git a/src/ui/public/vislib/lib/types/point_series.js b/src/ui/public/vislib/lib/types/point_series.js index be3cf56c7f246..4df6f989efb9f 100644 --- a/src/ui/public/vislib/lib/types/point_series.js +++ b/src/ui/public/vislib/lib/types/point_series.js @@ -120,7 +120,7 @@ export function VislibTypesPointSeries() { id: 'CategoryAxis-1', type: 'category', labels: { - axisFormatter: data.data.xAxisFormatter || data.get('xAxisFormatter') + axisFormatter: data.get('xAxisFormatter') }, scale: { expandLastBucket: opts.expandLastBucket diff --git a/src/ui/public/vislib/visualizations/gauges/meter.js b/src/ui/public/vislib/visualizations/gauges/meter.js index 94a87eb27e8b9..50b91cce0854d 100644 --- a/src/ui/public/vislib/visualizations/gauges/meter.js +++ b/src/ui/public/vislib/visualizations/gauges/meter.js @@ -155,13 +155,11 @@ export function MeterGaugeProvider() { const angleFactor = this.gaugeConfig.gaugeType === 'Meter' ? 0.75 : 1; const maxRadius = (Math.min(width, height / angleFactor) / 2) * marginFactor; - const extendRange = this.gaugeConfig.extendRange; - const maxY = _.max(data.values, 'y').y; const min = this.gaugeConfig.colorsRange[0].from; const max = _.last(this.gaugeConfig.colorsRange).to; const angle = d3.scale.linear() .range([minAngle, maxAngle]) - .domain([min, extendRange && max < maxY ? maxY : max]); + .domain([min, max]); const radius = d3.scale.linear() .range([0, maxRadius]) .domain([this.gaugeConfig.innerSpace + 1, 0]); @@ -197,12 +195,12 @@ export function MeterGaugeProvider() { .data([data]) .enter() .append('g') - .attr('data-label', (d) => this.getLabel(d.values[0].y)); + .attr('data-label', (d) => this.getLabel(_.last(d.values).y)); const gauges = gaugeHolders .selectAll('g') - .data(d => d.values) + .data(d => [ _.last(d.values) ]) .enter(); @@ -262,10 +260,7 @@ export function MeterGaugeProvider() { const percentage = Math.round(100 * (d.y - min) / (max - min)); return `${percentage}%`; } - if (d.aggConfig) { - return d.aggConfig.fieldFormatter('text')(d.y); - } - return d.y; + return data.formatter ? data.formatter(d.y) : d.y; }) .attr('style', 'dominant-baseline: central;') .style('text-anchor', 'middle') diff --git a/src/ui/public/vislib/visualizations/gauges/simple.js b/src/ui/public/vislib/visualizations/gauges/simple.js index 3116aa752b484..c40c56a7e96fd 100644 --- a/src/ui/public/vislib/visualizations/gauges/simple.js +++ b/src/ui/public/vislib/visualizations/gauges/simple.js @@ -116,12 +116,12 @@ export function SimpleGaugeProvider() { .data([data]) .enter() .append('g') - .attr('data-label', (d) => this.getLabel(d.values[0].y)); + .attr('data-label', (d) => this.getLabel(_.last(d.values).y)); const gauges = gaugeHolders .selectAll('g') - .data(d => d.values) + .data(d => { return [ _.last(d.values) ]; }) .enter(); @@ -178,16 +178,13 @@ export function SimpleGaugeProvider() { const percentage = Math.round(100 * (d.y - min) / (max - min)); return `${percentage}%`; } - if (d.aggConfig) { - return d.aggConfig.fieldFormatter('text')(d.y); - } - return d.y; + return data.formatter ? data.formatter(d.y) : d.y; }) .attr('style', 'dominant-baseline: central; font-weight: bold; white-space: nowrap;text-overflow: ellipsis;overflow: hidden;') .style('text-anchor', 'middle') .style('font-size', fontSize + 'pt') .style('fill', function () { - return !bgColor && labelColor ? self.getColorBucket(data.values[0].y) : bgFill; + return !bgColor && labelColor ? self.getColorBucket(data.value) : bgFill; }); if (isTooltip) { diff --git a/src/ui/public/vislib/visualizations/pie_chart.js b/src/ui/public/vislib/visualizations/pie_chart.js index 7bb27deaf167f..b2f1077b84909 100644 --- a/src/ui/public/vislib/visualizations/pie_chart.js +++ b/src/ui/public/vislib/visualizations/pie_chart.js @@ -28,7 +28,7 @@ export function VislibVisualizationsPieChartProvider(Private) { constructor(handler, chartEl, chartData) { super(handler, chartEl, chartData); - const charts = this.handler.data.getVisData(); + const charts = this.handler.data.chartData(); this._validatePieData(charts); this._attr = _.defaults(handler.visConfig.get('chart', {}), defaults); @@ -41,7 +41,7 @@ export function VislibVisualizationsPieChartProvider(Private) { */ _validatePieData(charts) { const isAllZeros = charts.every(function (chart) { - return chart.slices.children.length === 0; + return chart.children.length === 0; }); if (isAllZeros) { @@ -74,11 +74,11 @@ export function VislibVisualizationsPieChartProvider(Private) { const parentPercent = parent.percentOfParent; const sum = parent.sumOfChildren = Math.abs(children.reduce(function (sum, child) { - return sum + Math.abs(child.size); + return sum + Math.abs(child.values[0].value); }, 0)); children.forEach(function (child) { - child.percentOfGroup = Math.abs(child.size) / sum; + child.percentOfGroup = Math.abs(child.values[0].value) / sum; child.percentOfParent = child.percentOfGroup; if (parentPercent != null) { @@ -154,13 +154,13 @@ export function VislibVisualizationsPieChartProvider(Private) { } return 'slice'; }) - .call(self._addIdentifier, 'name') + .call(self._addIdentifier, 'label') .style('stroke', '#fff') .style('fill', function (d) { if (d.depth === 0) { return 'none'; } - return color(d.name); + return color(d.label); }); if (isTooltip) { @@ -190,14 +190,11 @@ export function VislibVisualizationsPieChartProvider(Private) { return function (selection) { selection.each(function (data) { - const slices = data.slices; const div = d3.select(this); const width = $(this).width(); const height = $(this).height(); - if (!slices.children.length) return; - - self.convertToPercentage(slices); + self.convertToPercentage(data); self._validateContainerSize(width, height); const svg = div.append('svg') @@ -206,7 +203,7 @@ export function VislibVisualizationsPieChartProvider(Private) { .append('g') .attr('transform', 'translate(' + width / 2 + ',' + height / 2 + ')'); - const path = self.addPath(width, height, svg, slices); + const path = self.addPath(width, height, svg, data); self.addPathEvents(path); self.events.emit('rendered', { diff --git a/src/ui/public/vislib/visualizations/point_series/area_chart.js b/src/ui/public/vislib/visualizations/point_series/area_chart.js index cd7aeb4d581e0..178d1d4a761a5 100644 --- a/src/ui/public/vislib/visualizations/point_series/area_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/area_chart.js @@ -69,6 +69,14 @@ export function VislibVisualizationsAreaChartProvider(Private) { const yScale = this.getValueAxis().getScale(); const interpolate = this.seriesConfig.interpolate; const isHorizontal = this.getCategoryAxis().axisConfig.isHorizontal(); + const isPercentage = this.getValueAxis().axisConfig.isPercentage(); + + if (isPercentage && this.chartData.aggs) { + data.aggs[0].value = 'val'; + data.values.forEach(value => { + value.val = Math.round(value.y * 100) + '%'; + }); + } // Data layers const layer = svg.append('g') diff --git a/src/ui/public/vislib/visualizations/point_series/column_chart.js b/src/ui/public/vislib/visualizations/point_series/column_chart.js index 46c307a99ce4e..27c79f1b99134 100644 --- a/src/ui/public/vislib/visualizations/point_series/column_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/column_chart.js @@ -49,6 +49,7 @@ export function VislibVisualizationsColumnChartProvider(Private) { const color = this.handler.data.getColorFunc(); const tooltip = this.baseChart.tooltip; const isTooltip = this.handler.visConfig.get('tooltip.show'); + const isPercentage = this.getValueAxis().axisConfig.isPercentage(); const layer = svg.append('g') .attr('class', 'series histogram') @@ -59,6 +60,13 @@ export function VislibVisualizationsColumnChartProvider(Private) { return !_.isNull(d.y); })); + if (isPercentage && this.chartData.aggs) { + data.aggs[0].value = 'val'; + data.values.forEach(value => { + value.val = Math.round(value.y * 100) + '%'; + }); + } + bars .exit() .remove(); diff --git a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js index 81cb4cb739409..c5ef0af757a7e 100644 --- a/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/heatmap_chart.js @@ -114,6 +114,15 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { const zAxisConfig = this.getValueAxis().axisConfig; const zAxisFormatter = zAxisConfig.get('labels.axisFormatter'); const showLabels = zAxisConfig.get('labels.show'); + const percentageMode = this.handler.visConfig.get('percentageMode'); + + const [min, max] = zScale.domain(); + if (percentageMode && this.chartData.aggs) { + this.chartData.aggs[0].value = 'val'; + this.chartData.values.forEach(value => { + value.val = Math.round(100 * (value.y - min) / (max - min)) + '%'; + }); + } const layer = svg.append('g') .attr('class', 'series'); @@ -140,11 +149,10 @@ export function VislibVisualizationsHeatmapChartProvider(Private) { return xScale(d.x); } - function y(d) { - return yScale(d.series); + function y() { + return yScale(data.label); } - const [min, max] = zScale.domain(); function getColorBucket(d) { let val = 0; if (setColorRange && colorsRange.length) { diff --git a/src/ui/public/vislib/visualizations/point_series/line_chart.js b/src/ui/public/vislib/visualizations/point_series/line_chart.js index 4b9d8521c1039..9d7fb7d345be0 100644 --- a/src/ui/public/vislib/visualizations/point_series/line_chart.js +++ b/src/ui/public/vislib/visualizations/point_series/line_chart.js @@ -43,6 +43,14 @@ export function VislibVisualizationsLineChartProvider(Private) { const isTooltip = this.handler.visConfig.get('tooltip.show'); const isHorizontal = this.getCategoryAxis().axisConfig.isHorizontal(); const lineWidth = this.seriesConfig.lineWidth; + const isPercentage = this.getValueAxis().axisConfig.isPercentage(); + + if (isPercentage && this.chartData.aggs) { + data.aggs[0].value = 'val'; + data.values.forEach(value => { + value.val = Math.round(value.y * 100) + '%'; + }); + } const radii = this.baseChart.radii; @@ -77,18 +85,18 @@ export function VislibVisualizationsLineChartProvider(Private) { return yScale(y0 + y); } - function cColor(d) { - return color(d.series); + function cColor() { + return color(data.label); } - function colorCircle(d) { + function colorCircle() { const parent = d3.select(this).node().parentNode; const lengthOfParent = d3.select(parent).data()[0].length; const isVisible = (lengthOfParent === 1); // If only 1 point exists, show circle if (!showCircles && !isVisible) return 'none'; - return cColor(d); + return cColor(); } function getCircleRadiusFn(modifier) { diff --git a/src/ui/public/vislib/visualizations/time_marker.js b/src/ui/public/vislib/visualizations/time_marker.js index 06845d69b2c1f..b257dc2a5083c 100644 --- a/src/ui/public/vislib/visualizations/time_marker.js +++ b/src/ui/public/vislib/visualizations/time_marker.js @@ -27,7 +27,7 @@ export function VislibVisualizationsTimeMarkerProvider() { } _isTimeBasedChart(selection) { - const data = selection.data(); + const data = selection.data()[0].charts; return data.every(function (datum) { return (datum.ordered && datum.ordered.date); }); diff --git a/src/ui/public/visualize/visualize_legend.js b/src/ui/public/visualize/visualize_legend.js index a3211ceef8ec2..818ebd1a221d5 100644 --- a/src/ui/public/visualize/visualize_legend.js +++ b/src/ui/public/visualize/visualize_legend.js @@ -134,7 +134,7 @@ uiModules.get('kibana') // Most of these functions were moved directly from the old Legend class. Not a fan of this. function getLabels(data, type) { if (!data) return []; - data = data.columns || data.rows || [data]; + data = data.charts; if (type === 'pie') return Data.prototype.pieNames(data); return getSeriesLabels(data); } diff --git a/src/ui/ui_exports.js b/src/ui/ui_exports.js index ba8c57f8479d2..60f172e620c7a 100644 --- a/src/ui/ui_exports.js +++ b/src/ui/ui_exports.js @@ -16,7 +16,9 @@ export default class UiExports { ], visResponseHandlers: [ 'ui/vis/response_handlers/basic', - 'ui/vis/response_handlers/none' + 'ui/vis/response_handlers/none', + 'ui/vis/response_handlers/series_data', + 'ui/vis/response_handlers/hierarchical_data', ], visEditorTypes: [ 'ui/vis/editors/default/default',