Skip to content

Commit

Permalink
#1365 Fixing some issues in the stability chart
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Dec 7, 2024
1 parent e5714b3 commit 3d2a03c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 8 additions & 6 deletions ontrack-web-core/components/charts/CountChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import {useEffect, useState} from "react";
import {Bar, CartesianGrid, ComposedChart, Legend, Tooltip, XAxis, YAxis} from "recharts";
import ChartContainer from "@components/charts/ChartContainer";

export default function CountChart({query, variables, yTickFormatter}) {
export default function CountChart({
query,
variables,
yTickFormatter,
legendFormatter = () => "Count ",
domain,
}) {

const client = useGraphQLClient()

Expand Down Expand Up @@ -40,10 +46,6 @@ export default function CountChart({query, variables, yTickFormatter}) {
}
}, [client, query, variables]);

const legendFormatter = (value, entry, index) => {
return "Count"
}

const [inactiveSeries, setInactiveSeries] = useState([])

const legendClick = ({dataKey}) => {
Expand All @@ -62,7 +64,7 @@ export default function CountChart({query, variables, yTickFormatter}) {
>
<CartesianGrid strokeDasharray="3 3"/>
<XAxis dataKey="date" angle={-45} tickMargin={30} height={80} interval="preserveStart"/>
<YAxis tickFormatter={yTickFormatter}/>
<YAxis tickFormatter={yTickFormatter} domain={domain}/>
<Tooltip/>
<Legend formatter={legendFormatter} onClick={legendClick} style={{cursor: 'pointer'}}/>
<Bar dataKey="value" fill="#6666aa" hide={inactiveSeries.includes('value')}/>
Expand Down
4 changes: 3 additions & 1 deletion ontrack-web-core/components/charts/PercentageChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export default function PercentageChart({query, variables}) {
<CountChart
query={query}
variables={variables}
yTickFormatter={percentageFormatter()}
yTickFormatter={percentageFormatter}
legendFormatter={() => "%"}
domain={[0, 100]}
/>
</>
)
Expand Down

0 comments on commit 3d2a03c

Please sign in to comment.