Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified

Chart

This module renders a dataset as an HTML-based chart representing the data.

Usage

// import the component
import ElementChart from 'calypso/my-sites/chart';

// And use it inline inside the render method of another component
function render() {
    return (
        <ElementChart
            loading={ loading /*boolean*/ }
            data={ data /*array*/ }
            barClick={ barClick /*function*/ }
        />
    );
}

// Example Data Array
/*
[ {
    'label': 		<String>, // x-axis label
    'value': 		<Number>, // bar value
    'nestedValue':	<Number>, // nested bar value or null if no nested bar
    'className': 	<String>, // classname(s) applied to bar container
    'data':			<Object>, // any data that you want to have access to in the barClick callback
    'tooltipData':	[
        {
            label: 		<String>,
            value: 		<Number>,
            link: 		<String>,
            icon: 		<String>,
            className: 	<String>
        }
    ]
} ]
*/

Required Props

  • loading — Any truthy value indicates the chart is loading
  • data — An array of data objects using the format outlined above

Optional Props

  • minTouchBarWidthdefault: 42 The minimum bar width on touch devices
  • minBarWidthdefault: 15 The minimum bar width on non-touch devices
  • barClick - The function to be called when a bar is clicked on the chart, it is passed the entire data object of the bar
  • minBarsToBeShown - The minimun no of bars to be shown
  • hideYAxis - default: false A boolean value whether to hide the y-axis
  • hideXAxis - default: false A boolean value whether to hide the x-axis