Skip to content

Commit

Permalink
feat: init charts
Browse files Browse the repository at this point in the history
  • Loading branch information
timeowilliams committed Sep 26, 2024
1 parent f75b119 commit 796aa10
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 27 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/package_size.yml

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"dotenv": "^16.4.5",
"echarts": "^5.5.1",
"electron-store": "^10.0.0",
"electron-updater": "^6.3.4",
"electron-vite": "^2.3.0",
Expand Down
23 changes: 23 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ app.whenReady().then(async () => {
setupPeriodicSave()
setupIPCListeners()
})

emailService.scheduleEmailSend()
})

function handleUserLogout() {
Expand All @@ -191,7 +189,6 @@ function setupIPCListeners() {
if (savedUser) {
startActivityMonitoring()
currentSiteTimeTrackers = store.get('siteTimeTrackers', [])
emailService.scheduleEmailSend()
}
})
ipcMain.on('test-email-send', async () => await emailService.testEmailSend())
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Login = lazy(() => import('./Login'))
const Signup = lazy(() => import('./Signup'))
const Versions = lazy(() => import('./Versions'))
const HelloWorld = () => <h1>Hello World!</h1>
const BarChart = lazy(() => import('./BarChart'))

const App = (props: ComponentProps<typeof Router>) => {
const [isLoggedIn, setIsLoggedIn] = useAuth()
Expand Down Expand Up @@ -87,10 +88,11 @@ render(
<AuthProvider>
<Router root={App}>
<Suspense fallback={<div>Loading...</div>}>
<Route path="/" component={Versions} />
<Route path="/" component={BarChart} />
<Route path="/login" component={Login} />
<Route path="/hello-world" component={HelloWorld} />
<Route path="/signup" component={Signup} />
<Route path="/analytics" component={BarChart} />
</Suspense>
</Router>
</AuthProvider>
Expand Down
51 changes: 51 additions & 0 deletions src/renderer/src/BarChart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { onMount, onCleanup } from 'solid-js'
import * as echarts from 'echarts'

const BarChart = () => {
let chartDiv: HTMLElement | null | undefined

onMount(() => {
// Initialize the chart
const myChart = echarts.init(chartDiv, 'dark')

// Specify the chart options
const options = {
title: {
text: 'Deep Work Hours'
},
animationDuration: 3000,
tooltip: {},
xAxis: {
type: 'category',
data: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
},
yAxis: {
type: 'value'
},
series: [
{
name: 'Hours',
type: 'bar',
data: [5, 6, 7, 8, 4, 3, 6] // Example data
}
]
}

// Set the options to the chart
myChart.setOption(options)

// Add resize listener to make the chart responsive
window.addEventListener('resize', () => {
myChart.resize()
})

// Clean up the chart on unmount
onCleanup(() => {
myChart.dispose()
})
})

return <div ref={chartDiv} style={{ width: '100%', height: '400px' }}></div>
}

export default BarChart

0 comments on commit 796aa10

Please sign in to comment.