awesome_spiderchart 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new54

Spiderchart #

An awesome radar charts to make your app just awesome

Radar chart flutter example

Getting Started #

Creating a SpiderChart is that easy you can choose the color of the lines, radius of point. A SpiderChartValue is all the stats for the group you want to compare with your spider or radar graph.

SpiderChartWidget component = SpiderChartWidget(
  lineColor: Colors.blueGrey[500],
  activeLabelColor: Colors.blueGrey[50],
  nbSides: 7,
  labels: [
    SpiderChartStatModel(roundSize: 4, label: "test 1"),
    SpiderChartStatModel(roundSize: 4, label: "test 2"),
    SpiderChartStatModel(roundSize: 4, label: "test 3"),
    SpiderChartStatModel(roundSize: 4, label: "test 4"),
    SpiderChartStatModel(roundSize: 4, label: "test 5"),
    SpiderChartStatModel(roundSize: 4, label: "test 6"),
    SpiderChartStatModel(roundSize: 4, label: "test 7"),
  ],
  valuesList: new List()
    ..add(
      new SpiderChartValue(
        [ .5, .8, .9, .8, .9, .1, .2 ],
        gradient: gradient,
        strokeColor: Colors.lightGreenAccent[200]
      )
    ),
);

Enjoy

[0.0.1] - 02/06/2020 #

  • First version of the spider chart library

example/lib/main.dart

