Coder Social home page Coder Social logo

jiamrui / flutter_echarts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from entronad/flutter_echarts

0.0 1.0 0.0 704 KB

A Flutter widget to use Echarts in a reactive way.

Home Page: https://pub.dev/packages/flutter_echarts

License: Other

Dart 99.75% Kotlin 0.04% Swift 0.03% Objective-C 0.01% Ruby 0.17%

flutter_echarts's Introduction

δΈ­ζ–‡

pub

A Flutter widget to use Echarts in a reactive way.

bar boxplot effectScatter funnel gague geo graph heatmap kline line liquid map parallel pie radar scatter wordCloud bar3D line3D sankey scatter3D surface3D themeRiver overlap

Features

Reactive Updating

The most exciting feature of Flutter widgets and React components is that the view could update reactively to the change of data. Thanks to Echarts' data driving architecture, flutter_echarts implemented a reactive way to connect chart with data. The chart will automatically re-render when the data in the option property changes.

Two Way Communication

The onMessage and extraScript properties provide a way to set event communication both from flutter to JavaScript or in controversy.

Configurable Extensions

Echarts has a lot of extensions . the extensions property allows you to inject the extension scripts as raw strings. In this way, you can copy these scripts to your source code, without concerning about the confusing assets dirs.

Installing

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_echarts: #latest version

Now in your Dart code, you can use:

import 'package:flutter_echarts/flutter_echarts.dart';  

Details see pub.dev .

Usage

The flutter_echarts itself is very simple to use, just like a common statelessWidget:

Details about the option is in the Echarts docs or Echarts examples

Container(
  child: Echarts(
  option: '''
    {
      xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
      },
      yAxis: {
        type: 'value'
      },
      series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'line'
      }]
    }
  ''',
  ),
  width: 300,
  height: 250,
)

For an ios app, you need to add this entry to your Info.plist' <dic> tag:

<key>io.flutter.embedded_views_preview</key>
<string>YES</string>

A full example is here: flutter_echarts_example .

Widget Properties

option

String

( required )

The JavaScript Echarts Option for the chart as a string. The echarts is mainly configured by this property. You could use jsonEncode() function in dart:convert to convert data in Dart object form:

source: ${jsonEncode(_data1)},

Because JavaScript don't have ''' , you can use this operator to reduce some escape operators for quotas:

Echarts(
  option: '''
  
    // option string
    
  ''',
),

extraScript

String

The JavaScript which will execute after the Echarts.init() and before any chart.setOption() . The widget has build a javascriptChennel named Messager, so you could use this identifier to send message from JavaScript to Flutter:

extraScript: '''
  chart.on('click', (params) => {
    if(params.componentType === 'series') {
  	  Messager.postMessage('anything');
    }
  });
''',

onMessage

void Function(String)

Function to handle the message sent by Messager.postMessage() in extraScript .

extensions

List<String>

List of strings that coyied from Echarts extensions, such as components, WebGL, languages, etc. You can download them here . Insert them as raw strings:

const liquidPlugin = r'''

  // copy from liquid.min.js

''';

captureAllGestures

bool

( default: false )

Whether the chart captures all gestures. Setting it ture is usefull when handling 3D rotation and data zoom bars. Note that will prevent containers like ListViews to act to gestures on the charts.

Blog

Reactive Echarts Flutter Widget

A performance optimization of Flutter WebView


If you have any suggestions or demands, please give an issue .

The gallery GIF is from chenjiandongx

flutter_echarts's People

Contributors

entronad avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.