搜索插件、代码仓与 APP 分类

fl_heatmap 封面
插件详情v0.4.6

fl_heatmap

一个用于 Flutter 应用的热力图小部件,具有多种样式选项。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3510
喜欢数
56
Pub 分数
160

安装插件

flutter pub add fl_heatmap

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

fl_heatmap 是一个 Flutter 包,提供可自定义的热力图小部件,用于可视化二维数据。它支持多种样式选项,包括颜色方案、单元格大小和标签自定义,非常适合展示数据集中的密度或频率模式。该小部件可无缝集成到跨平台的 Flutter 应用中,提供流畅的渲染和响应式行为。特别适用于分析仪表板、地理数据可视化以及时间序列热力图。该包注重性能,能够高效处理大型数据集,同时保持简洁直观的 API。

适合场景

  • 数据密度可视化
  • 分析仪表板
  • 地理空间数据表示
  • 时间序列热图
  • 用户活动跟踪

主要特点

  • 可自定义的颜色方案
  • 可配置的单元格大小
  • 对标签和工具提示的支持
  • 响应式设计
  • 大型数据集的高效渲染
  • 跨平台兼容性

适合对象

  • 开发数据可视化功能的开发者
  • 创建分析仪表板的团队
  • 需要在数据中进行模式识别的应用程序
  • 带有交互式图表的教育工具
  • 涉及空间或时间数据的项目

使用建议

  • 需要理解二维数据结构
  • 性能可能因数据量非常大而有所不同
  • 有限的内置交互功能,仅限于提示工具
  • 样式选项需要仔细配置才能获得最佳外观

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

fl_heatmap

A heatmap widget for Flutter apps.

heatmap electricity consumption

heatmap water consumption

Usage

1 - Depend on it

Add it to your package's pubspec.yaml file

dependencies:
  fl_heatmap: ^0.1.0
2 - Install it

Install packages from the command line

flutter packages get
3 - Use it

This is an example for the months of four years:

import 'package:fl_heatmap/fl_heatmap.dart';

class _ExampleState extends State<ExampleApp> {
  HeatmapItem? selectedItem;

  late HeatmapData heatmapData;

  @override
  void initState() {
    _initExampleData();
    super.initState();
  }

  void _initExampleData() {
    const rows = [
      '2022',
      '2021',
      '2020',
      '2019',
    ];
    const columns = [
      'Jan',
      'Feb',
      'Mär',
      'Apr',
      'Mai',
      'Jun',
      'Jul',
      'Aug',
      'Sep',
      'Okt',
      'Nov',
      'Dez',
    ];
    final r = Random();
    const String unit = 'kWh';
    heatmapData = HeatmapData(rows: rows, columns: columns, items: [
      for (int row = 0; row < rows.length; row++)
        for (int col = 0; col < columns.length; col++)
          HeatmapItem(
              value: r.nextDouble() * 6,
              unit: unit,
              xAxisLabel: columns[col],
              yAxisLabel: rows[row]),
    ]);
  }

  @override
  Widget build(BuildContext context) {
    final title = selectedItem != null
        ? '${selectedItem!.value.toStringAsFixed(2)} ${selectedItem!.unit}'
        : '--- ${heatmapData.items.first.unit}';
    final subtitle = selectedItem != null
        ? '${selectedItem!.xAxisLabel} ${selectedItem!.yAxisLabel}'
        : '---';
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Heatmap plugin example app'),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              const SizedBox(height: 16),
              Text(title, textScaleFactor: 1.4),
              Text(subtitle),
              const SizedBox(height: 8),
              Heatmap(
                  onItemSelectedListener: (HeatmapItem? selectedItem) {
                    debugPrint(
                        'Item ${selectedItem?.yAxisLabel}/${selectedItem?.xAxisLabel} with value ${selectedItem?.value} selected');
                    setState(() {
                      this.selectedItem = selectedItem;
                    });
                  },
                  rowsVisible: 5, // Only the first 5 rows are visible
                  heatmapData: heatmapData)
            ],
          ),
        ),
      ),
    );
  }
}

If necessary you can inherit from HeatmapItem and attach some payload, e.g. the electricity costs for the consumption:

class CustomHeatmapItem extends HeatmapItem {
  CustomHeatmapItem(
      {required this.costs,
      required double value,
      required String unit,
      required String xAxisLabel,
      required String yAxisLabel})
      : super(
            value: value,
            unit: unit,
            xAxisLabel: xAxisLabel,
            yAxisLabel: yAxisLabel);
  
  final double costs;
}

Features

  • Supporting custom color schemes with dynamic size or use predefined color palettes such as colorPaletteTemperature, colorPaletteRed, colorPaletteBlue.
  • x- and y-axis labels are completely dynamic
  • Do not show the x-axis/y-axis labels if necessary
  • Detect clicks on cells and get back the data item to show detailed information about the cell
  • Use different styles for the cells if necessary
  • Show only the first lines and user can request to show all

Apps using this plugin

EHW+ Your app?
EHW+ ...

所属分类

源码仓库

使用此插件的项目

暂无相关数据。