承接 llabbasmkhll/laravel-sparkline 相关项目开发

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

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

llabbasmkhll/laravel-sparkline

Composer 安装命令:

composer require llabbasmkhll/laravel-sparkline

包简介

generate small chart and sparklines in your laravel app

README 文档

README

Generate small chart and sparklines in your laravel app like a breeze.
this package helps you to plot prices of stock ,currencies ,crypto, etc, into an image in your laravel app.
it uses image intervention and PHP gd to generate the image.



Installation

composer require abbaudo/laravel-sparkline


Usage

to use sparkline all you have to is providing the numbers that you want to plot to data function and render the chart like below:

$metrics = [76, 80, 50, 62, 32, 55, 42, 5, 10, 2, 22, 5, 6, 26, 25, 55, 40, 32, 55, 42, 5, 10, 2, 22, 56];

return Sparkline::data($metrics)->render()->response('png');

this will generate an sparkline like this:
sparkline

Note

render() will return an Intervention\Image object. more information in image intervention.
if your too lazy to read intervention docs simply use ->response('png') to return the sparkline to the browser.
or ->save('public/fou.jpg') to save the sparkline.



Customization

Color

line

set the color of the sparkline by color function. by defult its yellow.

$red   = 250;
$green = 100;
$blue  = 100;
$alpha = 1;

Sparkline::data($metrics)->color($red, $green, $blue, $alpha)->render()->response('png');

d8l94xyhh

background

set the background color by backgorund function. by defult its transparent.

$red   = 250;
$green = 70;
$blue  = 70;
$alpha = 0.2;

Sparkline::data($metrics)->backgound($red, $green, $blue, $alpha)->render()->response('png');

KTGrO6VsI

fill

to fill the sparkline use fill function. by defult its transparent.

$red   = 250;
$green = 70;
$blue  = 70;
$alpha = 0.2;

Sparkline::data($metrics)->fill($red, $green, $blue, $alpha)->render()->response('png');

a4OK4h092

Thickness

set line thikness by calling thickness like so :

Sparkline::data($metrics)->thikness(3)->render()->response('png');

z_qh8IEhz

Fade

by defult sparklines made with faded color in the begining of the line. to customize it use fade.

Sparkline::data($metrics)->fade(0.2)->render()->response('png');

FCRHK8Zpq
1.0 to maximum fade and 0.0 to remove the fade

Size

to change the size of the sparkline use size. the defult size is 80px for height and 200px for width.

$width = 500;
$height = 100;

Sparkline::data($metrics)->size($width, $height)->render()->response('png');

9Sbe60Lvx

use width and heigt to change the size seperatly.

Sparkline::data($metrics)->width(400)->render()->response('png');

Sparkline::data($metrics)->height(100)->render()->response('png');

Sparkline::data($metrics)->width(300)->height(80)->render()->response('png');


Example

SparklineController.php

class SparklineController extends Controller
{
    public function index(Currency $currency)
    {
        $metrics   = Coingecko::getMetrics($currency->code);
        $sparkline = Sparkline::data($metrics);

        if ($metrics[0] - end($metrics) > 0) {
            $sparkline->color(250, 100, 100);
        } elseif ($metrics[0] - end($metrics) < 0) {
            $sparkline->color(100, 250, 100);
        }

        return $sparkline->render()->response('png');
    }
}

web.php

Route::get('/currencies/{currency}/sparkline.png', [SparklineController::class, 'index'])->name('currencies.sparkline');


Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.



License

Distributed under the MIT License. See LICENSE for more information.



Contact

Abbas mkhzomi - Telegram@abbaudox - amkhzomi@gmail.com

Project Link: https://github.com/abbaudo/laravel-sparkline

统计信息

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

GitHub 信息

  • Stars: 8
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固