承接 laravel-enso/charts 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

laravel-enso/charts

Composer 安装命令:

composer require laravel-enso/charts

包简介

Backend chart payload builders for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge Requests

Description

Charts is Laravel Enso's backend chart payload builder for the @enso-ui/charts frontend package.

It provides fluent factories for the chart types used across Enso dashboards and reporting screens, then returns normalized arrays that can be serialized directly to the frontend. The package also centralizes default chart colors, plugin defaults, datalabel handling, and axis configuration so host applications can generate consistent Chart.js payloads without hand-crafting dataset structures.

Installation

This package comes pre-installed in Laravel Enso applications that render chart widgets or dashboard analytics.

For standalone installation inside an Enso-based application:

composer require laravel-enso/charts

The package auto-registers its service provider and merges the enso.charts configuration namespace.

If you need to publish the configuration file:

php artisan vendor:publish --tag=charts-config

or:

php artisan vendor:publish --tag=enso-config

Features

  • Provides dedicated factories for:
    • bar charts
    • line charts
    • bubble charts
    • radar charts
    • pie charts
    • doughnut charts
    • polar area charts
  • Returns Chart.js-ready payloads through a single get() call.
  • Supports fluent chart metadata such as:
    • title
    • aspect ratio
    • plugin configuration
    • per-option overrides
  • Supports per-axis configuration for Cartesian charts.
  • Supports per-dataset configuration overrides by dataset label.
  • Supports custom palettes through colorsConfig().
  • Supports chart datalabel configuration through datalabels().
  • Supports optional gridlines and automatic Y-axis minimum handling.
  • Supports short-number formatting hints for the frontend.
  • Ships default Enso chart colors and plugin defaults in config/enso/charts.php.

Usage

Bar chart

use LaravelEnso\Charts\Factories\Bar;

$chart = (new Bar())
    ->title('Quarterly revenue')
    ->labels(['Q1', 'Q2', 'Q3', 'Q4'])
    ->datasets([
        'Revenue' => [12000, 18000, 15000, 22000],
        'Forecast' => [10000, 16000, 17000, 21000],
    ])
    ->gridlines()
    ->shortNumbers()
    ->get();

Line chart

use LaravelEnso\Charts\Factories\Line;

$chart = (new Line())
    ->title('Users by month')
    ->labels(['Jan', 'Feb', 'Mar'])
    ->datasets([
        'Users' => [20, 40, 35],
    ])
    ->fill()
    ->get();

Bubble chart

use LaravelEnso\Charts\Factories\Bubble;

$chart = (new Bubble())
    ->title('Portfolio risk')
    ->labels(['Low risk', 'High risk'])
    ->datasets([
        [
            [12, 4, 10],
            [18, 8, 25],
        ],
        [
            [9, 6, 15],
            [15, 12, 20],
        ],
    ])
    ->get();

::: tip Tip Bubble charts auto-scale point radius by default. If the dataset already contains the exact radius values you want to render, call disableAutoRadius() before get(). :::

API

Factories

  • LaravelEnso\Charts\Factories\Bar Adds horizontal() and stackedScales() helpers for bar datasets.
  • LaravelEnso\Charts\Factories\Line Adds fill() for filled line charts.
  • LaravelEnso\Charts\Factories\Bubble Maps [x, y, radius] tuples into bubble datasets and can auto-scale radius values.
  • LaravelEnso\Charts\Factories\Radar Builds radar chart datasets.
  • LaravelEnso\Charts\Factories\Pie Builds pie chart payloads.
  • LaravelEnso\Charts\Factories\Doughnut Builds doughnut chart payloads.
  • LaravelEnso\Charts\Factories\Polar Builds polar area chart payloads.

Shared fluent methods

All chart factories inherit these methods from LaravelEnso\Charts\Factories\Chart:

  • title(string $title)
  • labels(array $labels)
  • datasets(array $datasets)
  • ratio(float $ratio)
  • option(string $option, mixed $value)
  • plugin(string $plugin, mixed $config)
  • shortNumbers(int $precision = 2)
  • gridlines()
  • autoYMin()
  • datalabels(array $config)
  • colorsConfig(array $colors)
  • datasetConfig(string $dataset, array $config)
  • xAxisConfig(array $config, ?string $dataset = 'x')
  • yAxisConfig(array $config, ?string $dataset = 'y')
  • get()

Payload shape

The factories return arrays with this top-level structure:

  • type
  • title
  • data
  • options

For Cartesian charts, data contains:

  • labels
  • datasets

For bubble charts, data contains:

  • datasets

Each dataset is normalized for the target chart type and enriched with default Enso colors plus datalabel configuration.

Configuration

Config file:

  • config/enso/charts.php

Current package options:

  • fillBackgroundOpacity Opacity used when converting a hex color into an RGBA fill color.
  • options Default Chart.js options merged into each factory response.
  • colors Default Enso chart palette used when no custom colors are supplied.

Depends On

Required Enso packages:

Companion frontend package:

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

laravel-enso/charts 适用场景与选型建议

laravel-enso/charts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.69k 次下载、GitHub Stars 达 17, 最近一次更新时间为 2017 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「charts」 「laravel」 「chartjs」 「laravel-enso」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 laravel-enso/charts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 laravel-enso/charts 我们能提供哪些服务?
定制开发 / 二次开发

基于 laravel-enso/charts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 17
  • Watchers: 5
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-19