import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:awesome_spiderchart/chart_painter.dart';
import 'package:awesome_spiderchart/spiderchart.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Spider radar chart demo',
      theme: ThemeData(
        primarySwatch: Colors.blueGrey,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {

  AnimationController _controller, _labelTouchController, _bottomBarController;
  Animation<double> _scaleAnim;
  Animation<double> _scaleChart;
  Animation<double> _scaleLabelAnim;
  Animation<double> _scaleBottomBar;
  int _activeIndex = -1;

  final Gradient bgGradient = new LinearGradient(
    colors: <Color>[
      Colors.blueGrey[500],
      Colors.blueGrey[800],
    ],
    begin: Alignment(1.0, -1.0),
    end: Alignment(-1.0, 1.0),
  );

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this, duration: new Duration(milliseconds: 3000));
    _labelTouchController = AnimationController(vsync: this, duration: Duration(milliseconds: 1500));
    _bottomBarController = AnimationController(vsync: this, duration: Duration(milliseconds: 500));

    _scaleLabelAnim = new CurvedAnimation(parent: _labelTouchController, curve: Curves.ease);
    _scaleBottomBar = new CurvedAnimation(parent: _bottomBarController, curve: Curves.ease);
    _scaleAnim = new CurvedAnimation(parent: _controller, curve: Interval(0, .8, curve: Curves.elasticOut));
    _scaleChart = new CurvedAnimation(parent: _controller, curve: Interval(.7, 1, curve: Curves.easeInOutExpo));
    //_scaleLabelAnim.addListener(() => this.setState(() {}));

    Future.delayed(Duration(seconds: 1), () => _controller.forward());
  }

  @override
  Widget build(BuildContext context) {
    final Gradient gradient = new LinearGradient(
      colors: <Color>[
        Colors.lightGreenAccent[100].withOpacity(0.7),
        Colors.lightGreenAccent[700].withOpacity(0.7),
      ],
      begin: Alignment(1.0, -1.0),
      end: Alignment(-1.0, 1.0),
    );
    //---------------------------------------------------
    return Scaffold(
      appBar: AppBar(
        title: Text("Apparence.io - spider chart"),
      ),
      body: Container(
        decoration: BoxDecoration(
          gradient: bgGradient
//            color: Colors.blueGrey[800]
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Expanded(
              child: AnimatedBuilder(
                animation: _scaleAnim,
                builder: (context, child) =>
                  Transform.rotate(
                    angle: -2 * pi * _scaleAnim.value,
                    child: Transform.scale(
                      scale: _scaleAnim.value,
                      child: _buildSpiderChartWidget(gradient),
                    ),
                  ),
                child: _buildSpiderChartWidget(gradient),
              ),
            ),
            Flexible(
              child: Padding(
                padding: const EdgeInsets.only(top: 64.0),
                child: Text(""),
              ),
            )
          ],
        ),
      ),
      bottomSheet: _buildDetailsExpandableCard(context),
    );
  }

  _buildSpiderChartWidget(Gradient gradient) {
    return SpiderChartWidget(
      lineColor: Colors.blueGrey[500],
      activeLabelColor: Colors.blueGrey[50],
      nbSides: 5,
      labels: [
        SpiderChartStatModel(roundSize: 4, label: "test 1"),
        SpiderChartStatModel(roundSize: 4, label: "test 2"),
        SpiderChartStatModel(roundSize: 4, label: "test 3"),
        SpiderChartStatModel(roundSize: 4, label: "test 4"),
        SpiderChartStatModel(roundSize: 4, label: "test 5"),
      ],
      activeLabel: _activeIndex,
      onTap: (index) {
        setState(() {
          _activeIndex = index;
        });
        _bottomBarController.reverse()
          .then((_) => _bottomBarController.forward());
      },
      valuesList: new List()
        ..add(new SpiderChartValue(
          [
            .5 * _scaleChart.value,
            .8 * _scaleChart.value,
            .9 * _scaleChart.value,
            .8 * _scaleChart.value,
            .9 * _scaleChart.value,
            .4 * _scaleChart.value,
            .4 * _scaleChart.value,
            .6 * _scaleChart.value,
          ],
          gradient: gradient,
          strokeColor: Colors.lightGreenAccent[200])
        ),
    );
  }

  _buildDetailsExpandableCard(BuildContext context) {
    return AnimatedBuilder(
      animation: _scaleBottomBar,
      builder: (context, child) => Container(
        height: _scaleBottomBar.value * 220,
        decoration: BoxDecoration(
//          borderRadius: BorderRadius.vertical(top: Radius.circular(32)),
          color: Colors.blueGrey[200]
        ),
        child: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Flexible(
                child: Text("Lorem ipsum lorem ipsum",
                  style: TextStyle(
                    color: Colors.blueGrey[800],
                    fontWeight: FontWeight.bold,
                    fontSize: 21
                  ),
                ),
              ),
              Flexible(
                child: Text("Lorem ipsum lorem ipsum lorem ipsum lorem ipsum " +
                  "lorem ipsum lorem ipsum lorem ipsum lorem ipsum " +
                  "lorem ipsum lorem ipsum lorem ipsum lorem ipsum",
                  style: TextStyle(
                    color: Colors.blueGrey[800],
                    fontWeight: FontWeight.normal,
                    fontSize: 16
                  )
                ),
              ),
              Flexible(
                flex: 1,
                child: Padding(
                  padding: const EdgeInsets.only(top: 24.0),
                  child: Container(
                    decoration: BoxDecoration(
                      color: Colors.transparent,
                      border: Border.all(color: Colors.white, width: 1),
                      borderRadius: BorderRadius.all(Radius.circular(32))
                    ),
                    child: FlatButton(
                      onPressed: () => _bottomBarController.reverse(),
                      child: Text("Close", style: TextStyle(color: Colors.white),)
                    ),
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }


}

Use this package as a library

1. Depend on it

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


dependencies:
  awesome_spiderchart: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:awesome_spiderchart/chart_painter.dart';
import 'package:awesome_spiderchart/generated/i18n.dart';
import 'package:awesome_spiderchart/label_painter.dart';
import 'package:awesome_spiderchart/label_widget.dart';
import 'package:awesome_spiderchart/offset_extension.dart';
import 'package:awesome_spiderchart/pointer_widget.dart';
import 'package:awesome_spiderchart/spiderchart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
20
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Mar 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/chart_painter.dart. (-1 points)

Analysis of lib/chart_painter.dart reported 2 hints:

line 2 col 8: Unused import: 'dart:ui'.

line 3 col 8: Unused import: 'offset_extension.dart'.

Fix lib/label_painter.dart. (-0.50 points)

Analysis of lib/label_painter.dart reported 1 hint:

line 2 col 8: Unused import: 'dart:ui'.

Fix lib/label_widget.dart. (-0.50 points)

Analysis of lib/label_widget.dart reported 1 hint:

line 5 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: LabelWidget.index, LabelWidget.nbSides, LabelWidget.lineColor, LabelWidget.statModel

Fix additional 4 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/generated/i18n.dart (Run flutter format to format lib/generated/i18n.dart.)
  • lib/offset_extension.dart (Run flutter format to format lib/offset_extension.dart.)
  • lib/pointer_widget.dart (Run flutter format to format lib/pointer_widget.dart.)
  • lib/spiderchart.dart (Run flutter format to format lib/spiderchart.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
mockito ^4.1.1