Skip to content

Commit

Permalink
fix: double conversion to date caused invalid date (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinmukhamedm authored Jan 7, 2025
1 parent 684bfbc commit e86feae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
18 changes: 12 additions & 6 deletions frontend/components/dashboard/span-stat-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AggregationFunction } from '@/lib/clickhouse/utils';
import {
cn,
formatTimestamp,
formatTimestampFromSecondsWithInterval,
formatTimestampWithInterval,
} from '@/lib/utils';

Expand Down Expand Up @@ -156,7 +157,8 @@ interface ChartProps {
keys: Set<string>,
xAxisKey: string,
chartConfig: ChartConfig,
groupByInterval: GroupByInterval
groupByInterval: GroupByInterval,
numericTimestamp?: boolean
}

function StackedBarChart({
Expand Down Expand Up @@ -238,7 +240,8 @@ export function DefaultLineChart({
keys,
xAxisKey,
chartConfig,
groupByInterval
groupByInterval,
numericTimestamp
}: ChartProps) {
const dataMax = useMemo(() => Math.max(...data.map((d) => Object.entries(d)
.filter(([key]) => key !== xAxisKey)
Expand Down Expand Up @@ -270,12 +273,15 @@ export function DefaultLineChart({
type="category"
domain={['dataMin', 'dataMax']}
tickLine={false}
tickFormatter={(value) =>
formatTimestampWithInterval(
tickFormatter={(value) => {
if (numericTimestamp) {
return formatTimestampFromSecondsWithInterval(value, groupByInterval ?? 'hour');
}
return formatTimestampWithInterval(
value,
groupByInterval ?? 'hour'
)
}
);
}}
axisLine={false}
tickMargin={8}
dataKey={xAxisKey}
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/dashboard/trace-stat-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { GroupByInterval } from '@/lib/clickhouse/modifiers';
import { TraceMetricDatapoint } from '@/lib/traces/types';
import {
cn,
formatTimestampFromSeconds,
toFixedIfFloat,
} from '@/lib/utils';

Expand Down Expand Up @@ -107,12 +106,13 @@ export function TraceStatChart({
<DefaultLineChart
data={data?.map((d) => ({
"value": d.value,
"timestamp": formatTimestampFromSeconds(d.time)
"timestamp": d.time
})) ?? []}
xAxisKey="timestamp"
chartConfig={chartConfig}
groupByInterval={defaultGroupByInterval as GroupByInterval}
keys={new Set(["value"])}
numericTimestamp={true}
/>
)}
</div>
Expand Down

0 comments on commit e86feae

Please sign in to comment.