Skip to content

Commit

Permalink
[Feature]: Timeseries/Scatter 2 way sync (opensearch-project#1030)
Browse files Browse the repository at this point in the history
* Fixed 2 way sync issues for line

Signed-off-by: ruchika-narang <ruchika_narang@persistent.com>

* Updated snapshots

Signed-off-by: ruchika-narang <ruchika_narang@persistent.com>

* Removed extra line

Signed-off-by: ruchika-narang <ruchika_narang@persistent.com>

Signed-off-by: ruchika-narang <ruchika_narang@persistent.com>
  • Loading branch information
ruchika-narang authored Sep 19, 2022
1 parent 0a5d543 commit 52f9168
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,17 @@ export const DataConfigPanelItem = ({ fieldOptionList, visualizations }: any) =>
};

const isPositionButtonVisible = (sectionName: string) =>
sectionName === 'metrics' && visualizations.vis.name === visChartTypes.Line;
sectionName === 'metrics' &&
(visualizations.vis.name === visChartTypes.Line ||
visualizations.vis.name === visChartTypes.Scatter);

const getOptionsAvailable = (sectionName: string) => {
const selectedFields = {};
const unselectedFields = fieldOptionList.filter((field) => !selectedFields[field.label]);
return sectionName === 'metrics'
? unselectedFields
: visualizations.vis.name === visChartTypes.Line
: visualizations.vis.name === visChartTypes.Line ||
visualizations.vis.name === visChartTypes.Scatter
? unselectedFields.filter((i) => i.type === 'timestamp')
: unselectedFields;
};
Expand Down Expand Up @@ -285,7 +288,9 @@ export const DataConfigPanelItem = ({ fieldOptionList, visualizations }: any) =>
color="primary"
onClick={() => handleServiceAdd(sectionName)}
disabled={
sectionName === 'dimensions' && visualizations.vis.name === visChartTypes.Line
sectionName === 'dimensions' &&
(visualizations.vis.name === visChartTypes.Line ||
visualizations.vis.name === visChartTypes.Scatter)
}
>
Add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,14 @@ export const Line = ({ visualizations, layout, config }: any) => {
dataConfig.colorTheme.find((colorSelected) => colorSelected.name.name === field.name)
?.color) ||
PLOTLY_COLOR[index % PLOTLY_COLOR.length];
/**
* determine x axis
*/
const xaxis = useMemo(() => {
// span selection
const timestampField = find(fields, (field) => field.type === 'timestamp');
if (dataConfig.span && dataConfig.span.time_field && timestampField) {
return [timestampField, ...dataConfig.dimensions];
}
let xaxis;
const timestampField = find(fields, (field) => field.type === 'timestamp');

return dataConfig.dimensions;
}, [dataConfig.dimensions]);
if (dataConfig.span && dataConfig.span.time_field && timestampField) {
xaxis = [timestampField, ...dataConfig.dimensions];
} else {
xaxis = dataConfig.dimensions;
}

if (isEmpty(xaxis) || isEmpty(yaxis))
return <EmptyPlaceholder icon={visualizations?.vis?.icontype} />;
Expand Down

0 comments on commit 52f9168

Please sign in to comment.