搜尋套件、儲存庫與 APP 分類

套件詳情v0.1.0

flutter_sparkline

適用於 Flutter 的精美折線圖。

近 30 天下載
426
喜歡數
72
Pub 分數
30

安裝套件

flutter pub add flutter_sparkline

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter Sparkline 是一個輕量級套件,用於在 Flutter 應用中渲染緊湊且視覺上吸引人的微型圖表。它讓開發者能夠直接在文字或 UI 元素中顯示小型、簡單的折線圖,非常適合在有限空間內展示隨時間變化的趨勢。該套件支援自訂顏色、線條寬度和資料點樣式,適用於儀表板、報告和分析介面。憑藉乾淨的 API 和高效能,它可無縫整合到現有的 Flutter 專案中。

適用情境

  • 在儀表板中顯示趨勢數據
  • 在表格中可視化指標
  • 增強應用分析使用者介面
  • 以緊湊形式顯示歷史數據
  • 在清單項目中整合微型圖表

主要特色

  • 極簡主義,高影響力視覺化
  • 可自定的線條顏色和寬度
  • 平滑曲線渲染
  • 支援動態資料更新
  • 輕量且快速的效能

適合對象

  • 受限空間中的數據可視化
  • 移動應用分析
  • 即時指標顯示
  • 需要微妙趨勢指示器的UI
  • 尋求簡單圖表功能而無需複雜性的開發者

使用建議

  • 僅限基於行的 sparklines
  • 無互動功能,例如工具提示
  • 不適合大型數據集
  • 需要手動處理資料縮放
  • 最佳搭配小型、離散的資料系列使用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

pub package

flutter_sparkline

Beautiful sparkline charts for Flutter.

screenshot

Installation

Install the latest version from pub.

Quick Start

Import the package, create a Sparkline, and pass it your data.

import 'package:flutter/material.dart';
import 'package:flutter_sparkline/flutter_sparkline.dart';

void main() {
  var data = [0.0, 1.0, 1.5, 2.0, 0.0, 0.0, -0.5, -1.0, -0.5, 0.0, 0.0];
  runApp(
    new MaterialApp(
      home: new Scaffold(
        body: new Center(
          child: new Container(
            width: 300.0,
            height: 100.0,
            child: new Sparkline(
              data: data,
            ),
          ),
        ),
      ),
    ),
  );
}

base example screenshot

Customization

Sparkline
Property Default
lineWidth 2.0
lineColor Colors.lightBlue
lineGradient null

Example:

new Sparkline(
  data: data,
  lineWidth: 5.0,
  lineColor: Colors.purple,
);

lineopts example screenshot

new Sparkline(
  data: data,
  lineWidth: 10.0,
  lineGradient: new LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: [Colors.purple[800], Colors.purple[200]],
  ),
);

lineopts example screenshot


Points
Property Default
pointsMode PointsMode.none
pointSize 4.0
pointColor Colors.lightBlue[800]
PointsMode Description
none (default) Do not draw individual points.
all Draw all the points in the data set.
last Draw only the last point in the data set.

Example:

new Sparkline(
  data: data,
  pointsMode: PointsMode.all,
  pointSize: 8.0,
  pointColor: Colors.amber,
);

all points example screenshot

new Sparkline(
  data: data,
  pointsMode: PointsMode.last,
  pointSize: 8.0,
  pointColor: Colors.amber,
);

last point example screenshot


Fill
Property Default
fillMode FillMode.none
fillColor Colors.lightBlue[200]
fillGradient null
FillMode Description
none (default) Do not fill, draw only the sparkline.
above Fill the area above the sparkline.
below Fill the area below the sparkline.

Example:

new Sparkline(
  data: data,
  fillMode: FillMode.below,
  fillColor: Colors.red[200],
);

fill below example screenshot

new Sparkline(
  data: data,
  fillMode: FillMode.above,
  fillColor: Colors.red[200],
);

fill above example screenshot

new Sparkline(
  data: data,
  fillMode: FillMode.below,
  fillGradient: new LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: [Colors.red[800], Colors.red[200]],
  ),
);

fill above example screenshot


Todo:
  • [x] simple sparkline
  • [x] custom line width
  • [x] custom line color
  • [x] optional rounded corners
  • [x] fill
  • [x] embiggen individual points/change color
  • [x] different points modes [all/last/none]
  • [ ] animate between two sparklines
  • [ ] animate drawing a single sparkline
  • [ ] gesture detector to select closest point to tap
  • [ ] baseline
  • [x] different fill modes [above/below/none]
  • [x] fix edge points overflowing by offsetting by lineWidth
  • [ ] better corner rounding
  • [ ] axis labels
  • [x] gradient shader on line paint
  • [x] gradient shader on fill paint
  • [ ] multiple overlapping sparklines on a shared axis
  • [ ] tests

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。