Skip to content

Commit

Permalink
Timeseries adaptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Mar 17, 2020
1 parent b9d43ab commit d901f8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@
* under the License.
*/

// @ts-ignore
export { timezoneProvider } from 'ui/vis/lib/timezone';
import moment from 'moment-timezone';
import { IUiSettingsClient } from 'kibana/public';

export function getTimezone(config: IUiSettingsClient) {
if (config.isDefault('dateFormat:tz')) {
const detectedTimezone = moment.tz.guess();
if (detectedTimezone) return detectedTimezone;
else return moment().format('Z');
} else {
return config.get('dateFormat:tz', 'Browser');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { validateInterval } from './lib/validate_interval';
import { timezoneProvider } from './legacy_imports';
import { getTimezone } from './lib/get_timezone';
import { getUISettings, getDataStart, getCoreStart } from './services';

export const metricsRequestHandler = async ({
Expand All @@ -30,7 +30,7 @@ export const metricsRequestHandler = async ({
savedObjectId,
}) => {
const config = getUISettings();
const timezone = timezoneProvider(config)();
const timezone = getTimezone(config);
const uiStateObj = uiState.get(visParams.type, {});
const parsedTimeRange = getDataStart().query.timefilter.timefilter.calculateBounds(timeRange);
const scaledDataFormat = config.get('dateFormat:scaled');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ import {
TooltipType,
} from '@elastic/charts';
import { EuiIcon } from '@elastic/eui';

import { timezoneProvider } from '../../../legacy_imports';
import { getTimezone } from '../../../lib/get_timezone';
import { eventBus, ACTIVE_CURSOR } from '../../lib/active_cursor';
import { getUISettings } from '../../../services';
import { GRID_LINE_CONFIG, ICON_TYPES_MAP, STACKED_OPTIONS } from '../../constants';
Expand Down Expand Up @@ -86,7 +85,7 @@ export const TimeSeries = ({

const tooltipFormatter = decorateFormatter(xAxisFormatter);
const uiSettings = getUISettings();
const timeZone = timezoneProvider(uiSettings)();
const timeZone = getTimezone(uiSettings);
const hasBarChart = series.some(({ bars }) => bars.show);

return (
Expand Down

0 comments on commit d901f8e

Please sign in to comment.