Chart

A chart component visually represents data, such as bar, line, or pie charts. It takes in data and configuration props (labels, values, colors) and renders a chart.

Basic

Charts are used to display data in a clear and concise manner. They are ideal for presenting information in a visually appealing and easy-to-understand format.

Sales

Showing sales for the last year
Profit increased by 10.2% this year
January - December 2024

Installation

If you hit any issues, make sure you check out the installation guide here.

Manual Installation

Sometimes, using the CLI is the way to go, so make sure you install the necessary dependencies for the components you want to use.

And next, you can copy the code below and paste it into your dopest component folder.

Anatomy

Import the components and use them as shown below, adapting the structure to fit each component.

Colors

If you're working on an existing project, you can use these variables. However, if you've just installed Justd, they will already be included during project initialization. You can also customize chart colors, check out the theme page for more options.

@layer base {
  root: {
      --primary-chart: 51.24% 0.22272067527197015 261.09713650910066;
      --secondary-chart: 76.58% 0.119 263.28;
      --tertiary-chart: 63.25% 0.184 258.64;
      --highlight-chart: 81.17% 0.097 249.1;
      --accent-chart: 81.17% 0.097 249.1;
  }
  .dark: {
      --primary-chart: 54.6% 0.215 262.87;
      --secondary-chart: 72.11% 0.142 253.1;
      --tertiary-chart: 63.25% 0.184 258.64;
      --highlight-chart: 81.17% 0.097 249.1;
      --accent-chart: 88.29% 0.057 251.91;
  }
}

Tooltip

Tooltips are used to provide additional information about a chart element when the user hovers over it. They can be used to display additional details, such as the value of a data point, or to provide context about the data.

import { Chart } from "ui"
import { BarChart } from 'recharts'
 
<BarChart accessibilityLayer data={data}>
  <XAxis.../>
  <Chart.Tooltip cursor={false} content={<Chart.TooltipContent />} />
  <Bar.../>
</BarChart>

Legend

Legends are used to display a list of labels for different chart elements. They can be used to provide context about the data and help the user understand the meaning of different colors and shapes.

import { Chart } from "ui"
import { BarChart } from "recharts"
 
<BarChart>
  ...
  <Chart.Legend content={<Chart.LegendContent />} />
</BarChart>

BarChart could be replaced with any other chart component like PieChart, LineChart, etc.

Area Chart

Used to show changes over time, the area chart highlights both trends and volume, with the filled area showing the magnitude of change. It’s useful when you want to emphasize total growth or decline.

Basic

Area Chart

Showing total sales for last year
Sales increased by 8.4% this year
January - December 2023

Stacked

Area Chart - Stacked

Traffic data from various sources over the last 10 months
Overall traffic increased by 15.5% this month
January - October 2024

Linear

Area Chart - Linear

Showing total revenue for this year
Revenue increased by 12.5% this year
January - December 2024

Gradient

Area Chart - Gradient

Showing total visitors for the this year
Profit increased by 10.2% this year
January - December 2024

Bar Chart

Bar charts are perfect for comparing different categories. The lengths of the bars make it easy to compare quantities side by side, showing differences between groups clearly.

Basic

Bar Chart

January - November 2024
Trending up by 10.5% this month
Showing total sales for the last 11 months

Horizontal

Bar Chart - Horizontal

January - July 2024
Sales increased by 5.2% this year
Showing total visitors for the last 7 months

Multiple

Bar Chart - Multiple

January - October 2024
Online courses increased by 15.2% this year
Showing total revenue for january 2023 to august 2024

Custom Label

Bar Chart - Custom Label

The number of visitors to the website has increased by 15.5% this year
Visitors increased by 5.2% this year
Showing total visitors for last year

Mixed

Bar Chart - Mixed

January - September 2024
Trending up by 5.2% this month
Showing total visitors for the last 9 months

Line Chart

A line chart is used to display data points connected by a straight line, showing trends or changes over time. It's ideal for visualizing continuous data, especially when you want to emphasize the direction of change (upward or downward trends) over a period.

Basic

Line Chart

January - December 2024
Sales increased by 5.2% this year
Showing total visitors for one year

Multiple

Line Chart - Multiple

Today's sales and profit for the last 16 months
Profit and sales increased by 12.5% this year
January 2023 - April 2024

Dots

Line Chart - Dots

January - June 2024
Profit increased by 5.2% this year
Showing total profit for the last 10 months

Dots Color

Line Chart - Dots Colors

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 10 months

Custom Label

Line Chart - Label

January - October 2024
Revenue increased by 5.2% this year
Showing total revenue for the last 10 months

Linear

Line Chart - Linear

January - December 2024
Sales increased by 5.2% this year
Showing sales for january 2023 to october 2024

Pie Chart

A pie chart divides data into proportional slices to represent parts of a whole. It's ideal for displaying relative sizes of categories, especially when you need a visual comparison of percentages.

Basic

Pie Chart

January - September 2024
Subscribers increased by 8.5% this year
Showing total subscribers for the last 3 months

Interactive

Pie Chart - Interactive

January - June 2024

Label

Pie Chart - Label

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Stacked

Pie Chart - Stacked

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Radar Chart

Radar charts display multiple variables in relation to a central point, allowing you to compare several categories at once. It's useful for visualizing performance, skills, or capabilities across multiple metrics.

Basic

Radar Chart

Showing total visitors for last year
Sales increased by 5.2% this year
January - December 2023

Multiple

Radar Chart - Multiple

Showing total visitors for last year
Profit increased by 5.2% this year
January - December 2023

Dots

Radar Chart - Dots

Showing total visitors for last year
Sales increased by 5.2% this year
January - December 2023

Icon

Radar Chart - Icons

Showing total visitors for the last 6 months
Trending up by 5.2% this month
January - June 2024

Line Only

Radar Chart - Lines Only

Showing total visitors for last year
Profit increased by 5.2% this year
January - December 2023

Radial Chart

A radial chart is a circular graph where data points are plotted in a circular arrangement around a central point, radiating outwards. It’s used to display multivariate data where multiple variables are compared on the same scale. Radial charts help in visualizing relationships between different data points and often make it easier to see overall patterns or outliers in the data.

Basic

Radial Chart

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Grid

Radial Chart - Grid

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Stacked

Radial Chart - Stacked

August - December 2023
Profit increased by 5.2% this year
Showing total profit and sales for the last 3 months

Text

Radial Chart - Text

January - June 2024
Visitors increased by 5.2% this year
Showing total visitors for the last 3 months

Shape

Radial Chart - Shape

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Radial

Radial charts are a type of chart that displays data in a circular format. They are often used to visualize data that is spread out in a circular pattern, such as the distribution of sales across different regions or the concentration of customers in different areas.

Basic

Radial Chart

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Grid

Radial Chart - Grid

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Stacked

Radial Chart - Stacked

August - December 2023
Profit increased by 5.2% this year
Showing total profit and sales for the last 3 months

Text

Radial Chart - Text

January - June 2024
Visitors increased by 5.2% this year
Showing total visitors for the last 3 months

Shape

Radial Chart - Shape

January - June 2024
Trending up by 5.2% this month
Showing total visitors for the last 6 months

Accessibility

For accessibility purposes, you can add the accessibilityLayer prop to the chart component. This will add a role="img" to the chart, which will make it accessible to screen readers.

<AreaChart accessibilityLayer />