-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep preferred type in transformational commands too
- Loading branch information
Showing
2 changed files
with
44 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/plugins/unified_histogram/public/utils/get_preferred_chart_type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
import type { PieVisualizationState, XYState } from '@kbn/lens-plugin/public'; | ||
import type { ChartType } from '@kbn/visualization-utils'; | ||
import type { UnifiedHistogramVisContext } from '../types'; | ||
|
||
export const getPreferredChartType = (visAttributes: UnifiedHistogramVisContext['attributes']) => { | ||
let preferredChartType = visAttributes ? visAttributes?.visualizationType : undefined; | ||
|
||
if (preferredChartType === 'lnsXY') { | ||
preferredChartType = (visAttributes?.state?.visualization as XYState)?.preferredSeriesType; | ||
} | ||
if (preferredChartType === 'lnsPie') { | ||
preferredChartType = (visAttributes?.state?.visualization as PieVisualizationState)?.shape; | ||
} | ||
|
||
return preferredChartType as ChartType; | ||
}; |