/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. * * OpenCRVS is also distributed under the terms of the Civil Registration * & Healthcare Disclaimer located at http://opencrvs.org/license. * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as React from 'react' import styled, { withTheme } from 'styled-components' import { BarChart, Bar, XAxis, YAxis, Label, ResponsiveContainer, CartesianGrid, Cell } from 'recharts' import { ITheme } from '../theme' import { IDataPoint } from '../chart-datapoint-types' import { CustomizedXAxisTick } from './components/AxisTick' const Container = styled.div` margin-top: 30px; box-sizing: border-box; height: 250px; width: 100%; align-items: center; ` interface IVerticalBarProps { data: IDataPoint[] xAxisLabel: string yAxisLabel: string } const sumUpAllValues = (data: IDataPoint[]) => data.reduce((sum: number, item: IDataPoint) => sum + item.value, 0) export const VerticalBar = withTheme( (props: IVerticalBarProps & { theme: ITheme }) => { const { data, theme, xAxisLabel, yAxisLabel } = props const colours = [ theme.colors.primary, theme.colors.secondary, theme.colors.tertiary ] return ( { const { payload } = tickProps const dataPoint = data.find( ({ label }) => label === payload.value ) return ( ) }} tickLine={false} axisLine={false} dataKey="label" > {data.map((entry, index) => ( ))} ) } )