Skip to content

Commit 61119e3

Browse files
committed
Show line in BarCharts
1 parent e01d9ba commit 61119e3

File tree

2 files changed

+21
-5
lines changed
  • client/src/views/Dashboard

2 files changed

+21
-5
lines changed

client/src/views/Dashboard/GroupedBarChart/index.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ import {
1010
Tooltip,
1111
Legend,
1212
ResponsiveContainer,
13+
ComposedChart,
14+
Line,
1315
} from 'recharts';
1416

1517
function CustomizedLabel(props) {
1618
const { x, y, width, value } = props;
17-
1819
return (
1920
<text
20-
x={x + width / 2.75}
21+
x={x + width / 3}
2122
y={y}
2223
dy={-8}
23-
fontSize={12}
24+
fontSize={10}
2425
>
2526
{value}
2627
</text>
@@ -30,6 +31,7 @@ function CustomizedLabel(props) {
3031
export default function GroupedBarChart(props) {
3132
const {
3233
data,
34+
lineKey,
3335
} = props;
3436

3537
if (isNotDefined(data) || isNotDefined(data.values) || data.values.length <= 0) {
@@ -43,7 +45,7 @@ export default function GroupedBarChart(props) {
4345
height={250}
4446
width="100%"
4547
>
46-
<BarChart
48+
<ComposedChart
4749
data={data.values}
4850
margin={{ top: 50 }}
4951
>
@@ -57,13 +59,25 @@ export default function GroupedBarChart(props) {
5759
key={column}
5860
fill={data.colors[column]}
5961
label={<CustomizedLabel />}
62+
style={{ cursor: 'pointer' }}
6063
/>
6164
))}
62-
</BarChart>
65+
{!!lineKey && (
66+
<Line
67+
dataKey={lineKey}
68+
stroke="#0591fb"
69+
/>
70+
)}
71+
</ComposedChart>
6372
</ResponsiveContainer>
6473
);
6574
}
6675

76+
GroupedBarChart.defaultProps = {
77+
lineKey: '',
78+
};
79+
6780
GroupedBarChart.propTypes = {
6881
data: PropTypes.object.isRequired,
82+
lineKey: PropTypes.string,
6983
};

client/src/views/Dashboard/SummaryContainer/TrendSummary/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ class TrendSummary extends React.PureComponent {
335335
{rcData.values.length > 0 && (
336336
<GroupedBarChartRecharts
337337
data={rcData}
338+
lineKey="Planned RC"
338339
/>
339340
)}
340341
{/* <GroupedBarChart
@@ -356,6 +357,7 @@ class TrendSummary extends React.PureComponent {
356357
{childMonitoringData.values.length > 0 && (
357358
<GroupedBarChartRecharts
358359
data={childMonitoringData}
360+
lineKey="Not Sighted More than 90 Days"
359361
/>
360362
)}
361363
{/* <GroupedBarChart

0 commit comments

Comments
 (0)