abircode/smartvisual 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

abircode/smartvisual

最新稳定版本:v1.0.0

Composer 安装命令:

composer require abircode/smartvisual

包简介

A powerful Laravel package for creating stunning custom charts with AI-driven auto-detection, Livewire integration, and Vue/React support - Built from scratch by AbirCodes

README 文档

README

SmartVisual is a Laravel visualization package built from scratch by AbirCodes. It renders charts using a custom SVG engine and does not depend on Chart.js.

Features

  • Custom SVG rendering engine
  • Bar, Line, Radar, Pie, Doughnut charts
  • AI chart auto-detection
  • JSON and SVG export out of the box
  • Optional PNG export (requires Imagick)
  • Optional PDF export (requires dompdf)
  • Live dashboard friendly output

Requirements

  • PHP 8.1+
  • Laravel 9, 10, 11, or 12

Installation (Step by Step)

1) Install package

composer require abircode/smartvisual

2) Publish package config

php artisan vendor:publish --provider="Apack\SmartVisual\SmartVisualServiceProvider"

3) Clear cached config

php artisan optimize:clear

Basic Usage

use Apack\SmartVisual\Facades\Chart;

$chart = Chart::bar()
    ->setTitle('Monthly Sales')
    ->setLabels(['Jan', 'Feb', 'Mar', 'Apr'])
    ->addDataset('Revenue', [120, 180, 160, 210]);

$svg = $chart->render();

Example Controller

Create app/Http/Controllers/ChartController.php:

<?php

namespace App\Http\Controllers;

use Apack\SmartVisual\Facades\Chart;

class ChartController extends Controller
{
    public function index()
    {
        $barChart = Chart::bar()
            ->setTitle('Monthly Sales Report')
            ->setLabels(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'])
            ->addDataset('2024', [65, 59, 80, 81, 56, 55])
            ->addDataset('2023', [45, 39, 60, 61, 36, 35]);

        $lineChart = Chart::line()
            ->setTitle('Website Traffic')
            ->setLabels(['Week 1', 'Week 2', 'Week 3', 'Week 4'])
            ->addDataset('Visitors', [1200, 1900, 1500, 2200])
            ->addDataset('Page Views', [2100, 2400, 2100, 2800])
            ->setFillArea(true);

        $radarChart = Chart::radar()
            ->setTitle('Skills Assessment')
            ->setLabels(['PHP', 'JS', 'SQL', 'DevOps', 'UI/UX'])
            ->addDataset('Dev A', [85, 90, 78, 82, 88])
            ->addDataset('Dev B', [78, 85, 92, 75, 80]);

        $pieChart = Chart::pie()
            ->setTitle('Market Share')
            ->setLabels(['Product A', 'Product B', 'Product C', 'Product D'])
            ->addDataset('Share', [30, 25, 25, 20]);

        return view('charts.index', [
            'barSvg' => $barChart->render(),
            'lineSvg' => $lineChart->render(),
            'radarSvg' => $radarChart->render(),
            'pieSvg' => $pieChart->render(),
        ]);
    }
}

Example Blade View

Create resources/views/charts/index.blade.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SmartVisual Demo</title>
    <style>
        body { font-family: Georgia, serif; margin: 0; padding: 24px; background: #f8fafc; }
        .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 16px; }
        .card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px; }
        .card h2 { margin: 0 0 8px 0; font-size: 18px; }
        .chart svg { width: 100%; height: auto; display: block; }
    </style>
</head>
<body>
    <h1>SmartVisual Charts</h1>

    <div class="grid">
        <div class="card">
            <h2>Bar Chart</h2>
            <div class="chart">{!! $barSvg !!}</div>
        </div>

        <div class="card">
            <h2>Line Chart</h2>
            <div class="chart">{!! $lineSvg !!}</div>
        </div>

        <div class="card">
            <h2>Radar Chart</h2>
            <div class="chart">{!! $radarSvg !!}</div>
        </div>

        <div class="card">
            <h2>Pie Chart</h2>
            <div class="chart">{!! $pieSvg !!}</div>
        </div>
    </div>
</body>
</html>

Example Route

Add this in routes/web.php:

use App\Http\Controllers\ChartController;

Route::get('/charts-demo', [ChartController::class, 'index']);

Export Examples

$chart = Chart::pie()
    ->setTitle('Segment Mix')
    ->setLabels(['Enterprise', 'Growth', 'Mid-Market', 'Starter'])
    ->addDataset('Mix', [34, 26, 22, 18]);

$svgPath = $chart->export('svg');
$jsonPath = $chart->export('json');

// Requires Imagick
// $pngPath = $chart->export('png');

// Requires dompdf/dompdf
// $pdfPath = $chart->export('pdf');

Demo Dashboard Screenshots

These snapshots are generated from the live demo dashboard endpoint.

Revenue Momentum

Revenue Momentum

Delivery Capacity

Delivery Capacity

Segment Mix

Segment Mix

Operational Health

Operational Health

Local Development Test

php test_package.php

Notes

  • If you use local path installation for testing, set a Composer path repository in your Laravel app.
  • If export to PNG or PDF fails, install the required optional dependencies listed above.
  • For interactive dashboards, use periodic AJAX refresh and swap rendered SVG blocks.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固