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

Feature/tooltip-text-customization: Customized the tooltip text #33

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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 ConfigTooltip = ({ 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 (
<>
shankha-das marked this conversation as resolved.
Show resolved Hide resolved
<DimensionComponent key={`viz-series-${index}`} {...params} />
<EuiSpacer size="s" />
</>
);
});
}, [schemas, vizState, handleConfigurationChange]);

return (
<EuiAccordion initialIsOpen id="configPanel__tooltip" buttonContent="Tooltip options" paddingSize="s">
shankha-das marked this conversation as resolved.
Show resolved Hide resolved
{dimensions}
</EuiAccordion>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export { ConfigGaugeValueOptions } from './config_gauge_options';
export { ColorPalettePicker } from './config_color_palette_picker';
export { ConfigLineChartStyles } from './config_line_chart_styles';
export { ConfigLegend } from './config_legend';
export { ConfigTooltip } from './config_tooltip';
export { HeatmapColorPalettePicker } from './config_heatmap_color_palette_picker';
export { SingleColorPicker } from './config_single_color_picker';
export { PanelItem } from './config_panel_item';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,64 @@ exports[`Bar component Renders bar component 1`] = `
},
],
},
Object {
"editor": [Function],
"id": "tooltip_options",
"mapTo": "tooltipOptions",
"name": "Tooltip options",
"schemas": Array [
Object {
"component": null,
"mapTo": "tooltipMode",
"name": "Tooltip mode",
"props": Object {
"defaultSelections": Array [
Object {
"id": "show",
"name": "Show",
},
],
"options": Array [
Object {
"id": "show",
"name": "Show",
},
Object {
"id": "hidden",
"name": "Hidden",
},
],
},
},
Object {
"component": null,
"mapTo": "tooltipText",
"name": "Tooltip text",
"props": Object {
"defaultSelections": Array [
Object {
"id": "all",
"name": "All",
},
],
"options": Array [
Object {
"id": "all",
"name": "All",
},
Object {
"id": "x",
"name": "Dimension",
},
Object {
"id": "y",
"name": "Metrics",
},
],
},
},
],
},
Object {
"editor": [Function],
"id": "legend",
Expand Down Expand Up @@ -494,6 +552,7 @@ exports[`Bar component Renders bar component 1`] = `
data={
Array [
Object {
"hoverinfo": "all",
"marker": Object {
"color": "rgba(60,161,199,0.4)",
"line": Object {
Expand Down Expand Up @@ -560,6 +619,7 @@ exports[`Bar component Renders bar component 1`] = `
data={
Array [
Object {
"hoverinfo": "all",
"marker": Object {
"color": "rgba(60,161,199,0.4)",
"line": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,64 @@ exports[`Heatmap component Renders heatmap component 1`] = `
},
],
},
Object {
"editor": [Function],
"id": "tooltip_options",
"mapTo": "tooltipOptions",
"name": "Tooltip options",
"schemas": Array [
Object {
"component": null,
"mapTo": "tooltipMode",
"name": "Tooltip mode",
"props": Object {
"defaultSelections": Array [
Object {
"id": "show",
"name": "Show",
},
],
"options": Array [
Object {
"id": "show",
"name": "Show",
},
Object {
"id": "hidden",
"name": "Hidden",
},
],
},
},
Object {
"component": null,
"mapTo": "tooltipText",
"name": "Tooltip text",
"props": Object {
"defaultSelections": Array [
Object {
"id": "all",
"name": "All",
},
],
"options": Array [
Object {
"id": "all",
"name": "All",
},
Object {
"id": "x",
"name": "Dimension",
},
Object {
"id": "y",
"name": "Metrics",
},
],
},
},
],
},
Object {
"editor": [Function],
"id": "legend",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,64 @@ exports[`Histogram component Renders histogram component 1`] = `
},
],
},
Object {
"editor": [Function],
"id": "tooltip_options",
"mapTo": "tooltipOptions",
"name": "Tooltip options",
"schemas": Array [
Object {
"component": null,
"mapTo": "tooltipMode",
"name": "Tooltip mode",
"props": Object {
"defaultSelections": Array [
Object {
"id": "show",
"name": "Show",
},
],
"options": Array [
Object {
"id": "show",
"name": "Show",
},
Object {
"id": "hidden",
"name": "Hidden",
},
],
},
},
Object {
"component": null,
"mapTo": "tooltipText",
"name": "Tooltip text",
"props": Object {
"defaultSelections": Array [
Object {
"id": "all",
"name": "All",
},
],
"options": Array [
Object {
"id": "all",
"name": "All",
},
Object {
"id": "x",
"name": "Dimension",
},
Object {
"id": "y",
"name": "Metrics",
},
],
},
},
],
},
Object {
"editor": [Function],
"id": "legend",
Expand Down Expand Up @@ -494,6 +552,7 @@ exports[`Histogram component Renders histogram component 1`] = `
data={
Array [
Object {
"hoverinfo": "all",
"marker": Object {
"color": "rgba(60,161,199,0.2)",
"line": Object {
Expand Down Expand Up @@ -546,6 +605,7 @@ exports[`Histogram component Renders histogram component 1`] = `
data={
Array [
Object {
"hoverinfo": "all",
"marker": Object {
"color": "rgba(60,161,199,0.2)",
"line": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,64 @@ exports[`Line component Renders line component 1`] = `
},
],
},
Object {
"editor": [Function],
"id": "tooltip_options",
"mapTo": "tooltipOptions",
"name": "Tooltip options",
"schemas": Array [
Object {
"component": null,
"mapTo": "tooltipMode",
"name": "Tooltip mode",
"props": Object {
"defaultSelections": Array [
Object {
"id": "show",
"name": "Show",
},
],
"options": Array [
Object {
"id": "show",
"name": "Show",
},
Object {
"id": "hidden",
"name": "Hidden",
},
],
},
},
Object {
"component": null,
"mapTo": "tooltipText",
"name": "Tooltip text",
"props": Object {
"defaultSelections": Array [
Object {
"id": "all",
"name": "All",
},
],
"options": Array [
Object {
"id": "all",
"name": "All",
},
Object {
"id": "x",
"name": "Dimension",
},
Object {
"id": "y",
"name": "Metrics",
},
],
},
},
],
},
Object {
"editor": [Function],
"id": "legend",
Expand Down
Loading