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

high_chart 표지
패키지 상세v2.8.1

high_chart

High Charts (.JS) 기반의 차트 라이브러리로, 파이 차트, 선형 차트 등 고급 차트를 만들 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
281
좋아요
90
Pub 점수
160

패키지 설치

flutter pub add high_chart

패키지 개요

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

high_chart는 High Charts(JavaScript)의 강력한 시각화 기능을 Flutter 애플리케이션에 가져오는 Flutter/Dart 패키지입니다. 개발자들이 파이 차트, 라인 차트, 바 차트 등 고급이고 상호작용 가능한 차트를 여러 플랫폼에서 생성할 수 있게 해줍니다. 성능과 사용자 정의를 중시하여 Android, iOS, Web, macOS, Windows, Linux를 지원합니다. High Charts에 익숙한 개발자에게 친숙한 API를 제공하여 풍부한 데이터 시각화를 앱에 쉽게 통합할 수 있습니다. 대시보드, 분석 인터페이스 및 동적이고 반응형 차트가 필요한 모든 앱에 적합합니다.

사용 사례

  • 데이터 대시보드
  • 분석 인터페이스
  • 재무 보고
  • 인터랙티브 UI
  • 교육 앱

주요 기능

  • 여러 차트 유형을 지원합니다
  • 크로스 플랫폼 호환성
  • 매우 사용자 정의 가능
  • 반응형 디자인
  • 기존 코드와의 간편한 통합
  • 실시간 데이터 업데이트

적합한 대상

  • High Charts에 익숙한 개발자
  • 풍부한 데이터 시각화가 필요한 앱
  • 대시보드 및 보고 도구
  • 웹 및 모바일 하이브리드 프로젝트
  • 다양한 플랫폼 간 일관된 UI를 우선시하는 팀

고려 사항

  • High Charts 개념을 이해해야 합니다
  • JS 종속성으로 인해 번들 크기가 더 클 수 있습니다
  • 제한된 네이티브 플러터 위젯 통합
  • 간단한 정적 시각화보다는 복잡하고 상호작용 가능한 차트에 가장 적합합니다
  • 매우 큰 데이터 세트와 함께 가능한 성능 영향

원본 README

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

High Chart logo

pub package pub points pub likes build license

High Chart for Flutter

A Flutter wrapper around Highcharts (.JS) for building rich, interactive charts — line, column, pie, area, combination charts, and more — with a single, consistent API.

Supports Android, iOS, Web, Windows, and macOS. Linux is declared as a plugin platform but not yet actually implemented — see Platform support.

Features

  • 🎯 Full access to the Highcharts JS API via a simple JSON/JS configuration string, or a fully typed, IDE-autocompleted HCOptions API generated from Highcharts' own TypeScript definitions
  • 🌐 Works everywhere Flutter runs — mobile, desktop, and web from the same codebase
  • 🌗 Built-in light, dark, and system theme support
  • 📦 Load Highcharts scripts from the network or bundle them locally as assets
  • ⚙️ Global Highcharts configuration via Highcharts.setOptions() (e.g. lang)
  • 📡 Two-way communication: chart events (selection, click, zoom, …) can call back into Flutter
  • 💾 Native chart export to PNG/JPEG/SVG — saved straight to disk on Android, iOS, macOS, and Windows, no manual download plumbing
  • 🔗 External links inside charts open in the system browser instead of hijacking the in-app WebView

Installation

Add high_chart to your pubspec.yaml:

dependencies:
  high_chart: ^2.8.1

Then fetch the package:

flutter pub get

Usage

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

class ExampleChart extends StatelessWidget {
  const ExampleChart({super.key});

  final String _chartData = '''{
    title: { text: 'Monthly Sales' },
    xAxis: {
      categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May']
    },
    series: [{
      type: 'column',
      name: 'Revenue',
      data: [3, 2, 1, 3, 3]
    }]
  }''';

  @override
  Widget build(BuildContext context) {
    return HighCharts(
      size: const Size(400, 300),
      data: _chartData,
      networkScripts: const [
        'https://code.highcharts.com/highcharts.js',
      ],
    );
  }
}

The data string is standard Highcharts configuration — see the Highcharts API reference for every option available (series types, axes, tooltips, legends, exporting, and more).

Typed options (HCOptions)

As an alternative to hand-writing a data string, pass options — a fully typed, IDE-autocompleted configuration tree generated from Highcharts' own TypeScript definitions (HCOptions, HCChartOptions, HCSeriesLineOptions, HCTitleOptions, and ~4,900 more, one per Highcharts option group):

import 'package:high_chart/high_chart.dart';

HighCharts(
  size: const Size(400, 300),
  options: HCOptions(
    title: HCTitleOptions(text: 'Monthly Sales'),
    xAxis: HCXAxisOptions(
      categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    ),
    series: [
      HCSeriesColumnOptions(name: 'Revenue', data: [3, 2, 1, 3, 3]),
    ],
  ),
  networkScripts: const ['https://code.highcharts.com/highcharts.js'],
)

data and options are mutually exclusive — provide exactly one. Every field is optional and only set fields are sent to the chart, so there's no need to fill in an entire options tree just to change one value.

A few things worth knowing:

  • Callbacks/formatters aren't in the typed API. A JS function can't be represented in a JSON payload sent from Dart, so properties like tooltip.formatter don't have a typed field. Use data for charts that need them, or combine both — see below.
  • series (and a few similarly "any one of ~100 shapes" properties) is dynamic. Highcharts' series type is a union of one interface per series type, which Dart can't model as a single field type. The typed series classes (HCSeriesLineOptions, HCSeriesPieOptions, …) still exist and are still fully typed — just put them in the list directly: series: [HCSeriesLineOptions(...), HCSeriesPieOptions(...)].
  • Raw maps still work inside typed options. Any dynamic slot (like series) also accepts a plain Map/List/primitive — useful for the rare option the generator skipped, or for gradually migrating a data string over: series: [{'type': 'line', 'data': [1, 2, 3]}] serializes exactly as if you'd written it in a data string.

