패키지, 저장소 및 앱 카테고리 검색

chart_sparkline 표지
패키지 상세v1.1.2

chart_sparkline

Flutter용 아름다운 스파크라인 차트. 평균선, 최고값 및 최저값.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
7.5천
좋아요
135
Pub 점수
150

패키지 설치

flutter pub add chart_sparkline

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Chart Sparkline은 컴팩트하고 시각적으로 매력적인 스파크라인 차트를 생성할 수 있는 Flutter 패키지입니다. 평균선과 최대값 및 최소값을 강조하는 기능을 통해 작은 공간에 트렌드를 표시합니다. 대시보드와 데이터 요약에 적합하며, Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원합니다. 가볍고 기존의 Flutter 앱에 원활하게 통합될 수 있으며, 깔끔한 디자인으로 사용자를 과부하시키지 않고 데이터 가독성을 향상시킵니다.

사용 사례

  • 대시보드 위젯
  • 실시간 데이터 추적
  • 성능 추세 시각화
  • 압축된 데이터 요약
  • 재무 지표 표시

주요 기능

  • 평균선 시각화
  • 최대 및 최소 값 강조 표시
  • 미니멀리스트 디자인
  • 크로스 플랫폼 지원
  • Flutter와의 간편한 통합
  • 스무스 렌더링

적합한 대상

  • 데이터 대시보드
  • 모바일 및 웹 애플리케이션
  • 분석 인터페이스
  • 재정 및 건강 추적 앱
  • 작은 차트가 필요한 UI

고려 사항

  • 작은 데이터 세트에 가장 적합
  • 제한된 상호작용
  • 툴팁 또는 레이블 없음
  • 수동 데이터 형식 지정이 필요합니다
  • 복잡한 차트 유형에 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

pub package

chart_sparkline

Beautiful sparkline charts for Flutter.

screenshot

Online Demo

Online Demo

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:chart_sparkline/chart_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(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: Container(
            width: 300.0,
            height: 100.0,
            child: Sparkline(
              data: data,
            ),
          ),
        ),
      ),
    ),
  );
}

base example screenshot

Customization

Sparkline
Property Default
lineWidth 2.0
lineColor Colors.lightBlue
lineGradient null

Example:

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

lineopts example screenshot

Sparkline(
  data: data,
  lineWidth: 10.0,
  lineGradient: 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]
pointIndex null
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.
atIndex Draw one point at the index specified by pointIndex.

Example:

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

all points example screenshot

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

last point example screenshot

Sparkline(
  data: data,
  pointsMode: PointsMode.atIndex,
  pointIndex: 7,
  pointSize: 8.0,
  pointColor: Colors.amber,
);

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:

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

fill below example screenshot

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

fill above example screenshot

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

fill above example screenshot

Smoothing
Sparkline(
  data: data,
  useCubicSmoothing: true,
  cubicSmoothingFactor: 0.2,
),

cubic smoothing example screenshot

Average Line
Sparkline(
  data: data,
  averageLine: true,
  averageLabel: true,
),

cubic smoothing example screenshot

first, last, highest and the lowest
Sparkline(
  data: data,
  kLine: ['max', 'min', 'first', 'last'],
),

cubic smoothing example screenshot

Grid Line
Sparkline(
  gridLinelabelPrefix: '\$',
  gridLineLabelPrecision: 3,
  enableGridLines: true,
),

cubic smoothing example screenshot

Animation Line

Online Demo

AnimatedBuilder(
  animation: AnimationController(duration: const Duration(seconds: 1), vsync: this),
  builder: (context, child) => Sparkline(
    data: [0.0, 1.0, 1.5, 2.0, 0.0, 0.0, -0.5, -1.0, -0.5, 0.0, 0.0],
    animationController: _controller,
    pointsMode: PointsMode.all,
    pointSize: 8.0,
  ),
),

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
  • [x] animate drawing a single sparkline
  • [ ] gesture detector to select closest point to tap
  • [x] baseline
  • [x] different fill modes [above/below/none]
  • [x] fix edge points overflowing by offsetting by lineWidth
  • [x] better corner rounding
  • [x] axis labels
  • [x] gradient shader on line paint
  • [x] gradient shader on fill paint
  • [ ] multiple overlapping sparklines on a shared axis

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.