0.0.13 • Published 3 years ago

modified-hgraph v0.0.13

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

hGraph React

An open source visualization for patient health data, as a React component using d3.

View the React based demo for this repository.

See the core hGraph repo for more examples and roadmap.

Looking for React Native? Check out the port to React Native from Citizen Health.

hGraph

Installation

This package can be found on npm and installed like so:

$ yarn add hgraph-react
# or
$ npm install hgraph-react

The hGraph component is packaged using webpack.

Usage

hGraph Component Props

Most props are not required and have sensible defaults built in, as listed below.

Prop NameTypeIs RequiredDescriptionDefault
dataarraytrueAn array of objects representing the metrics to display in hGraph (see below)N/A
scorenumberfalseThe overall score to display in the center of hGraphN/A
widthnumberfalseThe width in pixels hGraph should render at.600
heightnumberfalseThe height in pixels hGraph should render at.600
marginobjectfalseAn object representing the values for margins around hGraph.{ top: 70, right: 100, bottom: 70, left: 100 }
thresholdMinnumberfalseA number value between 0 and 1 (percentage), determining the position the lower threshold of the healthy range renders at..25
thresholdMaxnumberfalseA number value between 0 and 1 (percentage), determining the position the upper threshold of the healthy range renders at..75
donutHoleFactornumberfalseA number value between 0 and 1 (percentage), determining the amount of hGraph's radius that should be cut out forming the hole in the center of the graph..4
colorstring (hex color code)falseThe color of the points and polygon shape.'#616363'
healthyRangeFillColorstring (hex color code)falseThe color of the healthy range band.'#98bd8e'
fontSizenumberfalseThe size (in pixels) of the font for the labels.16
fontColorstring (hex color code)falseThe color of the labels.'#000'
showAxisLabelbooleanfalseWhether or not axis labels should display around hGraph.true
axisLabelWrapWidthnumberfalseThe width (in pixels) that the labels should wrap text at.80 (Note: use null for no wrapping)
axisLabelOffsetnumberfalseThe distance (in pixels) that axis labels should be offset from the outer bounds of hGraph's 'absolute max' radius.12
areaOpacitynumberfalseThe opacity of the polygon shape.0.25
pointRadiusnumberfalseThe radius (in pixels) of the points for metric values.10
pointLabelWrapWidthnumberfalseThe width (in pixels) that the point labels should wrap text at.null (no wrapping)
pointLabelOffsetnumberfalseThe distance (in pixels) that point labels should be offset from the point.8
hitboxRadiusnumberfalseThe radius (in pixels) of the point hitboxes. (hGraph overlays a transparent hitbox over each point which can help users accurately click/touch points, particularly on mobile devices.)Defaults to props.pointRadius size.
showScorebooleanfalseWhether or not to display the overall score in the middle of hGraph.true
scoreFontSizenumberfalseThe size (in pixels) of the font for the overall hGraph score120
scoreFontColorstring (hex color code)falseThe color of the hGraph score.'#000'
zoomFactornumberfalseThe multiplier factor hGraph should zoom in.2.25
zoomTransitionTimenumberfalseThe amount of time (in milliseconds) the zooming animation should take.750
zoomOnPointClickbooleanfalseConfigure if hGraph should zoom in/focus on a clicked point and display child points in the graph.true
onPointClickfunctionfalseCallback function called when a point is clicked. Function is passed 2 arguments: the data object corresponding to the point clicked, and the event.N/A

hGraph Metric Object Properties

Property NameTypeIs RequiredDescription
idstringtrueA unique (compared to all other metrics) identifier string for the metric.
labelstringtrueThe axis display label for the metric.
valuenumbertrueThe patient's recorded value for the metric.
healthyMinnumbertrueThe minimum value possible to still be considered a healthy value.
healthyMaxnumbertrueThe maximum value possible to still be considered a healthy value.
absoluteMinnumbertrueA reasonable minimum possible value for this metric. Note: values below this absolute minimum will be clamped to the min.)
absoluteMaxnumbertrueA reasonable maximum possible value for this metric. Note: values above this absolute maximum will be clamped to the max.
unitLabelstringtrueThe units the metric is measured in, displayed with the metric value.
childrenarrayfalseOptional array of child metrics that comprise this metric. Children metrics should conform to hGraph Metric Objects properties. Children are shown when a point is clicked and hGraph is in the "zoomed in" state.

License

hGraph is Apache 2.0 licensed.

For guidance integrating hGraph into your product or service, contact us at hello@goinvo.com.