Skip to content

Commit

Permalink
[TSVB] reduce formatter creation number
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaanj committed Apr 28, 2021
1 parent 385736c commit 9b1c724
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { EuiFlexItem, EuiToolTip, EuiFlexGroup, EuiBadge } from '@elastic/eui';
import { getUISettings } from '../../services';
import { convertIntervalIntoUnit, isAutoInterval, isGteInterval } from './lib/get_interval';
import { getFixedOffset } from './lib/get_fixed_offset';
import { createIntervalBasedFormatter } from './lib/create_interval_based_formatter';
import { PanelData } from '../../../common/types';

Expand Down Expand Up @@ -47,8 +46,7 @@ export const LastValueModeIndicator = ({
panelInterval,
scaledDataFormat,
dateFormat,
ignoreDaylightTime,
getFixedOffset()
ignoreDaylightTime
);
const lastBucketDate = formatter(seriesData[seriesData.length - 1][0]);
const formattedPanelInterval =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import moment from 'moment';

const JANUARY_MOMENT_CONFIG = { M: 0, d: 1 };

function getFormat(interval: number, rules: string[][] = []) {
for (let i = rules.length - 1; i >= 0; i--) {
const rule = rules[i];
Expand All @@ -21,9 +23,9 @@ export function createIntervalBasedFormatter(
interval: number,
rules: string[][],
dateFormat: string,
ignoreDaylightTime: boolean,
fixedOffset: number
ignoreDaylightTime: boolean
) {
const fixedOffset = moment(JANUARY_MOMENT_CONFIG).utcOffset();
return (val: moment.MomentInput): string => {
const momentVal = moment(val);
if (ignoreDaylightTime) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { MarkdownSimple } from '../../../../../../../plugins/kibana_react/public
import { replaceVars } from '../../lib/replace_vars';
import { getAxisLabelString } from '../../lib/get_axis_label_string';
import { getInterval } from '../../lib/get_interval';
import { getFixedOffset } from '../../lib/get_fixed_offset';
import { createIntervalBasedFormatter } from '../../lib/create_interval_based_formatter';
import { STACKED_OPTIONS } from '../../../visualizations/constants';
import { getCoreStart } from '../../../../services';
Expand All @@ -35,15 +34,16 @@ class TimeseriesVisualization extends Component {
scaledDataFormat = this.props.getConfig('dateFormat:scaled');
dateFormat = this.props.getConfig('dateFormat');

xAxisFormatter = (interval) => (val) => {
xAxisFormatter = (interval) => {
const formatter = createIntervalBasedFormatter(
interval,
this.scaledDataFormat,
this.dateFormat,
Boolean(this.props.model.ignore_daylight_time),
getFixedOffset()
Boolean(this.props.model.ignore_daylight_time)
);
return formatter(val);
return (val) => {
return formatter(val);
};
};

yAxisStackedByPercentFormatter = (val) => {
Expand Down

0 comments on commit 9b1c724

Please sign in to comment.