diff --git a/src/components/Reports/InfringementsViz.jsx b/src/components/Reports/InfringementsViz.jsx index 028645a591..1f37f4f8f6 100644 --- a/src/components/Reports/InfringementsViz.jsx +++ b/src/components/Reports/InfringementsViz.jsx @@ -1,10 +1,18 @@ /* eslint-disable testing-library/no-node-access */ -import React from 'react'; import * as d3 from 'd3'; - +import React from 'react'; import { Button, Modal } from 'react-bootstrap'; -import styles from './PeopleReport/PeopleReport.module.css'; import { boxStyle, boxStyleDark } from '../../styles'; +import styles from './PeopleReport/PeopleReport.module.css'; +import { + createAxes, + createDots, + createLabels, + createLegend, + createLine, + createSvgRoot, + createTooltip, +} from './d3GraphUtils'; function InfringementsViz({ infringements, fromDate, toDate, darkMode }) { const [graphVisible, setGraphVisible] = React.useState(false); @@ -18,197 +26,97 @@ function InfringementsViz({ infringements, fromDate, toDate, darkMode }) { const handleModalShow = d => { setFocusedInf(d); - if (graphVisible === false) { - setModalVisible(!modalVisible); - } - setGraphVisible(!graphVisible); // Open the graph when opening the modal + if (graphVisible === false) setModalVisible(!modalVisible); + setGraphVisible(!graphVisible); }; + function displayGraph(bsCount, maxSquareCount) { if (!graphVisible) { d3.selectAll('#infplot > *').remove(); } else { d3.selectAll('#infplot > *').remove(); + const margin = { top: 30, right: 20, bottom: 30, left: 20 }; const containerWidth = '1000'; - // Adjusted width based on the available space const width = Math.min(containerWidth - margin.left - margin.right, 1000); - const height = 400 - margin.top - margin.bottom; - const tooltipEl = function tooltipEl(d) { - return ( - `${'
| Descriptions | +
|---|
| Descriptions |
| {desc} | + ? focusedInf.des.map(desc => ( +
| {desc} |