承接 diagro/lib_php_chart 相关项目开发

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

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

diagro/lib_php_chart

最新稳定版本:1.3.2

Composer 安装命令:

composer require diagro/lib_php_chart

包简介

Library for creating ChartJS in PHP.

README 文档

README

PHP chart library Diagro library PHP chartjs

Description

Create charts with ChartJS through PHP. You make the chart in PHP code and serialize it to Javascript. In Javascript you create the chart by deserialize the output of the PHP Chart class.

The Manager class holds the graphs and is responsible for rendering.

$("canvas[id^='chart_']").each(function(idx, el) {
	new Chart(
		$(el).attr('id'), 
		$.parseJSON(atob($(el).data('chart')))
	);
});

If you use Laravel. Simply register the Manager class in the AppServiceProvider.

public function register()
{
	$this->app->singleton('charts', \Diagro\Chart\Manager::class);
}

In a blade view:

{{ app('charts')->render('chart_id') }}

Or register a stringable blade like:

Blade::stringable(\Diagro\Chart\Chart::class, function($chart) {
    return app('charts')->render($chart->id);
});

Example:

$chart = new Chart('messages_per_time', Chart::TYPE_BAR);
$chart->labels = array_keys($per_datetime);
$chart->datasets[0] = new \Diagro\Chart\Datasets\Bar('Aantal per tijdstip');
$chart->datasets[0]->data = array_values($per_datetime);
$chart->datasets[0]->background_color = [
	new \Diagro\Chart\Color\RGBA(255,99,132,0.2),
	new \Diagro\Chart\Color\RGBA(54,162,235,0.2)
];
$chart->datasets[0]->border_color = [
	new \Diagro\Chart\Color\RGBA(255,99,132,1),
	new \Diagro\Chart\Color\RGBA(54,162,235,1)
];
$chart->datasets[0]->border_width = 1;

$chart->options->plugins->legend->display = false;

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Diagro
  • 更新时间: 2022-09-09