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

Time series/scatter bugs fixed #1113

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { isEmpty } from 'lodash';
import { ADD_BUTTON_TEXT, AGGREGATIONS } from '../../../../../../../../common/constants/explorer';
import { VIS_CHART_TYPES } from '../../../../../../../../common/constants/shared';
import { getPropName } from '../../../../../../../components/event_analytics/utils/utils';

export const ConfigColorTheme = ({
visualizations,
Expand All @@ -45,7 +46,7 @@ export const ConfigColorTheme = ({
: fields
).map((item) => ({
...item,
label: item.name,
label: getPropName(item),
}));
const getUpdatedOptions = () =>
options.filter((option) => !vizState.some((vizOpt) => option.name === vizOpt?.name?.name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ export const Line = ({ visualizations, layout, config }: any) => {
} = DEFAULT_CHART_STYLES;
const {
data: {
defaultAxes,
indexFields,
query,
rawVizData: {
data: queriedVizData,
metadata: { fields },
Expand All @@ -46,9 +43,7 @@ export const Line = ({ visualizations, layout, config }: any) => {
}: IVisualizationContainerProps = visualizations;
const { dataConfig = {}, layoutConfig = {}, availabilityConfig = {} } = userConfigs;

const yaxis = dataConfig[AGGREGATIONS]
? dataConfig[AGGREGATIONS].filter((item) => item.label)
: [];
const yaxis = dataConfig[AGGREGATIONS] ? dataConfig[AGGREGATIONS] : [];
ramneet-persistent marked this conversation as resolved.
Show resolved Hide resolved
const tooltipMode =
dataConfig?.tooltipOptions?.tooltipMode !== undefined
? dataConfig.tooltipOptions.tooltipMode
Expand Down Expand Up @@ -92,21 +87,19 @@ export const Line = ({ visualizations, layout, config }: any) => {
xaxis = dataConfig[GROUPBY];
}

if (isEmpty(xaxis) || isEmpty(yaxis)) return <EmptyPlaceholder icon={visMetaData?.icontype} />;
if (!timestampField || xaxis.length !== 1 || isEmpty(yaxis))
return <EmptyPlaceholder icon={visMetaData?.icontype} />;

let valueSeries;
if (!isEmpty(xaxis) && !isEmpty(yaxis)) {
valueSeries = [...yaxis];
} else {
valueSeries = (
defaultAxes.yaxis || take(fields, lastIndex > 0 ? lastIndex : 1)
).map((item, i) => ({ ...item, side: i === 0 ? 'left' : 'right' }));
valueSeries = take(fields, lastIndex > 0 ? lastIndex : 1).map((item, i) => ({
...item,
side: i === 0 ? 'left' : 'right',
}));
}

const isDimensionTimestamp = isEmpty(xaxis)
? defaultAxes?.xaxis?.length && defaultAxes.xaxis[0].type === 'timestamp'
: xaxis.length === 1 && xaxis[0].type === 'timestamp';

let multiMetrics = {};
const [calculatedLayout, lineValues] = useMemo(() => {
const isBarMode = mode === 'bar';
Expand Down Expand Up @@ -166,6 +159,14 @@ export const Line = ({ visualizations, layout, config }: any) => {
const layoutForBarMode = {
barmode: 'group',
};
const axisLabelsStyle = {
automargin: true,
tickfont: {
...(labelSize && {
size: labelSize,
}),
},
};
const mergedLayout = {
...layout,
...layoutConfig.layout,
Expand All @@ -181,12 +182,10 @@ export const Line = ({ visualizations, layout, config }: any) => {
},
xaxis: {
tickangle: tickAngle,
automargin: true,
tickfont: {
...(labelSize && {
size: labelSize,
}),
},
...axisLabelsStyle,
},
yaxis: {
...axisLabelsStyle,
},
showlegend: showLegend,
...(isBarMode && layoutForBarMode),
Expand All @@ -199,6 +198,7 @@ export const Line = ({ visualizations, layout, config }: any) => {
y: [],
mode: 'text',
text: [],
showlegend: false,
};
const thresholds = dataConfig.thresholds ? dataConfig.thresholds : [];
const levels = availabilityConfig.level ? availabilityConfig.level : [];
Expand Down Expand Up @@ -246,9 +246,5 @@ export const Line = ({ visualizations, layout, config }: any) => {
[config, layoutConfig.config]
);

return isDimensionTimestamp ? (
<Plt data={lineValues} layout={calculatedLayout} config={mergedConfigs} />
) : (
<EmptyPlaceholder icon={visMetaData?.icontype} />
);
return <Plt data={lineValues} layout={calculatedLayout} config={mergedConfigs} />;
};