定制 jonpurvis/radial 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jonpurvis/radial

Composer 安装命令:

composer require jonpurvis/radial

包简介

Beautiful donut and pie charts for Flux UI. Drop-in components with hover effects, legends, and dark mode support.

README 文档

README

Radial is a companion for Flux UI, adding donut and pie charts styled to match Flux’s look and feel. Simple to use, with hover effects, legends, and dark mode support.

Light Dark
Light mode Dark mode

Installation

composer require jonpurvis/radial

Data Structure

Both components use the same segment format. Each segment requires label, value, and class:

$data = [
    ['label' => 'Critical', 'value' => 40, 'class' => 'text-red-500'],
    ['label' => 'Warning', 'value' => 25, 'class' => 'text-yellow-500'],
    ['label' => 'Healthy', 'value' => 35, 'class' => 'text-green-500'],
];
Key Type Description
label string Segment name (shown in tooltip and, for donut, in center on hover)
value int|float Segment value (determines arc size)
class string Tailwind color class for the segment (e.g. text-blue-500)

Donut Component

A radial chart with a number in the center, perfect for dashboards. Segments highlight on hover, showing values in a tooltip and in the center.

Basic usage

<radial:donut :data="$data" label="Total" />

Donut – all options

Prop Type Default Description
data array [] Segments with label, value, and class (Tailwind color)
label string|null null Center label shown below the value
value int|float|null null Override center value (defaults to sum of data)
hover string|null null Alternative label shown when hovering the center
hoverLabel string|null null Alias for hover
legend false|'top'|'bottom'|'left'|'right' false Show legend at specified position
tooltip bool true Show tooltip on segment hover
cutout int 70 Inner hole size (0 = solid, 70 = donut, 90 = thin ring)
static bool false Disable hover/tap interactions
size string '13rem' Chart size (width/height)

Donut examples

Legend on any side

<radial:donut :data="$data" legend="bottom" />
<radial:donut :data="$data" legend="top" />
<radial:donut :data="$data" legend="left" />
<radial:donut :data="$data" legend="right" />

Center hover label

<radial:donut :data="$data" label="Total" hover="All Categories" />

Thin ring (cutout 90)

<radial:donut :data="$data" :cutout="90" />

Custom center value

<radial:donut :data="$data" :value="85" label="Score" />

Static (no interactions)

<radial:donut :data="$data" :static="true" :tooltip="false" />

Sizing – use the class attribute; chart stays square:

<radial:donut :data="$data" class="size-64" />
<radial:donut :data="$data" class="max-w-xs mx-auto" />

Pie Component

A solid pie chart (no center hole). Same data structure as the donut; tooltips and legend work the same way.

Basic usage

<radial:pie :data="$data" />

Pie – all options

Prop Type Default Description
data array [] Segments with label, value, and class (Tailwind color)
legend false|'top'|'bottom'|'left'|'right' false Show legend at specified position
tooltip bool true Show tooltip on segment hover
static bool false Disable hover/tap interactions
size string '13rem' Chart size (width/height)

Pie examples

With legend

<radial:pie :data="$data" legend="right" />

Static

<radial:pie :data="$data" :static="true" :tooltip="false" />

Sizing

<radial:pie :data="$data" class="size-64" />

Styling

  • Segment colors use the class key in each data item (e.g. text-green-500).
  • Center text (donut) and tooltips use Flux-style zinc colors.
  • Full dark mode support.

Copy-paste examples

Drop these into a Flux/Livewire page to try the components.

Donut – minimal

@php
    $donutData = [
        ['label' => 'Critical', 'value' => 40, 'class' => 'text-red-500'],
        ['label' => 'Warning', 'value' => 25, 'class' => 'text-yellow-500'],
        ['label' => 'Healthy', 'value' => 35, 'class' => 'text-green-500'],
];
@endphp

<radial:donut :data="$donutData" label="Total" />

Donut – with legend and center hover

@php
    $donutData = [
        ['label' => 'Critical', 'value' => 40, 'class' => 'text-red-500'],
        ['label' => 'Warning', 'value' => 25, 'class' => 'text-yellow-500'],
        ['label' => 'Healthy', 'value' => 35, 'class' => 'text-green-500'],
];
@endphp

<radial:donut :data="$donutData" label="Total" hover="All items" legend="bottom" />

Pie – minimal

@php
    $pieData = [
        ['label' => 'A', 'value' => 30, 'class' => 'text-blue-500'],
        ['label' => 'B', 'value' => 50, 'class' => 'text-emerald-500'],
        ['label' => 'C', 'value' => 20, 'class' => 'text-amber-500'],
];
@endphp

<radial:pie :data="$pieData" />

Pie – with legend

@php
    $pieData = [
        ['label' => 'A', 'value' => 30, 'class' => 'text-blue-500'],
        ['label' => 'B', 'value' => 50, 'class' => 'text-emerald-500'],
        ['label' => 'C', 'value' => 20, 'class' => 'text-amber-500'],
];
@endphp

<radial:pie :data="$pieData" legend="right" />

Side-by-side donut and pie

@php
    $chartData = [
        ['label' => 'Critical', 'value' => 40, 'class' => 'text-red-500'],
        ['label' => 'Warning', 'value' => 25, 'class' => 'text-yellow-500'],
        ['label' => 'Healthy', 'value' => 35, 'class' => 'text-green-500'],
];
@endphp

<div class="flex flex-wrap gap-8 justify-center items-start">
    <radial:donut :data="$chartData" label="Total" legend="bottom" />
    <radial:pie :data="$chartData" legend="right" />
</div>

Contributing

Contributions are welcome. Please open an issue or pull request on GitHub.

License

MIT

统计信息

  • 总下载量: 1.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固