How to use the @patternfly/react-charts.ChartTooltip.defaultEvents function in @patternfly/react-charts

To help you get started, we’ve selected a few @patternfly/react-charts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oVirt / ovirt-web-ui / src / components / VmDetails / cards / UtilizationCard / UtilizationCharts / BarChart.js View on Github external
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>