Commit 66faedfb by Ryan McKinley Committed by Torkel Ödegaard

DataFrame: remove dateFormat (#18424)

parent e1b2d61c
...@@ -48,7 +48,6 @@ export interface Field { ...@@ -48,7 +48,6 @@ export interface Field {
type?: FieldType; type?: FieldType;
filterable?: boolean; filterable?: boolean;
unit?: string; unit?: string;
dateFormat?: string; // Source data format
decimals?: number | null; // Significant digits (for display) decimals?: number | null; // Significant digits (for display)
min?: number | null; min?: number | null;
max?: number | null; max?: number | null;
......
...@@ -98,7 +98,6 @@ export class CSVReader { ...@@ -98,7 +98,6 @@ export class CSVReader {
name: '#', name: '#',
type: FieldType.number, type: FieldType.number,
unit: '#', unit: '#',
dateFormat: '#',
}; };
// Check if it is a known/supported column // Check if it is a known/supported column
......
// Libraries // Libraries
import _ from 'lodash'; import _ from 'lodash';
import { import { Threshold, getMappedValue, Field, DecimalInfo, DisplayValue, DecimalCount } from '@grafana/data';
DateTime,
dateTime,
Threshold,
getMappedValue,
Field,
DecimalInfo,
DisplayValue,
DecimalCount,
} from '@grafana/data';
// Utils // Utils
import { getValueFormat } from './valueFormats/valueFormats'; import { getValueFormat } from './valueFormats/valueFormats';
...@@ -60,14 +51,6 @@ export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProce ...@@ -60,14 +51,6 @@ export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProce
} }
} }
if (field.dateFormat) {
const date = toMoment(value, numeric, field.dateFormat);
if (date.isValid()) {
text = date.format(field.dateFormat);
shouldFormat = false;
}
}
if (!isNaN(numeric)) { if (!isNaN(numeric)) {
if (shouldFormat && !_.isBoolean(value)) { if (shouldFormat && !_.isBoolean(value)) {
const { decimals, scaledDecimals } = getDecimalsForValue(value, field.decimals); const { decimals, scaledDecimals } = getDecimalsForValue(value, field.decimals);
...@@ -88,20 +71,6 @@ export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProce ...@@ -88,20 +71,6 @@ export function getDisplayProcessor(options?: DisplayValueOptions): DisplayProce
return toStringProcessor; return toStringProcessor;
} }
function toMoment(value: any, numeric: number, format: string): DateTime {
if (!isNaN(numeric)) {
const v = dateTime(numeric);
if (v.isValid()) {
return v;
}
}
const v = dateTime(value, format);
if (v.isValid) {
return v;
}
return dateTime(value); // moment will try to parse the format
}
/** Will return any value as a number or NaN */ /** Will return any value as a number or NaN */
function toNumber(value: any): number { function toNumber(value: any): number {
if (typeof value === 'number') { if (typeof value === 'number') {
......
...@@ -8,7 +8,6 @@ describe('FieldDisplay', () => { ...@@ -8,7 +8,6 @@ describe('FieldDisplay', () => {
const f0 = { const f0 = {
min: 0, min: 0,
max: 100, max: 100,
dateFormat: 'YYYY',
}; };
const f1 = { const f1 = {
unit: 'ms', unit: 'ms',
...@@ -20,7 +19,6 @@ describe('FieldDisplay', () => { ...@@ -20,7 +19,6 @@ describe('FieldDisplay', () => {
expect(field.min).toEqual(0); expect(field.min).toEqual(0);
expect(field.max).toEqual(100); expect(field.max).toEqual(100);
expect(field.unit).toEqual('ms'); expect(field.unit).toEqual('ms');
expect(field.dateFormat).toEqual('YYYY');
// last one overrieds // last one overrieds
const f2 = { const f2 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment