one-click-accessibility/modules/settings/assets/js/components/analytics/charts/line-chart.js
VasylD f0dce2793e
[APP-1923][APP-1924] manage remediations, global remediations (#424)
* [APP-1923] change remediation management (#411)

* [APP-1988] Add tabs

* [APP-1988][APP-1989] add tabs, remove menu item

* [APP-1988][APP-1989] add tabs, remove menu item

* [APP-1992] add empty state and tab navigation

* [APP-1993][APP-1994] Change view for manage AI fixes, change delete confirmation modal

* [APP-1996] add view for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1996] add edit for alt text fixes

* [APP-1995] Color contrast form

* [APP-2001] add global remediation logic (#415)

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2001] add global remediation logic

* [APP-2003] add disable across scans (#418)

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* [APP-2003] add disable across scans

* add logs

* add logs

* add logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* remove logs

* change to theme value

* change to theme value

* change to theme value

* change to theme value

* add edit mode

* add edit mode

* add edit mode
2025-11-10 16:25:45 +07:00

67 lines
1.8 KiB
JavaScript

import Card from '@elementor/ui/Card';
import CardHeader from '@elementor/ui/CardHeader';
import Typography from '@elementor/ui/Typography';
import { useTheme } from '@elementor/ui/styles';
import { LineChart as MuiLineChart } from '@mui/x-charts/LineChart';
import { LineChartTitle } from '@ea11y/components/analytics/components/line-chart-title';
import { LineTooltip } from '@ea11y/components/analytics/components/line-tooltip';
import { NoData } from '@ea11y/components/analytics/components/no-data';
import { dateI18n } from '@wordpress/date';
import { useAnalyticsContext } from '../../../contexts/analytics-context';
export const LineChart = () => {
const theme = useTheme();
const { stats } = useAnalyticsContext();
const totalOpen = stats.dates.reduce(
(sum, item) => sum + Number(item.total),
0,
);
const showChart = stats.dates.length > 0;
return (
<Card variant="outlined" sx={{ height: '100%' }}>
<CardHeader
title={<LineChartTitle />}
subheader={
totalOpen > 0 ? (
<Typography variant="h3" sx={{ height: '50px' }}>
{totalOpen.toString()}
</Typography>
) : null
}
sx={{ pb: 0 }}
/>
{showChart && (
<MuiLineChart
series={[
{
type: 'line',
curve: 'linear',
data: stats.dates.map((item) => item.total),
color: theme.palette.info.main,
},
]}
xAxis={[
{
scaleType: 'point',
data: stats.dates.map((item) => item.date),
valueFormatter: (item, context) =>
context.location === 'tick'
? dateI18n('d.m', item, false)
: item,
},
]}
slots={{
axisContent: LineTooltip,
}}
tooltip={{
trigger: totalOpen ? 'axis' : 'none',
}}
height={250}
/>
)}
{stats.dates.length === 0 && <NoData />}
</Card>
);
};