Skip to content
WebJs
Menu
Trace, Code Block and AI Elements

Beautiful Charts & Graphs

A collection of ready-to-use chart components, drawn as SVG on the server. From basic charts to rich data displays, copy and paste into your apps.

Radar Charts

Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-default.ts
/**
 * A radar chart, a chart block ported from shadcn/ui's chart-radar-default.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-default` at
 * `components/charts/chart-radar-default.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarDefault()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 273 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarDefault() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false },
          angleAxis: { dataKey: 'month' },
          grid: {},
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-dots.ts
/**
 * A radar chart with dots, a chart block ported from shadcn/ui's chart-radar-dots.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-dots` at
 * `components/charts/chart-radar-dots.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarDots()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 273 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarDots() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Dots</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false },
          angleAxis: { dataKey: 'month' },
          grid: {},
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6, dot: { r: 4, fillOpacity: 1 } }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Dots
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-lines-only.ts
/**
 * A radar chart with lines only, a chart block ported from shadcn/ui's chart-radar-lines-only.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-lines-only` at
 * `components/charts/chart-radar-lines-only.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarLinesOnly()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 160 },
  { month: 'February', desktop: 185, mobile: 170 },
  { month: 'March', desktop: 207, mobile: 180 },
  { month: 'April', desktop: 173, mobile: 160 },
  { month: 'May', desktop: 160, mobile: 190 },
  { month: 'June', desktop: 174, mobile: 204 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarLinesOnly() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Lines Only</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line' },
          angleAxis: { dataKey: 'month' },
          grid: { radialLines: false },
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0, stroke: 'var(--color-desktop)', strokeWidth: 2 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)', fillOpacity: 0, stroke: 'var(--color-mobile)', strokeWidth: 2 },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Lines Only
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-label-custom.ts
/**
 * A radar chart with a custom label, a chart block ported from shadcn/ui's chart-radar-label-custom.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-label-custom` at
 * `components/charts/chart-radar-label-custom.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarLabelCustom()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarLabelCustom() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Custom Label</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line' },
          angleAxis: {
            dataKey: 'month',
            // Each month as desktop / mobile over its name.
            tick: ({ x, y, textAnchor, index, datum }) => svg`
              <text x=${x} y=${y + (index === 0 ? -10 : 0)} text-anchor=${textAnchor} font-size="13" font-weight="500">
                <tspan>${datum.desktop}</tspan><tspan class="fill-muted-foreground">/</tspan><tspan>${datum.mobile}</tspan><tspan
                  x=${x} dy="1rem" font-size="12" class="fill-muted-foreground">${datum.month}</tspan>
              </text>`,
          },
          grid: {},
          margin: { top: 10, right: 10, bottom: 10, left: 10 },
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)' },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Custom Label
Showing total visitors for the last 6 months
186/80January 305/200February 237/120March 73/190April 209/130May 214/140June
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-custom.ts
/**
 * A radar chart with a custom grid, a chart block ported from shadcn/ui's chart-radar-grid-custom.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-custom` at
 * `components/charts/chart-radar-grid-custom.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridCustom()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 273 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridCustom() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid Custom</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, hideLabel: true },
          angleAxis: { dataKey: 'month' },
          grid: { radialLines: false, polarRadius: [90], strokeWidth: 1 },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid Custom
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-none.ts
/**
 * A radar chart with no grid, a chart block ported from shadcn/ui's chart-radar-grid-none.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-none` at
 * `components/charts/chart-radar-grid-none.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridNone()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 273 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridNone() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid None</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, hideLabel: true },
          angleAxis: { dataKey: 'month' },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6, dot: { r: 4, fillOpacity: 1 } }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid None
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-circle.ts
/**
 * A radar chart with a grid and circle, a chart block ported from shadcn/ui's chart-radar-grid-circle.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-circle` at
 * `components/charts/chart-radar-grid-circle.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridCircle()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 273 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridCircle() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid Circle</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, hideLabel: true },
          angleAxis: { dataKey: 'month' },
          grid: { gridType: 'circle' },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6, dot: { r: 4, fillOpacity: 1 } }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid Circle
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-circle-no-lines.ts
/**
 * A radar chart with a grid and circle fill, a chart block ported from shadcn/ui's chart-radar-grid-circle-no-lines.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-circle-no-lines` at
 * `components/charts/chart-radar-grid-circle-no-lines.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridCircleNoLines()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 305 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 203 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 214 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridCircleNoLines() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid Circle - No lines</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, hideLabel: true },
          angleAxis: { dataKey: 'month' },
          grid: { gridType: 'circle', radialLines: false },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6, dot: { r: 4, fillOpacity: 1 } }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid Circle - No lines
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-circle-fill.ts
/**
 * A radar chart with a grid and circle fill, a chart block ported from shadcn/ui's chart-radar-grid-circle-fill.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-circle-fill` at
 * `components/charts/chart-radar-grid-circle-fill.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridCircleFill()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 285 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 203 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 264 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridCircleFill() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid Circle Filled</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false },
          angleAxis: { dataKey: 'month' },
          grid: { class: 'fill-(--color-desktop) opacity-20', gridType: 'circle' },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.5 }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid Circle Filled
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-grid-fill.ts
/**
 * A radar chart with a grid filled, a chart block ported from shadcn/ui's chart-radar-grid-fill.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-grid-fill` at
 * `components/charts/chart-radar-grid-fill.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarGridFill()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186 },
  { month: 'February', desktop: 285 },
  { month: 'March', desktop: 237 },
  { month: 'April', desktop: 203 },
  { month: 'May', desktop: 209 },
  { month: 'June', desktop: 264 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarGridFill() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Grid Filled</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, hideLabel: true },
          angleAxis: { dataKey: 'month' },
          grid: { class: 'fill-(--color-desktop) opacity-20' },
          radars: [{ dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.5 }],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Grid Filled
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-multiple.ts
/**
 * A radar chart with multiple data, a chart block ported from shadcn/ui's chart-radar-multiple.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-multiple` at
 * `components/charts/chart-radar-multiple.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarMultiple()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarMultiple() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Multiple</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line' },
          angleAxis: { dataKey: 'month' },
          grid: {},
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)' },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Multiple
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-legend.ts
/**
 * A radar chart with a legend, a chart block ported from shadcn/ui's chart-radar-legend.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-legend` at
 * `components/charts/chart-radar-legend.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarLegend()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarLegend() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Legend</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cardContentClass()}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line' },
          angleAxis: { dataKey: 'month' },
          grid: {},
          margin: { top: -40, bottom: -10, left: 0, right: 0 },
          legend: { class: 'mt-8', height: 60 },
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)' },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 pt-4 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Legend
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Desktop
Mobile
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-icons.ts
/**
 * A radar chart with icons, a chart block ported from shadcn/ui's chart-radar-icons.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-icons` at
 * `components/charts/chart-radar-icons.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarIcons()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
    icon: () => ArrowDownFromLine(),
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
    icon: () => ArrowUpFromLine(),
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

// lucide's arrow-down-from-line and arrow-up-from-line, the series icons.
const ArrowDownFromLine = () => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="lucide lucide-arrow-down-from-line"><path d="M19 3H5"></path><path d="M12 21V7"></path><path d="m6 15 6 6 6-6"></path></svg>`;
const ArrowUpFromLine = () => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="lucide lucide-arrow-up-from-line"><path d="m18 9-6-6-6 6"></path><path d="M12 3v14"></path><path d="M5 21h14"></path></svg>`;

export default function ChartRadarIcons() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Icons</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cardContentClass()}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line' },
          angleAxis: { dataKey: 'month' },
          grid: {},
          margin: { top: -40, bottom: -10, left: 0, right: 0 },
          legend: { class: 'mt-8', height: 60 },
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)' },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 pt-4 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Icons
Showing total visitors for the last 6 months
JanuaryFebruaryMarchAprilMayJune
Desktop
Mobile
Radar Chart

Code

View the code for the chart.

components/charts/chart-radar-radius.ts
/**
 * A radar chart with a radius axis, a chart block ported from shadcn/ui's chart-radar-radius.
 *
 * Installed by `npx @webjsdev/ui add chart-radar-radius` at
 * `components/charts/chart-radar-radius.ts`. It is app code you own, so edit it
 * freely, and render it from any page with `${ChartRadarRadius()}`.
 */
