-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/Pie chart legend, chart style, color theme and cypress test c…
…ases for same. (#776) * pie chart legends, chart color contrast and cypress test cases Signed-off-by: Deepak Nevde <[email protected]> * Added color code in constants Signed-off-by: Deepak Nevde <[email protected]> * Snapshots updated Signed-off-by: Deepak Nevde <[email protected]> * Conflicts resolved Signed-off-by: Deepak Nevde <[email protected]> * Review comment addressed Signed-off-by: Deepak Nevde <[email protected]> * color variable changes Signed-off-by: Deepak Nevde <[email protected]>
- Loading branch information
1 parent
ccee0d3
commit 10abff2
Showing
11 changed files
with
344 additions
and
20 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
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
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
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
41 changes: 41 additions & 0 deletions
41
...explorer/visualizations/config_panel/config_panes/config_controls/config_button_group.tsx
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,41 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { uniqueId } from 'lodash'; | ||
import { EuiTitle, EuiSpacer, EuiButtonGroup } from '@elastic/eui'; | ||
interface ToggleButtonOptions { | ||
id: string; | ||
label: string; | ||
} | ||
interface ToggleGroupProps { | ||
title: string; | ||
legend: string; | ||
groupOptions: ToggleButtonOptions[]; | ||
idSelected: string; | ||
handleButtonChange: (id: string, value?: any) => void; | ||
} | ||
export const ButtonGroupItem: React.FC<ToggleGroupProps> = ({ | ||
title, legend, groupOptions, idSelected, handleButtonChange | ||
}) => ( | ||
<> | ||
<EuiTitle size="xxs"> | ||
<h3>{title}</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<div style={{ width: "fit-content" }}> | ||
<EuiButtonGroup | ||
id={uniqueId('button-select-')} | ||
name={title} | ||
legend={legend} | ||
options={groupOptions} | ||
idSelected={idSelected} | ||
onChange={handleButtonChange} | ||
buttonSize="compressed" | ||
isFullWidth={false} | ||
/> | ||
</div> | ||
</> | ||
); |
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
50 changes: 50 additions & 0 deletions
50
...ytics/explorer/visualizations/config_panel/config_panes/config_controls/config_legend.tsx
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,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useCallback, useMemo } from 'react'; | ||
import { EuiAccordion, EuiSpacer } from '@elastic/eui'; | ||
import { ButtonGroupItem } from './config_button_group'; | ||
import { IConfigPanelOptionSection } from '../../../../../../../../common/types/explorer'; | ||
|
||
export const ConfigLegend = ({ schemas, vizState, handleConfigChange }: any) => { | ||
const handleConfigurationChange = useCallback( | ||
(stateFiledName) => { | ||
return (changes) => { | ||
handleConfigChange({ | ||
...vizState, | ||
[stateFiledName]: changes, | ||
}); | ||
}; | ||
}, | ||
[handleConfigChange, vizState] | ||
); | ||
|
||
const dimensions = useMemo(() => { | ||
return schemas.map((schema: IConfigPanelOptionSection, index: number) => { | ||
const DimensionComponent = schema.component || ButtonGroupItem; | ||
const params = { | ||
title: schema.name, | ||
legend: schema.name, | ||
groupOptions: schema?.props?.options.map((btn: { name: string }) => ({ ...btn, label: btn.name })), | ||
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id, | ||
handleButtonChange: handleConfigurationChange(schema.mapTo), | ||
vizState, | ||
...schema.props, | ||
}; | ||
return ( | ||
<> | ||
<DimensionComponent key={`viz-series-${index}`} {...params} /> | ||
<EuiSpacer size="s" /> | ||
</> | ||
); | ||
}); | ||
}, [schemas, vizState, handleConfigurationChange]);; | ||
|
||
return ( | ||
<EuiAccordion initialIsOpen id="configPanel__legend" buttonContent="Legend" paddingSize="s"> | ||
{dimensions} | ||
</EuiAccordion> | ||
); | ||
}; |
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
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
Oops, something went wrong.