draw_graph 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new63

Draw Graph #

A dart package to draw line graphs in your flutter app.

Usage #

  • Getting graph widget:

    LineGraph Widget #

    Properties

    • features: List

      A list of features to be shown in the graph. Detailed description of Feature class below. (required)

    • size: Size

      This will determine the size of your graph. Height will be size.height - 50 in case when description is showed. (required)

    • labelX: List<String>

      A list of X-Axis Labels. This will determine and number of cells to distribute your data in and the width of your cells.

    • labelY: List<String>

      A list of Y-Axis Labels. The labels will be distributed on Y-Axis and determine height on cells.

    • fontFamily: String

      The fontFamily to use for labels and description of features.

    • graphColor: Color

      The color of your axis and labels.

    • showDescription: bool

      Whether to show description at the end of graph.

    Constructor

    LineGraphPainter({
      @required List<feature> features, 
      @required Size size,
      List<String> labelX: [],
      List<String> labelY: [],
      String fontFamily: 'sans serif',
      Color graphColor: Colors.grey
      bool showDescription: false
    });
    

    Example

    LineGraph({
      features: features,
      size: Size(500, 400),
      labelX: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'],
      labelY: ['20%', '40%', '60%', '80%', '100%'],
      showDescription: true,
      graphColor: Colors.white30,
    })
    
  • Creating a list of Features

    • import the Feature model import 'package:draw_graph/models/feature.dart';

    Feature Model #

    Properties

    • data: List<double>

      The Y-Axis values to be plotted. Should be in the range [0-1]. The length of the list should be equal to X-Axis labels. (required)

    • title: String

      The title displayed in Feature Description below the graph

    • color: Color

      The color of graph for this feature

    Constructor

    Feature({
      @required List<double> data,
      String title: '',
      Color color: Colors.black,
    });
    

    Example

    List<Feature> features = [
      Feature(
        title: "Drink Water",
        color: Colors.blue,
        data: [0.2, 0.8, 1, 0.7, 0.6],
      ),
      Feature(
        title: "Exercise",
        color: Colors.pink,
        data: [1, 0.8, 6, 0.7, 0.3, 8],
      ),
    ];
    

Getting Started #

See the example directory for a sample app using draw_graph.

[0.0.1] - 2020-06-26 #

  • A description for people who will use that package or version.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:draw_graph/draw_graph.dart';
import 'package:draw_graph/models/feature.dart';

final Color darkBlue = Color.fromARGB(255, 18, 32, 47);

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      home: Scaffold(
        appBar: AppBar(
          title: Text("DrawGraph Package"),
        ),
        body: MyScreen(),
      ),
    );
  }
}

class MyScreen extends StatelessWidget {
  final List<Feature> features = [
    Feature(
      title: "Drink Water",
      color: Colors.blue,
      data: [0.2, 0.8, 0.4, 0.7, 0.6],
    ),
    Feature(
      title: "Exercise",
      color: Colors.pink,
      data: [1, 0.8, 0.6, 0.7, 0.3],
    ),
    Feature(
      title: "Study",
      color: Colors.cyan,
      data: [0.5, 0.4, 0.85, 0.4, 0.7],
    ),
    Feature(
      title: "Water Plants",
      color: Colors.green,
      data: [0.6, 0.2, 0, 0.1, 1],
    ),
    Feature(
      title: "Grocery Shopping",
      color: Colors.amber,
      data: [0.25, 1, 0.3, 0.8, 0.6],
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        Container(),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 64.0),
          child: Text(
            "Tasks Track",
            style: TextStyle(
              fontSize: 32,
              fontWeight: FontWeight.bold,
              letterSpacing: 2,
            ),
          ),
        ),
        LineGraph(
          features: features,
          size: Size(500, 400),
          labelX: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5'],
          labelY: ['20%', '40%', '60%', '80%', '100%'],
          showDescription: true,
          graphColor: Colors.white30,
        ),
        SizedBox(
          height: 50,
        )
      ],
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  draw_graph: ^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:draw_graph/draw_graph.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • draw_graph that is a package requiring null.

Maintenance suggestions

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.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test