Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 23b3612

Browse files
author
Scott Lepper
committed
use "time" field as time
1 parent 4b12e14 commit 23b3612

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SqlProxyDatasource.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import {
77
DataSourceJsonData,
88
MutableDataFrame,
99
DataFrame,
10-
guessFieldTypeFromValue,
10+
guessFieldTypeFromValue,
11+
FieldType
1112
} from '@grafana/data';
1213

1314
import { SqlQuery } from './types';
1415
import { getBackendSrv } from '@grafana/runtime';
15-
import { format } from 'date-fns';
16+
import { format, roundToNearestMinutes } from 'date-fns';
1617

1718
export class DataSource extends DataSourceApi<SqlQuery, DataSourceJsonData> {
1819
/** @ngInject */
@@ -56,6 +57,11 @@ export class DataSource extends DataSourceApi<SqlQuery, DataSourceJsonData> {
5657
const fields = Object.keys(array[0]).map(field => {
5758
return { name: field, type: guessFieldTypeFromValue(array[0][field]) };
5859
});
60+
for (const field of fields) {
61+
if (field.name.toLowerCase() === "time") {
62+
field.type = FieldType.time;
63+
}
64+
}
5965
dataFrame = new MutableDataFrame({ fields });
6066
array.forEach((row, index) => {
6167
dataFrame.appendRow(Object.values(row));

0 commit comments

Comments
 (0)