blumilksoftware/heatmap
Composer 安装命令:
composer require blumilksoftware/heatmap
包简介
Heatmap library for PHP
README 文档
README
About
Making a heatmap from custom datasets should be extremely easy. We are here to help you with that.
What's a heatmap? It is a data visualization technique that shows magnitude of a phenomenon as color in two dimensions[1], and you can know it from GitHub user profile pages:
Installation
The Heatmap is distributed as Composer library via Packagist. To add it to your project, execute the following command:
composer require blumilksoftware/heatmap
Usage
You can use any set of data you want. By default, dates will be taken from "created_at" key of arrays or objects implementing \ArrayAccess interface. Builder accepts also objects implementing \Blumilk\HeatmapBuilder\Contracts\TimeGroupable contract with mandatory getTimeGroupableIndicator() method returning a string with proper date:
$data = [ ["created_at" => "2025-11-01 00:00:00", /** (...) */], ["created_at" => "2025-11-03 00:00:00", /** (...) */], ["created_at" => "2025-11-16 00:00:00", /** (...) */], ["created_at" => "2025-11-16 00:00:00", /** (...) */], ["created_at" => "2025-11-18 00:00:00", /** (...) */], ["created_at" => "2025-11-19 00:00:00", /** (...) */], ];
Then create an instance of \Blumilk\HeatmapBuilder\HeatmapBuilder. By default, it will be working on day-based periods for last week from the moment you are calling it:
$builder = new HeatmapBuilder(); $result = $builder->build($data);
Method build() returns array of tiles that can be serialized into JSON with simple json_encode() function or any other serializer:
[
{
"label": "2025-11-16",
"count": 2,
"description": ""
},
{
"label": "2025-11-17",
"count": 0,
"description": ""
},
{
"label": "2025-11-18",
"count": 1,
"description": ""
},
{
"label": "2025-11-19",
"count": 1,
"description": ""
},
{
"label": "2025-11-20",
"count": 0,
"description": ""
},
{
"label": "2025-11-21",
"count": 0,
"description": ""
},
{
"label": "2025-11-22",
"count": 0,
"description": ""
},
{
"label": "2025-11-23",
"count": 0,
"description": ""
}
]
Customizing the Heatmap Builder watching period
By default, the HeatmapBuilder automatically sets its observation period to the last seven days if no custom period ($period) is provided during instantiation. This default behavior ensures a rolling seven-day view from the current day.
If you need to specify a custom period (e.g., the entire month of January), you can achieve this by explicitly passing a CarbonPeriod instance to the builder, as shown in the example below:
// Define a custom period for the entire month of January 2025 $period = CarbonPeriod::create( Carbon::parse('2025-01-01'), '1 day', Carbon::parse('2025-01-31') ); // Instantiate the HeatmapBuilder with the custom period $builder = new HeatmapBuilder( now: Carbon::now(), periodInterval: PeriodInterval::Daily, period: $period // Include the custom period ); // Generate the heatmap data $result = $builder->build($data);
blumilksoftware/heatmap 适用场景与选型建议
blumilksoftware/heatmap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 165 次下载、GitHub Stars 达 4, 最近一次更新时间为 2024 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 blumilksoftware/heatmap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blumilksoftware/heatmap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 165
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-27
