-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[D&D] Adds Bar line and Area charts to Wizard #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ashwin-pc
merged 10 commits into
opensearch-project:main
from
ashwin-pc:feature/histogram-dnd
Sep 8, 2022
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8fbd20f
Working histogram
ashwin-pc 7841c81
Adds histogram options
ashwin-pc aa3c2ac
Adds line chart
ashwin-pc f71d630
Adds area chart
ashwin-pc b49ba63
updates nav sizes
ashwin-pc 3b6c3d3
adds resizeable container to right nav
ashwin-pc 3769a3a
Misc fixes
ashwin-pc 240cc1e
Adds chart switcher test
ashwin-pc e8b4899
Github comment feedback
ashwin-pc dd6aadd
Updates copy
ashwin-pc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
42 changes: 42 additions & 0 deletions
42
src/plugins/wizard/public/visualizations/common/expression_helpers.ts
This file contains hidden or 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,42 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { cloneDeep } from 'lodash'; | ||
| import { OpenSearchaggsExpressionFunctionDefinition } from '../../../../data/public'; | ||
| import { ExpressionFunctionOpenSearchDashboards } from '../../../../expressions'; | ||
| import { buildExpressionFunction } from '../../../../expressions/public'; | ||
| import { VisualizationState } from '../../application/utils/state_management'; | ||
| import { getAggService, getIndexPatterns } from '../../plugin_services'; | ||
|
|
||
| export const getAggExpressionFunctions = async (visualization: VisualizationState) => { | ||
| const { activeVisualization, indexPattern: indexId = '' } = visualization; | ||
| const { aggConfigParams } = activeVisualization || {}; | ||
|
|
||
| const indexPatternsService = getIndexPatterns(); | ||
| const indexPattern = await indexPatternsService.get(indexId); | ||
| const aggConfigs = getAggService().createAggConfigs(indexPattern, cloneDeep(aggConfigParams)); | ||
|
ashwin-pc marked this conversation as resolved.
|
||
|
|
||
| const opensearchDashboards = buildExpressionFunction<ExpressionFunctionOpenSearchDashboards>( | ||
| 'opensearchDashboards', | ||
| {} | ||
| ); | ||
|
|
||
| // soon this becomes: const opensearchaggs = vis.data.aggs!.toExpressionAst(); | ||
| const opensearchaggs = buildExpressionFunction<OpenSearchaggsExpressionFunctionDefinition>( | ||
| 'opensearchaggs', | ||
| { | ||
| index: indexId, | ||
| metricsAtAllLevels: false, | ||
| partialRows: false, | ||
|
joshuarrrr marked this conversation as resolved.
|
||
| aggConfigs: JSON.stringify(aggConfigs.aggs), | ||
| includeFormatHints: false, | ||
| } | ||
| ); | ||
|
|
||
| return { | ||
| aggConfigs, | ||
| expressionFns: [opensearchDashboards, opensearchaggs], | ||
| }; | ||
| }; | ||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,18 +3,13 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { cloneDeep } from 'lodash'; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! |
||
| import { SchemaConfig } from '../../../../visualizations/public'; | ||
| import { MetricVisExpressionFunctionDefinition } from '../../../../vis_type_metric/public'; | ||
| import { | ||
| AggConfigs, | ||
| IAggConfig, | ||
| OpenSearchaggsExpressionFunctionDefinition, | ||
| } from '../../../../data/common'; | ||
| import { AggConfigs, IAggConfig } from '../../../../data/common'; | ||
| import { buildExpression, buildExpressionFunction } from '../../../../expressions/public'; | ||
| import { RootState } from '../../application/utils/state_management'; | ||
| import { MetricOptionsDefaults } from './metric_viz_type'; | ||
| import { getAggService, getIndexPatterns } from '../../plugin_services'; | ||
| import { getAggExpressionFunctions } from '../common/expression_helpers'; | ||
|
|
||
| const prepareDimension = (params: SchemaConfig) => { | ||
| const visdimension = buildExpressionFunction('visdimension', { accessor: params.accessor }); | ||
|
|
@@ -92,24 +87,7 @@ export interface MetricRootState extends RootState { | |
| } | ||
|
|
||
| export const toExpression = async ({ style: styleState, visualization }: MetricRootState) => { | ||
| const { activeVisualization, indexPattern: indexId = '' } = visualization; | ||
| const { aggConfigParams } = activeVisualization || {}; | ||
|
|
||
| const indexPatternsService = getIndexPatterns(); | ||
| const indexPattern = await indexPatternsService.get(indexId); | ||
| const aggConfigs = getAggService().createAggConfigs(indexPattern, cloneDeep(aggConfigParams)); | ||
|
|
||
| // soon this becomes: const opensearchaggs = vis.data.aggs!.toExpressionAst(); | ||
| const opensearchaggs = buildExpressionFunction<OpenSearchaggsExpressionFunctionDefinition>( | ||
| 'opensearchaggs', | ||
| { | ||
| index: indexId, | ||
| metricsAtAllLevels: false, | ||
| partialRows: false, | ||
| aggConfigs: JSON.stringify(aggConfigs.aggs), | ||
| includeFormatHints: false, | ||
| } | ||
| ); | ||
| const { aggConfigs, expressionFns } = await getAggExpressionFunctions(visualization); | ||
|
|
||
| // TODO: Update to use the getVisSchemas function from the Visualizations plugin | ||
| // const schemas = getVisSchemas(vis, params); | ||
|
|
@@ -169,7 +147,5 @@ export const toExpression = async ({ style: styleState, visualization }: MetricR | |
| metricVis.addArgument('metric', prepareDimension(metric)); | ||
| }); | ||
|
|
||
| const ast = buildExpression([opensearchaggs, metricVis]); | ||
|
|
||
| return `opensearchDashboards | opensearch_dashboards_context | ${ast.toString()}`; | ||
| return buildExpression([...expressionFns, metricVis]).toString(); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.