Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react'
import PropTypes from 'prop-types'
import { ChartBar, Chart, ChartAxis, ChartTooltip, ChartStack, ChartLabel } from '@patternfly/react-charts'
const CustomLabel = ({ label, offsetX, text, ...rest }) => {
const t = label ? typeof label === 'function' ? label(rest.datum) : label : ''
return (
)
}
CustomLabel.defaultEvents = ChartTooltip.defaultEvents
CustomLabel.propTypes = {
text: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]),
label: PropTypes.oneOfType([ PropTypes.string, PropTypes.func ]),
offsetX: PropTypes.number,
}
const BarChart = ({ data, additionalLabel, thresholdWarning, thresholdError, id, ...rest }) => {
const availableInPercent = data.map((datum) => ({ x: datum.x, y: 100 - datum.y }))
const maxLength = Math.max(...data.map((datum) => datum.x.length))
const offsetX = maxLength * 14
return <div id="{id}">
</div>