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

stacked_bar_chart 封面
插件详情v1.1.0+2

stacked_bar_chart

一个 Flutter 库,用于绘制可滚动且可根据开发者需求自定义的图表。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
16
喜欢数
38
Pub 分数
130

安装插件

flutter pub add stacked_bar_chart

插件介绍

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

一个用于创建可自定义的可滚动堆叠条形图的 Flutter 库。专为需要灵活可视化工具的开发者设计,支持在 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台上动态渲染数据。该包提供直观的数据表示方式,具有平滑滚动和丰富的样式选项,可满足应用设计需求。非常适合仪表板、分析和报告界面,其中层叠数据对比至关重要。

适合场景

  • 数据仪表板
  • 分析报告
  • 财务趋势可视化
  • 教育类应用
  • 库存跟踪
  • 性能监控

主要特点

  • 可滚动图表
  • 可自定义的颜色和样式
  • 多层条形图可视化
  • 响应式设计
  • 平台无关支持
  • 动态数据更新

适合对象

  • 开发数据密集型应用的开发者
  • 需要交互式图表的UI设计师
  • 致力于跨平台项目的团队
  • 以分析为重点的应用程序
  • 实时数据可视化

使用建议

  • 需要了解图表数据结构
  • 复杂交互可能需要额外的状态管理
  • 使用超大数据集时的性能影响
  • 有限的内置工具提示或注释
  • 自定义样式可能需要额外的代码

原始 README

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

stacked_bar_chart

A Flutter package for creating different types of charts.This package gives developer the flexibility to customize their graph as well.

img

Features

  1. Plot graphs

    • Stacked Rounded Rectangle Graph
    • Stacked Rectangele Graph
    • Net Line Graph
    • Net Point Graph
  2. Customize your graph

    • Select if you want to display the net line
    • change core color,line color as well as line width of the net line
  3. Scrollable

    • The graphs plotted are scrollable
  4. Provide data in json format

    • You can use the toMap() and forMap() methods to provide your data in json format
  5. Style your Labels

    • You can style both you X-axis and Y-axis Labels.
  6. Callback on bar tap

    • A callback is provided on tap of each bar. Developer can use this feature as per their need.

Installation

In the dependencies: section of your pubspec.yaml, add the following line:

stacked_bar_chart:

Then import it as :

import 'package:stacked_bar_chart/stacked_bar_chart.dart';

Graph Types

1. Stacked Rounded Rectangle Graph

  • A simple stacked bar graph with rounded borders.

img

  • To plot this graph pass the GraphType.StackedRounded in graphType. as shown below
graphType: GraphType.StackedRounded

You can also change the styling of the line and point plotted.The color,width etc. can be changed using the netLine parameter as :

netLine: NetLine(
                showPointOnly: false,
                showLine: true,
                lineColor: Colors.blue,
                pointBorderColor: Colors.black,
                coreColor: Colors.white,
              ),

img img img

2. Stacked Rectangle Graph

  • A simple stacked bar graph with no rounded borders. You can customize it in the same way as the stacked rounded rectangle graph.

  • To plot this graph pass the GraphType.StackedRect in graphType. as shown below

graphType: GraphType.StackedRect

img img img

3. Net Line Graph

  • A simple line graph plotted with the net values of the data provided. The net values of a particular data is calculated and plotted.It can also be customized in the same way as stacked rounded rectangle graph.

  • To plot this graph pass the GraphType.StackedRect in graphType. as shown below

graphType: GraphType.LineGraph

img

4. Net Point Graph

  • A simple plot of the net values of the data.You can customize the point core and it's outer border using the netPoint parameter.

  • To plot this graph pass the GraphType.StackedRect in graphType. and then pass parameters in netLine to remove the line as shown below

graphType: GraphType.LineGraph
netLine: NetLine(
                showPointOnly: true,
                showLine: false,
                lineColor: Colors.blue,
                pointBorderColor: Colors.black,
                coreColor: Colors.white,
              ),

img

USAGE

class StackedBarGraph extends StatefulWidget {
  StackedBarGraph({Key key}) : super(key: key);

  @override
  _StackedBarGraphState createState() => _StackedBarGraphState();
}

class _StackedBarGraphState extends State<StackedBarGraph> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Stacked Rounded Rectangle Graph"),
      ),
      body: Column(
        children: [
          SizedBox(
            height: 50,
          ),
          Graph(
            yLabelConfiguration: YLabelConfiguration(
              yLabelStyle: TextStyle(
                color: Colors.grey,
                fontSize: 11,
              ),
              interval: 500,
              labelCount: 5,
              yLabelMapper: (num value) {
                return NumberFormat.compactCurrency(
                        locale: "en", decimalDigits: 0, symbol: "\$")
                    .format(value);
              },
            ),
            xLabelConfiguration: XLabelConfiguration(
              xLabelStyle: TextStyle(
                color: Colors.grey,
                fontSize: 11,
              ),
              xLabelMapper: (DateTime date) {
                return DateFormat("MMM yyyy").format(date);
              },
            ),
            netLine: NetLine(
              showLine: true,
              lineColor: Colors.black,
              pointBorderColor: Colors.black,
              coreColor: Colors.yellow,
            ),
            graphType: GraphType.StackedRounded,
            data: GraphData(
              backgroundColor: Colors.white,
              name: "ThePension",
              bars: [
                GraphBar(
                  month: DateTime(2020, 01),
                  sections: [
                    GraphBarSection(value: 200, color: Colors.pink),
                    GraphBarSection(value: 900, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -700, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 2),
                  sections: [
                    GraphBarSection(value: 300, color: Colors.pink),
                    GraphBarSection(value: 700, color: Colors.blue),
                    GraphBarSection(value: -400, color: Colors.amber),
                    GraphBarSection(value: -600, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 3),
                  sections: [
                    GraphBarSection(value: 400, color: Colors.pink),
                    GraphBarSection(value: 700, color: Colors.blue),
                    GraphBarSection(value: -100, color: Colors.amber),
                    GraphBarSection(value: -900, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 4),
                  sections: [
                    GraphBarSection(value: 400, color: Colors.pink),
                    GraphBarSection(value: 0, color: Colors.blue),
                    GraphBarSection(value: -800, color: Colors.amber),
                    GraphBarSection(value: -400, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 5),
                  sections: [
                    GraphBarSection(value: 700, color: Colors.pink),
                    GraphBarSection(value: 900, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -100, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 6),
                  sections: [
                    GraphBarSection(value: 900, color: Colors.pink),
                    GraphBarSection(value: 900, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -100, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 7),
                  sections: [
                    GraphBarSection(value: 300, color: Colors.pink),
                    GraphBarSection(value: 800, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -1100, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 8),
                  sections: [
                    GraphBarSection(value: 250, color: Colors.pink),
                    GraphBarSection(value: 980, color: Colors.blue),
                    GraphBarSection(value: -210, color: Colors.amber),
                    GraphBarSection(value: -720, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 9),
                  sections: [
                    GraphBarSection(value: 300, color: Colors.pink),
                    GraphBarSection(value: 200, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -400, color: Colors.purple),
                  ],
                ),
                GraphBar(
                  month: DateTime(2020, 10),
                  sections: [
                    GraphBarSection(value: 200, color: Colors.pink),
                    GraphBarSection(value: 900, color: Colors.blue),
                    GraphBarSection(value: -200, color: Colors.amber),
                    GraphBarSection(value: -700, color: Colors.purple),
                  ],
                ),
              ],
            ),
            onBarTapped: (GraphBar bar) {
              print(bar.month);
            },
          ),
        ],
      ),
    );
  }
}

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。