Fix cost chart tooltip date label
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { useTheme } from '@material-ui/core';
|
||||
import {
|
||||
ComposedChart,
|
||||
@@ -50,6 +51,8 @@ import { useCostOverviewStyles as useStyles } from '../../utils/styles';
|
||||
import { groupByDate, toDataMax, trendFrom } from '../../utils/charts';
|
||||
import { aggregationSort } from '../../utils/sort';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
type CostOverviewChartProps = {
|
||||
metric: Maybe<Metric>;
|
||||
metricData: Maybe<MetricData>;
|
||||
@@ -104,7 +107,7 @@ export const CostOverviewChart = ({
|
||||
if (isInvalid({ label, payload })) return null;
|
||||
|
||||
const dataKeys = [data.dailyCost.dataKey, data.metric.dataKey];
|
||||
const title = moment(label).format(DEFAULT_DATE_FORMAT);
|
||||
const title = dayjs(label).utc().format(DEFAULT_DATE_FORMAT);
|
||||
const items = payload
|
||||
.filter(p => dataKeys.includes(p.dataKey as string))
|
||||
.map(p => ({
|
||||
|
||||
@@ -76,8 +76,13 @@ describe('getPreviousPeriodTotalCost', () => {
|
||||
change: changeOf(MockAggregatedDailyCosts),
|
||||
trendline: trendlineOf(MockAggregatedDailyCosts),
|
||||
};
|
||||
const exclusiveEndDate = '2020-10-01';
|
||||
expect(
|
||||
getPreviousPeriodTotalCost(mockGroupDailyCost, Duration.P1M),
|
||||
getPreviousPeriodTotalCost(
|
||||
mockGroupDailyCost,
|
||||
Duration.P1M,
|
||||
exclusiveEndDate,
|
||||
),
|
||||
).toEqual(100_000);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user