Skip to content

Commit 2639f48

Browse files
committed
chore: release v0.18.1
1 parent e4a1d31 commit 2639f48

6 files changed

Lines changed: 23 additions & 47 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.18.1
4+
5+
### Patch Changes
6+
7+
- Fix CommandTrendChart parameters and recharts tooltip styles
8+
39
## 0.18.0
410

511
### Minor Changes

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lovcode",
33
"private": true,
4-
"version": "0.18.0",
4+
"version": "0.18.1",
55
"type": "module",
66
"packageManager": "pnpm@10.18.1",
77
"scripts": {

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lovcode"
3-
version = "0.18.0"
3+
version = "0.18.1"
44
description = "A Tauri App"
55
authors = ["you"]
66
edition = "2021"

src/components/home/CommandTrendChart.tsx

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { commandRangeAtom, commandModeAtom } from "@/store";
1414
interface CommandTrendChartProps {
1515
/** Map of command_name -> { week_key -> count } */
1616
data: Record<string, Record<string, number>>;
17-
weeks?: number;
1817
}
1918

2019
// Color palette for commands
@@ -46,7 +45,6 @@ function getISOWeek(date: Date): { year: number; week: number } {
4645
return { year: d.getUTCFullYear(), week: weekNo };
4746
}
4847

49-
type ChartMode = "weekly" | "cumulative";
5048
type TimeRange = "1m" | "3m" | "all";
5149

5250
const RANGE_WEEKS: Record<TimeRange, number | null> = {
@@ -55,7 +53,7 @@ const RANGE_WEEKS: Record<TimeRange, number | null> = {
5553
"all": null,
5654
};
5755

58-
export function CommandTrendChart({ data, weeks = 13 }: CommandTrendChartProps) {
56+
export function CommandTrendChart({ data }: CommandTrendChartProps) {
5957
const [hoverData, setHoverData] = useState<HoverData | null>(null);
6058
const [mode, setMode] = useAtom(commandModeAtom);
6159
const [range, setRange] = useAtom(commandRangeAtom);
@@ -97,9 +95,11 @@ export function CommandTrendChart({ data, weeks = 13 }: CommandTrendChartProps)
9795
const commands = commandTotals.slice(0, MAX_COMMANDS).map(([cmd]) => cmd);
9896

9997
// Build chart data based on mode
100-
const chartData = weekKeys.map((week, idx) => {
101-
const isCurrentWeek = idx === weekKeys.length - 1;
102-
const point: Record<string, string | number | null> = {
98+
// In weekly mode, exclude the current (incomplete) week
99+
const weeksToRender = mode === "weekly" ? weekKeys.slice(0, -1) : weekKeys;
100+
101+
const chartData = weeksToRender.map((week, idx) => {
102+
const point: Record<string, string | number> = {
103103
week: week.replace(/^\d{4}-W/, "W"),
104104
};
105105

@@ -108,19 +108,14 @@ export function CommandTrendChart({ data, weeks = 13 }: CommandTrendChartProps)
108108
commands.forEach((cmd) => {
109109
let cumulative = 0;
110110
for (let i = 0; i <= idx; i++) {
111-
cumulative += data[cmd]?.[weekKeys[i]] || 0;
111+
cumulative += data[cmd]?.[weeksToRender[i]] || 0;
112112
}
113113
point[cmd] = cumulative;
114114
});
115115
} else {
116-
// Weekly: show each week's data, current week as dot
116+
// Weekly: show each week's data
117117
commands.forEach((cmd) => {
118-
if (isCurrentWeek) {
119-
point[cmd] = null; // Break the line
120-
point[`${cmd}_current`] = data[cmd]?.[week] || 0;
121-
} else {
122-
point[cmd] = data[cmd]?.[week] || 0;
123-
}
118+
point[cmd] = data[cmd]?.[week] || 0;
124119
});
125120
}
126121
return point;
@@ -212,24 +207,13 @@ export function CommandTrendChart({ data, weeks = 13 }: CommandTrendChartProps)
212207
/>
213208
<Tooltip
214209
content={({ active, payload, label }) => {
215-
// Update external state when tooltip is active
216210
if (active && payload && payload.length > 0) {
217-
// Merge _current entries with main entries
218-
const merged = new Map<string, { value: number; color: string }>();
219-
payload.forEach((p) => {
220-
const name = (p.name as string).replace(/_current$/, "");
221-
const value = (p.value as number) ?? 0;
222-
const existing = merged.get(name);
223-
if (!existing || value > 0) {
224-
merged.set(name, { value, color: (p.color as string) || "#999" });
225-
}
226-
});
227211
const newData: HoverData = {
228212
label: label as string,
229-
items: Array.from(merged.entries()).map(([name, { value, color }]) => ({
230-
name,
231-
value,
232-
color,
213+
items: payload.map((p) => ({
214+
name: p.name as string,
215+
value: (p.value as number) ?? 0,
216+
color: (p.color as string) || "#999",
233217
})),
234218
};
235219
// Use setTimeout to avoid setState during render
@@ -251,20 +235,6 @@ export function CommandTrendChart({ data, weeks = 13 }: CommandTrendChartProps)
251235
strokeWidth={1.5}
252236
dot={false}
253237
activeDot={{ r: 3 }}
254-
connectNulls={false}
255-
/>
256-
))}
257-
{/* Current week points - shown as dots only in weekly mode */}
258-
{mode === "weekly" && commands.map((cmd, i) => (
259-
<Line
260-
key={`${cmd}_current`}
261-
type="monotone"
262-
dataKey={`${cmd}_current`}
263-
stroke={COLORS[i % COLORS.length]}
264-
strokeWidth={0}
265-
dot={{ r: 3, fill: COLORS[i % COLORS.length], strokeWidth: 0 }}
266-
activeDot={{ r: 4 }}
267-
legendType="none"
268238
/>
269239
))}
270240
</LineChart>

src/views/Home/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function Home({ onFeatureClick, onProjectClick, onSessionClick, onSearch
8585
{/* Command Trend Chart */}
8686
{commandWeeklyStats && Object.keys(commandWeeklyStats).length > 0 && (
8787
<div className="mt-4 pt-4 border-t border-border/40">
88-
<CommandTrendChart data={commandWeeklyStats} weeks={13} />
88+
<CommandTrendChart data={commandWeeklyStats} />
8989
</div>
9090
)}
9191
{/* Inline Stats */}

0 commit comments

Comments
 (0)