This commit is contained in:
Violet Voronetzky 2020-03-25 16:12:21 +02:00
Родитель 3e5ba01f87
Коммит 867816d2cd
3 изменённых файлов: 24 добавлений и 13 удалений

Просмотреть файл

@ -43,6 +43,7 @@ export class KustoChartHelper implements IChartHelper {
exceedMaxDataPointLabel: 'OTHER',
aggregationType: AggregationType.Sum,
chartTheme: ChartTheme.Light,
getUtcOffset: () => { return 0; },
legendOptions: {
isEnabled: true
}

Просмотреть файл

@ -25,10 +25,10 @@ export class Utilities {
/**
* Returns the value of the local date after adding the desired offset (from UTC)
* @param dateStr - The string value that represents the date to transform.
* @param getUtcOffset - [Optional] Callback that returnd offset in hours from UTC. If not provided, the utcOffset will be 0
* @param getUtcOffset - Callback that returns the offset in hours from UTC.
* @returns The value of the date + the desired UTC offset
*/
public static getDateValue(dateStr: string, getUtcOffset?: (dateStr: string) => number): number {
public static getDateValue(dateStr: string, getUtcOffset: (dateStr: string) => number): number {
const date = new Date(dateStr);
if (date.toDateString() === 'Invalid Date') {
@ -36,7 +36,7 @@ export class Utilities {
}
// Add UTC offset to the date
const utcOffset = getUtcOffset ? getUtcOffset(dateStr) : 0;
const utcOffset = getUtcOffset(dateStr);
const utcOffsetInMilliseconds = utcOffset * 60 * 60 * 1000;
const localDateValue = date.valueOf();

Просмотреть файл

@ -89,7 +89,8 @@ describe('Unit tests for Chart methods', () => {
columnsSelection: {
xAxis: columns[1], // timestamp
yAxes: [columns[3]] // request_count
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -232,7 +233,8 @@ describe('Unit tests for Chart methods', () => {
columnsSelection: {
xAxis: columns[0], // country
yAxes: [columns[1]] // count
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -276,7 +278,8 @@ describe('Unit tests for Chart methods', () => {
columnsSelection: {
xAxis: columns[1], // timestamp
yAxes: [columns[3]] // request_count
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -329,7 +332,8 @@ describe('Unit tests for Chart methods', () => {
xAxis: columns[0], // country
yAxes: [columns[2]], // request_count
splitBy: [columns[1]] // city
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -407,7 +411,8 @@ describe('Unit tests for Chart methods', () => {
xAxis: columns[1], // timestamp
yAxes: [columns[3]], // request_count
splitBy: [columns[2]], // city
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -478,7 +483,8 @@ describe('Unit tests for Chart methods', () => {
xAxis: columns[0], // country
yAxes: [columns[2]], // request_count
splitBy: [columns[1]] // city
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -533,7 +539,8 @@ describe('Unit tests for Chart methods', () => {
columnsSelection: {
xAxis: columns[1], // city
yAxes: [columns[2]], // request_count
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -585,7 +592,8 @@ describe('Unit tests for Chart methods', () => {
columnsSelection: {
xAxis: columns[1], // city
yAxes: [columns[2]], // request_count
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -657,7 +665,8 @@ describe('Unit tests for Chart methods', () => {
xAxis: columns[0], // country
yAxes: [columns[2]], // request_count
splitBy: [columns[1]] // city
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,
@ -732,7 +741,8 @@ describe('Unit tests for Chart methods', () => {
xAxis: columns[0], // browser
yAxes: [columns[3]], // usage
splitBy: [columns[1], columns[2]] // version, minor_version
}
},
getUtcOffset: () => { return 0; }
},
queryResultData: {
rows: rows,