fcharts 0.0.9

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 93

fcharts

Build Status Pub Status

A work-in-progress chart library for Flutter. Until version 1.0.0 the API is subject to change drastically. Needless to say, fcharts is not production ready.

The goal of this project is to allow for creating beautiful, responsive charts using a simple and intuitive API.

Inspired by Mikkel Ravn's tutorial on Flutter widgets and animations. If you have used Recharts (ReactJS library) you will find the high level API to be somewhat familiar.

Demo

Bar chart demo Touch demo

Example Usage

class SimpleLineChart extends StatelessWidget {
  // X value -> Y value
  static const myData = [
    ["A", "✔"],
    ["B", "❓"],
    ["C", "✖"],
    ["D", "❓"],
    ["E", "✖"],
    ["F", "✖"],
    ["G", "✔"],
  ];
  
  @override
  Widget build(BuildContext context) {
    return new LineChart(
      lines: [
        new Line<List<String>, String, String>(
          data: myData,
          xFn: (datum) => datum[0],
          yFn: (datum) => datum[1],
        ),
      ],
      chartPadding: new EdgeInsets.fromLTRB(30.0, 10.0, 10.0, 30.0),
    );
  }
}

The above code creates:

line chart

0.0.8

  • Added more examples
  • Wrapped up automatic span calculation

0.0.7

  • New API for creating a line chart widget

0.0.5 - 0.0.6

  • Begin adding tests
  • dartfmt

0.0.2 - 0.0.4

Just dependency, documentation, and format fixes.

0.0.1

Started the project!

  • Chart, a widget for creating a viewable chart from meaningful params
  • ChartData for creating a drawable
  • ChartDrawable for drawing directly to a canvas

example/lib/main.dart

import 'package:fcharts/fcharts.dart';
import 'package:fcharts_example/bar/simple.dart';
import 'package:fcharts_example/line/cities.dart';
import 'package:fcharts_example/line/simple.dart';
import 'package:fcharts_example/line/sparkline.dart';
import 'package:flutter/material.dart';

void main() => runApp(new FChartsExampleApp());

class ChartExample {
  ChartExample(
    this.name,
    this.widget,
    this.description,
  );

  final String name;
  final Widget widget;
  final String description;
}

final charts = [
  new ChartExample(
    'Simple Line Chart',
    new SimpleLineChart(),
    'Strings on the X-Axis and their index in the list on the Y-Axis.',
  ),
  new ChartExample(
    'City Coolness & Size Line Chart',
    new CityLineChart(),
    'Cities on the X-Axis with coolness & size on the Y-Axis with painted lines.',
  ),
  new ChartExample(
    'Random Sparkline Chart',
    new SparklineChart(),
    'Just a list of doubles was provided to the constructor.',
  ),
  new ChartExample(
    'Simple Bar Chart',
    new SimpleBarChart(),
    'Bar charts are not quite ready yet.',
  ),
];

class FChartsExampleApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<FChartsExampleApp> {
  var _chartIndex = 0;

  @override
  Widget build(BuildContext context) {
    final chart = charts[_chartIndex % charts.length];

    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Example: ${chart.name}'),
        ),
        body: new Container(
          decoration: new BoxDecoration(
            color: Colors.white,
          ),
          child: new Column(
            children: [
              new Padding(
                padding: new EdgeInsets.all(30.0),
                child: new Text(
                  chart.description,
                  textAlign: TextAlign.center,
                ),
              ),
              new Padding(
                  padding: new EdgeInsets.all(20.0),
                  child: new Container(
                    child: chart.widget,
                  )),
            ],
          ),
        ),
        floatingActionButton: new FloatingActionButton(
          onPressed: () {
            setState(() => _chartIndex++);
          },
          child: new Icon(Icons.refresh),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  fcharts: ^0.0.9

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:fcharts/fcharts.dart';
  
Version Uploaded Documentation Archive
0.0.9 May 5, 2018 Go to the documentation of fcharts 0.0.9 Download fcharts 0.0.9 archive
0.0.8 Apr 24, 2018 Go to the documentation of fcharts 0.0.8 Download fcharts 0.0.8 archive
0.0.7 Apr 24, 2018 Go to the documentation of fcharts 0.0.7 Download fcharts 0.0.7 archive
0.0.6 Apr 13, 2018 Go to the documentation of fcharts 0.0.6 Download fcharts 0.0.6 archive
0.0.5 Apr 2, 2018 Go to the documentation of fcharts 0.0.5 Download fcharts 0.0.5 archive
0.0.4 Mar 23, 2018 Go to the documentation of fcharts 0.0.4 Download fcharts 0.0.4 archive
0.0.3 Mar 23, 2018 Go to the documentation of fcharts 0.0.3 Download fcharts 0.0.3 archive
0.0.2 Mar 23, 2018 Go to the documentation of fcharts 0.0.2 Download fcharts 0.0.2 archive
0.0.1 Mar 23, 2018 Go to the documentation of fcharts 0.0.1 Download fcharts 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8
  • Flutter: 0.5.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Fix lib/src/widgets/bar_chart.dart.

Analysis of lib/src/widgets/bar_chart.dart reported 4 hints:

line 4 col 8: Unused import: 'package:fcharts/src/decor/axis.dart'.

line 5 col 8: Unused import: 'package:fcharts/src/decor/decor.dart'.

line 6 col 8: Unused import: 'package:fcharts/src/utils/chart_position.dart'.

line 13 col 8: Unused import: 'dart:math'.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
collection ^1.14.5 1.14.6 1.14.11
flutter 0.0.0
meta ^1.1.2 1.1.5 1.1.6
Transitive dependencies
sky_engine 0.0.99
typed_data 1.1.5 1.1.6
vector_math 2.0.6 2.0.8
Dev dependencies
flutter_test
test >=0.12.20 <0.13.0