mirror of
https://github.com/umami-software/umami.git
synced 2026-02-24 14:35:35 +01:00
New event data screen.
This commit is contained in:
parent
10c438d1de
commit
8ee37d1246
137 changed files with 4918 additions and 321 deletions
|
|
@ -0,0 +1,52 @@
|
|||
import { GridColumn, GridTable } from 'react-basics';
|
||||
import { useEventDataProperties, useEventDataValues, useMessages } from 'components/hooks';
|
||||
import { LoadingPanel } from 'components/common/LoadingPanel';
|
||||
import styles from './EventProperties.module.css';
|
||||
import PieChart from 'components/charts/PieChart';
|
||||
import { useState } from 'react';
|
||||
import { CHART_COLORS } from 'lib/constants';
|
||||
|
||||
export function EventProperties({ websiteId }: { websiteId: string }) {
|
||||
const [propertyName, setPropertyName] = useState('');
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { data, isLoading, isFetched, error } = useEventDataProperties(websiteId);
|
||||
const { data: values } = useEventDataValues(websiteId, propertyName);
|
||||
const chartData =
|
||||
propertyName && values
|
||||
? {
|
||||
labels: values.map(({ value }) => value),
|
||||
datasets: [
|
||||
{
|
||||
data: values.map(({ total }) => total),
|
||||
backgroundColor: CHART_COLORS,
|
||||
borderWidth: 0,
|
||||
},
|
||||
],
|
||||
}
|
||||
: null;
|
||||
|
||||
return (
|
||||
<LoadingPanel isLoading={isLoading} isFetched={isFetched} data={data} error={error}>
|
||||
<div className={styles.container}>
|
||||
<GridTable data={data} cardMode={false} className={styles.table}>
|
||||
<GridColumn name="propertyName" label={formatMessage(labels.property)}>
|
||||
{row => (
|
||||
<div className={styles.link} onClick={() => setPropertyName(row.propertyName)}>
|
||||
{row.propertyName}
|
||||
</div>
|
||||
)}
|
||||
</GridColumn>
|
||||
<GridColumn name="total" label={formatMessage(labels.count)} />
|
||||
</GridTable>
|
||||
{propertyName && (
|
||||
<div>
|
||||
<strong>{propertyName}</strong>
|
||||
<PieChart key={propertyName} type="doughnut" data={chartData} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</LoadingPanel>
|
||||
);
|
||||
}
|
||||
|
||||
export default EventProperties;
|
||||
Loading…
Add table
Add a link
Reference in a new issue