See tool/generate_options/README.md for how the typed API is generated and how to regenerate it against a newer Highcharts release.

Loading scripts

Highcharts JS can be loaded either from a CDN or bundled with your app:

HighCharts(
  size: const Size(400, 300),
  data: _chartData,
  // From the network
  networkScripts: const [
    'https://code.highcharts.com/highcharts.js',
    'https://code.highcharts.com/modules/exporting.js',
  ],
  // Or bundled as local assets (declared in pubspec.yaml)
  localScripts: const [
    'res/highcharts.js',
    'res/exporting.js',
  ],
)

Web platform: Highcharts scripts must additionally be included directly in web/index.html.

Exporting charts (PNG/JPEG/SVG)

Load exporting.js and offline-exporting.js together:

networkScripts: const [
  'https://code.highcharts.com/highcharts.js',
  'https://code.highcharts.com/modules/exporting.js',
  'https://code.highcharts.com/modules/offline-exporting.js',
],

Without offline-exporting.js, the export menu sends the chart to Highcharts' cloud server and expects the response back as a browser file download. offline-exporting.js renders the file entirely client-side as a data: URI instead, removing that network round-trip.

On Android, iOS, macOS, and Windows, the plugin intercepts that client-side download and saves the file natively — to the platform's real Downloads folder where one exists (desktop), falling back to the app's own storage elsewhere (iOS Documents; Android app-specific external storage, not the public Downloads folder — reaching that on Android needs MediaStore, which this plugin doesn't yet do). Web downloads the usual browser way and needs no special handling.

macOS App Sandbox: a sandboxed macOS app (the default for flutter create) can't write to ~/Downloads at all until it declares that entitlement. Add to both macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements:

<key>com.apple.security.files.downloads.read-write</key>
<true/>

Without it, the save fails with a PathAccessException (Operation not permitted) and is reported via onEvent as {event: 'export', status: 'error', ...} rather than crashing.

Pass onEvent to be notified when a save finishes:

HighCharts(
  size: const Size(400, 300),
  data: _chartData,
  networkScripts: const [
    'https://code.highcharts.com/highcharts.js',
    'https://code.highcharts.com/modules/exporting.js',
    'https://code.highcharts.com/modules/offline-exporting.js',
  ],
  onEvent: (event) {
    if (event is Map && event['event'] == 'export') {
      if (event['status'] == 'success') {
        print('Saved to ${event['path']}');
      } else {
        print('Export failed: ${event['message']}');
      }
    }
  },
)
Theming
HighCharts(
  size: const Size(400, 300),
  data: _chartData,
  networkScripts: const ['https://code.highcharts.com/highcharts.js'],
  themeMode: ThemeMode.dark, // ThemeMode.system, ThemeMode.light, ThemeMode.dark
)
Custom loader
HighCharts(
  size: const Size(400, 300),
  data: _chartData,
  networkScripts: const ['https://code.highcharts.com/highcharts.js'],
  loader: const SizedBox(
    width: 200,
    child: LinearProgressIndicator(),
  ),
)
Global options

Settings that live outside a single chart's configuration — such as lang — are applied via Highcharts.setOptions() before the chart is created, using the globalOptions parameter:

HighCharts(
  size: const Size(400, 300),
  data: _chartData,
  networkScripts: const ['https://code.highcharts.com/highcharts.js'],
  globalOptions: '''{
    lang: { decimalPoint: ',', thousandsSep: '.' }
  }''',
)
Receiving events from the chart

Register an onEvent callback to receive data sent from the chart's JavaScript. Call the sendToFlutter(data) helper — injected into every chart automatically — from any Highcharts event handler in data:

HighCharts(
  size: const Size(400, 300),
  data: '''{
    chart: { zoomType: 'x' },
    xAxis: {
      events: {
        setExtremes: function (e) {
          if (typeof e.min === 'number' && typeof e.max === 'number') {
            sendToFlutter({ min: e.min, max: e.max });
          }
        }
      }
    },
    series: [{ data: [1, 4, 3, 5, 2, 6] }]
  }''',
  networkScripts: const ['https://code.highcharts.com/highcharts.js'],
  onEvent: (event) {
    // event is the JSON-decoded payload passed to sendToFlutter(),
    // e.g. {min: 1.2, max: 4.8}
    print('Selected range: $event');
  },
)

onEvent also delivers the plugin's own export-status reports (see Exporting charts above) as {event: 'export', status: ..., ...} — check for that shape first if you handle both.

Platform support

Android iOS Web Windows macOS Linux
✅ ✅ ✅ ✅ ✅ ❌

Linux is registered as a plugin platform (pubspec.yaml declares it, and there's a native stub under linux/), but there's no actual chart-rendering implementation behind it yet — a HighCharts widget on Linux currently renders an "Unsupported Platform" placeholder. Contributions welcome; it'd need a Linux-capable WebView (e.g. via a CEF-based package) wired up the same way lib/src/mobile/ and lib/src/windows/ are.

Example

A complete, runnable example gallery is available in the example/ directory, demonstrating multiple chart types, theme switching, globalOptions, onEvent, and the typed HCOptions API.

Documentation

For a deeper dive into configuration and advanced usage, see the project wiki.

Contributing

Issues and pull requests are welcome on GitHub. Please check the changelog before reporting a bug that may already be fixed.

License

This project is licensed under the terms of the LICENSE file included in this repository.

카테고리

의존성

의존성 목록 6 개

소스 저장소

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

아직 데이터가 없습니다.