KMCounter icon indicating copy to clipboard operation
KMCounter copied to clipboard

能不能弄个柱状图 横向对比每天的按键数

Open wsvv opened this issue 2 years ago • 5 comments

这样比较直观显示每天的摸鱼情况hh

wsvv avatar Nov 30 '22 09:11 wsvv

我也有相同的需求,或者能导出csv文件自己做表也是极好的,希望开发者还能维护

76563 avatar Jan 14 '23 04:01 76563

我自己做了一个 https://github.com/pattazl/showKeyBoard 柱状图,历史数据曲线,数据导出等功能都有

pattazl avatar Oct 16 '23 01:10 pattazl

写了一个Python脚本,简单做一下数据分析,有需要的可以使用。

# Import required libraries
import re
from collections import defaultdict
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use("TkAgg")
import pandas as pd

# Read the file with UTF-16 encoding
with open('D:\GreenSoft\KMCounter.ini', 'r', encoding='utf-16') as file:
    file_content = file.readlines()

# Initialize a dictionary to store the data
data_dict = defaultdict(lambda: {'lbcount': 0, 'rbcount': 0, 'wheel': 0, 'move': 0, 'keystrokes': 0})

# Regular expression pattern to extract date in the format YYYYMMDD and the relevant data
pattern = re.compile(r'\[(\d{8})\]')
key_patterns = ['lbcount', 'rbcount', 'wheel', 'move', 'keystrokes']

# Extract data
current_date = None
for line in file_content:
    # if ==[total]==, then skip
    if line.strip() == '[total]':
        current_date = None
        continue
    date_match = pattern.match(line.strip())
    if date_match:
        current_date = date_match.group(1)
        current_date = f"{current_date[:4]}-{current_date[4:6]}-{current_date[6:]}"
        continue
    if current_date:
        for key in key_patterns:
            if line.startswith(key):
                value = float(line.split('=')[1].strip())
                data_dict[current_date][key] = value

# Convert the defaultdict to a normal dict
data_dict = dict(data_dict)

# Convert the data dictionary to a DataFrame
df = pd.DataFrame.from_dict(data_dict, orient='index')
df.index = pd.to_datetime(df.index)

# Filter out rows with 'total' in the index
df_filtered = df[~df.index.astype(str).str.contains('total', case=False)]

# Normalize the data for plotting
df_filtered_normalized = (df_filtered - df_filtered.min()) / (df_filtered.max() - df_filtered.min())

# Plotting
fig, ax = plt.subplots(figsize=(15, 10))
for column in df_filtered_normalized.columns:
    df_filtered_normalized[column].plot(ax=ax, marker='o', label=column)
ax.set_xlabel('Date')
ax.set_ylabel('Normalized Value')
ax.set_title('Comparison of lbcount, rbcount, wheel, move, and keystrokes Over Time')
ax.legend()
plt.tight_layout()
plt.show()

DanielZhao1990 avatar Oct 21 '23 02:10 DanielZhao1990

现在可以叫chatgpt画了

LanRenLan avatar Jun 25 '24 01:06 LanRenLan

我也有相同的需求,或者能导出csv文件自己做表也是极好的,希望开发者还能维护

目录下的ini文件里就是数据,自己解析呗。

telppa avatar Jun 26 '24 16:06 telppa