Skip to main content

Dot Plot

A Dot Plot is a simple form of data visualization that uses dots to show the distribution of a dataset. It is particularly useful for showing the shape of a small to moderate-sized dataset.

Installation

The DotPlot component is part of the @rexora/charts package. You can install it using npm or yarn:

npm install @rexora/charts
# or
yarn add @rexora/charts

Usage

Here's an example of how to use the DotPlot component:

import React from 'react';
import { DotPlot } from '@rexora/charts';

const data = [
{ value: 1 },
{ value: 2 },
{ value: 2 },
{ value: 3 },
{ value: 3 },
{ value: 3 },
{ value: 4 },
{ value: 4 },
{ value: 5 },
];

const MyComponent = () => {
return (
<div>
<h2>My Dot Plot</h2>
<DotPlot data={data} width={600} height={400} />
</div>
);
};

export default MyComponent;

Props and Options

The DotPlot component accepts the following props:

PropTypeDescriptionDefault
dataArrayThe data array for the dot plot. Each object should have a value property[]
widthnumberThe width of the chart SVGnull
heightnumberThe height of the chart SVGnull
optionsobjectConfiguration options for the chart{}

Options

OptionTypeDescriptionDefault
dotColorstringThe color of the dots#333
dotRadiusnumberThe radius of the dots3
marginobjectMargins around the chart ({ top, right, bottom, left }){ top: 20, right: 20, bottom: 30, left: 40 }