import { html, svg } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  cardClass, cardContentClass, cardDescriptionClass, cardFooterClass, cardHeaderClass, cardTitleClass,
} from '../ui/card.ts';
import { radarChart, type ChartConfig } from '../ui/chart.ts';

const chartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const chartConfig = {
  desktop: {
    label: 'Desktop',
    color: 'var(--chart-1)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--chart-2)',
  },
} satisfies ChartConfig;

// lucide's trending-up, the icon in shadcn's footer.
const TrendingUp = (cls = '') => svg`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class=${'lucide lucide-trending-up ' + cls}><path d="M16 7h6v6"></path><path d="m22 7-8.5 8.5-5-5L2 17"></path></svg>`;

export default function ChartRadarRadius() {
  return html`
    <div data-slot="card" class=${cardClass()}>
      <div data-slot="card-header" class=${cn(cardHeaderClass(), 'items-center pb-4')}>
        <div data-slot="card-title" class=${cardTitleClass()}>Radar Chart - Radius Axis</div>
        <div data-slot="card-description" class=${cardDescriptionClass()}>Showing total visitors for the last 6 months</div>
      </div>
      <div data-slot="card-content" class=${cn(cardContentClass(), 'pb-0')}>
        ${radarChart({
          config: chartConfig,
          class: 'mx-auto aspect-square max-h-[250px]',
          data: chartData,
          title: 'Visitors by month',
          tooltip: { cursor: false, indicator: 'line', labelKey: 'month' },
          grid: {},
          radiusAxis: { angle: 60, stroke: 'var(--foreground)', orientation: 'middle' },
          radars: [
            { dataKey: 'desktop', fill: 'var(--color-desktop)', fillOpacity: 0.6 },
            { dataKey: 'mobile', fill: 'var(--color-mobile)' },
          ],
        })}
      </div>
      <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col gap-2 text-sm')}>
        <div class="flex items-center gap-2 leading-none font-medium">
          Trending up by 5.2% this month ${TrendingUp('h-4 w-4')}
        </div>
        <div class="flex items-center gap-2 leading-none text-muted-foreground">January - June 2024</div>
      </div>
    </div>
  `;
}
Radar Chart - Radius Axis
Showing total visitors for the last 6 months
080160240320