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

[7.x] TSVB Inaccurate Group By (#73683) #73776

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions src/plugins/vis_type_timeseries/common/ui_restrictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import { PANEL_TYPES } from './panel_types';

/**
* UI Restrictions keys
* @constant
Expand Down Expand Up @@ -56,3 +58,12 @@ export type TimeseriesUIRestrictions = {
export const DEFAULT_UI_RESTRICTION: UIRestrictions = {
'*': true,
};

/** limit on the number of series for the panel
* @constant
* @public
*/
export const limitOfSeries = {
[PANEL_TYPES.GAUGE]: 1,
[PANEL_TYPES.METRIC]: 2,
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { QueryBarWrapper } from '../query_bar_wrapper';
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';

import { limitOfSeries } from '../../../../common/ui_restrictions';
import { PANEL_TYPES } from '../../../../common/panel_types';

class GaugePanelConfigUi extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -110,7 +113,7 @@ class GaugePanelConfigUi extends Component {
<SeriesEditor
colorPicker={true}
fields={this.props.fields}
limit={1}
limit={limitOfSeries[PANEL_TYPES.GAUGE]}
model={this.props.model}
name={this.props.name}
onChange={this.props.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import { FormattedMessage } from '@kbn/i18n/react';

import { QueryBarWrapper } from '../query_bar_wrapper';
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
import { limitOfSeries } from '../../../../common/ui_restrictions';
import { PANEL_TYPES } from '../../../../common/panel_types';

export class MetricPanelConfig extends Component {
constructor(props) {
Expand Down Expand Up @@ -75,7 +77,7 @@ export class MetricPanelConfig extends Component {
<SeriesEditor
colorPicker={false}
fields={this.props.fields}
limit={2}
limit={limitOfSeries[PANEL_TYPES.METRIC]}
model={this.props.model}
name={this.props.name}
onChange={this.props.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@
* specific language governing permissions and limitations
* under the License.
*/
export const getActiveSeries = (panel) => {
const shouldNotApplyFilter = ['gauge', 'markdown'].includes(panel.type);

return (panel.series || []).filter((series) => !series.hidden || shouldNotApplyFilter);
import { PanelSchema } from '../../../../common/types';
import { PANEL_TYPES } from '../../../../common/panel_types';
import { limitOfSeries } from '../../../../common/ui_restrictions';

export const getActiveSeries = (panel: PanelSchema) => {
let visibleSeries = panel.series || [];

if (panel.type in limitOfSeries) {
visibleSeries = visibleSeries.slice(0, limitOfSeries[panel.type]);
}

// Toogle visibility functionality for 'gauge', 'markdown' is not accessible
const shouldNotApplyFilter = [PANEL_TYPES.GAUGE, PANEL_TYPES.MARKDOWN].includes(panel.type);

return visibleSeries.filter((series) => !series.hidden || shouldNotApplyFilter);
};