From a10560458ce92ef0ee7e6e5fc3f3240e8432ad3b Mon Sep 17 00:00:00 2001 From: rshen91 Date: Tue, 22 Jun 2021 07:18:39 -0600 Subject: [PATCH] fix: merge changes --- .../state/selectors/get_goal_chart_data.ts | 48 +++++++++++++++++++ .../renderer/canvas/partition.tsx | 3 +- .../accessibility/goal_description.tsx | 10 ++-- .../src/components/accessibility/index.ts | 1 + 4 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 packages/charts/src/chart_types/goal_chart/state/selectors/get_goal_chart_data.ts diff --git a/packages/charts/src/chart_types/goal_chart/state/selectors/get_goal_chart_data.ts b/packages/charts/src/chart_types/goal_chart/state/selectors/get_goal_chart_data.ts new file mode 100644 index 0000000000..8092ae8c00 --- /dev/null +++ b/packages/charts/src/chart_types/goal_chart/state/selectors/get_goal_chart_data.ts @@ -0,0 +1,48 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { createCustomCachedSelector } from '../../../../state/create_selector'; +import { geometries } from './geometries'; + +/** @internal */ +export type GoalChartData = { + maximum: number; + minimum: number; + target: number; + value: number; +}; + +/** @internal */ +export const getGoalChartDataSelector = createCustomCachedSelector( + [geometries], + (geoms): GoalChartData => { + const goalChartData: GoalChartData = { + maximum: geoms.bulletViewModel.highestValue, + minimum: geoms.bulletViewModel.lowestValue, + target: geoms.bulletViewModel.target, + value: geoms.bulletViewModel.actual, + }; + return goalChartData; + }, +); + +/** @internal */ +export const getGoalChartLabelsSelector = createCustomCachedSelector([geometries], (geoms) => { + return { label: geoms.bulletViewModel.labelMajor, minorLabel: geoms.bulletViewModel.labelMinor }; +}); diff --git a/packages/charts/src/chart_types/partition_chart/renderer/canvas/partition.tsx b/packages/charts/src/chart_types/partition_chart/renderer/canvas/partition.tsx index fe0f0e1d4c..c7fcc8b7c7 100644 --- a/packages/charts/src/chart_types/partition_chart/renderer/canvas/partition.tsx +++ b/packages/charts/src/chart_types/partition_chart/renderer/canvas/partition.tsx @@ -21,8 +21,7 @@ import React, { MouseEvent, RefObject } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators, Dispatch } from 'redux'; -import { ScreenReaderSummary } from '../../../../components/accessibility'; -import { ScreenReaderPartitionTable } from '../../../../components/accessibility/partitions_data_table'; +import { ScreenReaderSummary, ScreenReaderPartitionTable } from '../../../../components/accessibility'; import { clearCanvas } from '../../../../renderers/canvas'; import { SettingsSpec } from '../../../../specs/settings'; import { onChartRendered } from '../../../../state/actions/chart'; diff --git a/packages/charts/src/components/accessibility/goal_description.tsx b/packages/charts/src/components/accessibility/goal_description.tsx index 8a84913e9d..43ea79322f 100644 --- a/packages/charts/src/components/accessibility/goal_description.tsx +++ b/packages/charts/src/components/accessibility/goal_description.tsx @@ -17,10 +17,8 @@ * under the License. */ -import createCachedSelector from 're-reselect'; - import { geometries } from '../../chart_types/goal_chart/state/selectors/geometries'; -import { getChartIdSelector } from '../../state/selectors/get_chart_id'; +import { createCustomCachedSelector } from '../../state/create_selector'; /** @internal */ export type GoalChartData = { @@ -31,9 +29,9 @@ export type GoalChartData = { }; /** @internal */ -export const getGoalChartDataSelector = createCachedSelector( +export const getGoalChartDataSelector = createCustomCachedSelector( [geometries], - (geoms): GoalChartData => { + (geoms: any): GoalChartData => { const goalChartData: GoalChartData = { maximum: geoms.bulletViewModel.highestValue, minimum: geoms.bulletViewModel.lowestValue, @@ -42,4 +40,4 @@ export const getGoalChartDataSelector = createCachedSelector( }; return goalChartData; }, -)(getChartIdSelector); +); diff --git a/packages/charts/src/components/accessibility/index.ts b/packages/charts/src/components/accessibility/index.ts index c4b3e8087d..d20347fcdb 100644 --- a/packages/charts/src/components/accessibility/index.ts +++ b/packages/charts/src/components/accessibility/index.ts @@ -19,3 +19,4 @@ /* @internal */ export { ScreenReaderSummary } from './screen_reader_summary'; +export { ScreenReaderPartitionTable } from './partitions_data_table';