Skip to content
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

Legend, Chart styles, and Color Theme features implementation for Bar chart on config panel - 697 #4

Closed
wants to merge 9 commits into from

Conversation

rinku-kumar-psl
Copy link
Owner

@rinku-kumar-psl rinku-kumar-psl commented May 30, 2022

Description

[Describe what this change achieves]
The below features are implemented in the config panel in this PR:

Legend:

  • Show Legend
  • Position

Chart styles:

  • Orientation(Vertical, Horizontal)
  • Mode (Stack, Group)
  • Rotate bar labels
  • Group width
  • Bar width
  • Line Width
  • Fill Opacity

Color Theme

Here are the visuals and implementation of new Data configs on the Bar chart as per the issue opensearch-project#697
opensearch-project#697 (comment)

Issues Resolved

[List any issues this PR will resolve]
opensearch-project#697

Check List

  • New functionality includes above listed Legend and Chart styles features in the Data config panel.
  • All tests that pass, including unit test, and integration test, except a few test cases, are failing at my end which is not related to this functionality.
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: rinku-kumar-psl <[email protected]>
@@ -186,9 +186,11 @@ export interface IConfigPanelOptions {
export interface IConfigPanelOptionSection {
name: string;
component: null;
mapTo: 'mode';
mapTo: 'mode' | string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't only string going to be sufficient here? 'mode' is also a string.

const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFiledName) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean field or filled? Looks like there is a typo.

}, [vizState]);

const dimensions = useMemo(() =>
currentSchemas.map((schema: IConfigPanelOptionSection, index: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index in map function is always an integer.

};
} else if (schema.eleType === 'slider') {
params = {
minRange: schema?.props?.min,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is going to happen, if either schema or props is not available? As you mentioned, they are optional here and it may happen that minRange may be undefined. Are we handling that situation?
Same is applicable for maxRange as well.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Subrat,

For minRange its handled if it's undefined or not passed, EUI Range component will take default minRange as 0. But we have to make maxRange as required filed for slider. So made the required changes.

title: schema.name,
currentRange: vizState[schema.mapTo] || schema?.defaultState,
ticks: schema?.props?.ticks,
showTicks: schema?.props?.showTicks,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, showTicks should be assigned some value, incase the schema.props does not exist. As you have marked them optional, some default value should be provided.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as we made the slider component to work as both plain Slider range and tick mark slider range, So If 'ticks' and 'showTicks' will be undefined(falsy value) then this will work as Plain Slider Range. Please suggest if this approach is correct or not.

Comment on lines 49 to 50
let res = vizState;
if (isEmpty(vizState)) res = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const res = isEmpty(vizState)? []: vizState;

Comment on lines 55 to 56
(ctId, ctName) => {
return (event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ctId, ctName) => event => {.........} You may not the return statement here.

Comment on lines 72 to 73
(ctId) => {
return (event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

* SPDX-License-Identifier: Apache-2.0
*/

import React, { useCallback } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the new files that you have created (like this) have a tab stop of 4 spaces. The existing files have tab length as 2 spaces. Could you please check once?

const barWidth = 1 - (dataConfig?.chartStyles?.barWidth || vis.barWidth);
const groupWidth = 1 - (dataConfig?.chartStyles?.groupWidth || vis.groupWidth);
const isVertical = barOrientation === vis.orientation;
const showLegend = dataConfig?.legend?.showLegend && dataConfig.legend.showLegend !== vis.showLegend ? false : true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work. We usually do not assign true or false after condition. The condition itself returns a boolean value.

const showLegend = !(dataConfig?.legend?.showLegend && dataConfig.legend.showLegend !== vis.showLegend);

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's working. Thanks!

Signed-off-by: rinku-kumar-psl <[email protected]>
Signed-off-by: rinku-kumar-psl <[email protected]>
@rinku-kumar-psl
Copy link
Owner Author

Raising external PR, so closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants