AreaChart
The area chart is a line chart with shading below the line. This area chart depicts score over time.
Version 2.0.2
Installation
To install @igloo-ui/area-chart in your project, you will need to run the following command using npm:
npm install @igloo-ui/area-chart
If you prefer Yarn, use the following command instead:
yarn add @igloo-ui/area-chart
Usage
Then to use the component in your code just import it!
import AreaChart from '@igloo-ui/area-chart';
const nFormatter = (num) => {
  const lookup = [
    { value: 1, symbol: '' },
    { value: 1e3, symbol: 'k' },
    { value: 1e6, symbol: 'M' },
    { value: 1e9, symbol: 'B' },
    { value: 1e12, symbol: 'T' },
  ];
  const digits = 2;
  const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
  const item = lookup
    .slice()
    .reverse()
    .find(function (item) {
      return num >= item.value;
    });
  return item
    ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol
    : '0';
};
<AreaChart
  scoreFormatter={nFormatter}
  dateRange={{
    start: '2022-10-01',
    end: '2022-10-07',
  }}
  dataSet={[
    {
      dateTimeStamp: '2022-10-01',
      score: 48878,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-02',
      score: 49879,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-03',
      score: 33587,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-04',
      score: 45445,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-05',
      score: 34534,
      secondaryScore: 30000,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-06',
      score: 34555,
      secondaryScore: 52677,
      name: 'sent',
      secondaryName: 'sent',
    },
    {
      dateTimeStamp: '2022-10-07',
      score: 67897,
      name: 'sent',
      secondaryName: 'sent',
    },
  ]}
/>;
API
AreaChart
| Prop | Type | Default | Description | 
|---|---|---|---|
 className | string | - | Add a specific class to the area chart component | 
 dataSet | DataSet[] | - | The data object that will be used for the area chart | 
 dataTest | string | - | Add a data-test tag for automated tests | 
 dateRange | DateTimeRange | - | The start date and end date for the x axis | 
 isResponsive | boolean | Whether or not the chart should resize | |
 locale | string | - | Update the default locale @deprecated This prop is deprecated and will be removed in the next major version in favor of Igloo's provider | 
 range | DataRange | The min and max value of the y-axis (Possible values: number, 'auto', 'dataMin' or 'dataMax') | |
 xAxisTickCount | number | The maximum elements of the x-axis | |
 scoreFormatter | (score: number) => string | - | The formatter function for the y-axis | 
 tooltipScoreFormatter | (score: number) => string | - | The formatter function for the score on the tooltip | 
 unavailableDataMessage | string | - | The message that is displayed when data is unavailable | 
 loading | boolean | Replaces AreaChart label with a skeleton | 
ChartTooltip
| Prop | Type | Default | Description | 
|---|---|---|---|
 dateFormatter | (date: number) => string | - | |
 scoreFormatter | (score: number) => string | - | |
 getDataScoreHue | (score: number) => string | - | |
 unavailableDataMessage | string | - |