Skip to content

Commit b1c4553

Browse files
committed
TSVB Inaccurate Group By
Closes: #62081
1 parent 4f8e7ba commit b1c4553

5 files changed

Lines changed: 33 additions & 5 deletions

File tree

File renamed without changes.

src/plugins/vis_type_timeseries/common/ui_restrictions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
* under the License.
1818
*/
1919

20+
import { PANEL_TYPES } from './panel_types';
21+
2022
/**
2123
* UI Restrictions keys
2224
* @constant
@@ -56,3 +58,12 @@ export type TimeseriesUIRestrictions = {
5658
export const DEFAULT_UI_RESTRICTION: UIRestrictions = {
5759
'*': true,
5860
};
61+
62+
/** limit on the number of series for the panel
63+
* @constant
64+
* @public
65+
*/
66+
export const limitOfSeries = {
67+
[PANEL_TYPES.GAUGE]: 1,
68+
[PANEL_TYPES.METRIC]: 2,
69+
};

src/plugins/vis_type_timeseries/public/application/components/panel_config/gauge.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
4646
import { QueryBarWrapper } from '../query_bar_wrapper';
4747
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
4848

49+
import { limitOfSeries } from '../../../../common/ui_restrictions';
50+
import { PANEL_TYPES } from '../../../../common/panel_types';
51+
4952
class GaugePanelConfigUi extends Component {
5053
constructor(props) {
5154
super(props);
@@ -110,7 +113,7 @@ class GaugePanelConfigUi extends Component {
110113
<SeriesEditor
111114
colorPicker={true}
112115
fields={this.props.fields}
113-
limit={1}
116+
limit={limitOfSeries[PANEL_TYPES.GAUGE]}
114117
model={this.props.model}
115118
name={this.props.name}
116119
onChange={this.props.onChange}

src/plugins/vis_type_timeseries/public/application/components/panel_config/metric.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ import { FormattedMessage } from '@kbn/i18n/react';
4141

4242
import { QueryBarWrapper } from '../query_bar_wrapper';
4343
import { getDefaultQueryLanguage } from '../lib/get_default_query_language';
44+
import { limitOfSeries } from '../../../../common/ui_restrictions';
45+
import { PANEL_TYPES } from '../../../../common/panel_types';
4446

4547
export class MetricPanelConfig extends Component {
4648
constructor(props) {
@@ -75,7 +77,7 @@ export class MetricPanelConfig extends Component {
7577
<SeriesEditor
7678
colorPicker={false}
7779
fields={this.props.fields}
78-
limit={2}
80+
limit={limitOfSeries[PANEL_TYPES.METRIC]}
7981
model={this.props.model}
8082
name={this.props.name}
8183
onChange={this.props.onChange}

src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.js renamed to src/plugins/vis_type_timeseries/server/lib/vis_data/helpers/get_active_series.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,20 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
export const getActiveSeries = (panel) => {
20-
const shouldNotApplyFilter = ['gauge', 'markdown'].includes(panel.type);
2119

22-
return (panel.series || []).filter((series) => !series.hidden || shouldNotApplyFilter);
20+
import { PanelSchema } from '../../../../common/types';
21+
import { PANEL_TYPES } from '../../../../common/panel_types';
22+
import { limitOfSeries } from '../../../../common/ui_restrictions';
23+
24+
export const getActiveSeries = (panel: PanelSchema) => {
25+
let visibleSeries = panel.series || [];
26+
27+
if (panel.type in limitOfSeries) {
28+
visibleSeries = visibleSeries.slice(0, limitOfSeries[panel.type]);
29+
}
30+
31+
// Toogle visibility functionality for 'gauge', 'markdown' is not accessible
32+
const shouldNotApplyFilter = [PANEL_TYPES.GAUGE, PANEL_TYPES.MARKDOWN].includes(panel.type);
33+
34+
return visibleSeries.filter((series) => !series.hidden || shouldNotApplyFilter);
2335
};

0 commit comments

Comments
 (0)