flutter_charts 0.1.7

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

Table of Contents

Table of contents :TOC:<a id="sec-1" name="sec-1"></a>

  • Flutter Charts - How to include the flutter_charts library in your application (See section )
  • An example of Flutter Chart output (See section )
  • Known packages, libraries and apps that use this this flutter_charts package (See section )
  • Flutter Charts - an overview: data, options, classes (See section )
  • Experimenting with Flutter Charts: Using the included example app file:example/lib/main.dart (See section )
  • Flutter Charts - examples: LineChart and VerticalBarChart. Code and resulting charts (See section )
    • Random Data (Y values), Random X Labels, Random Colors, Random Data Rows Legends, Data-Generated Y Labels. (See section )
    • User-Provided Data (Y values), User-Provided X Labels, Random Colors, User-Provided Data Rows Legends, Data-Generated Y Labels, (See section )
    • User-Provided Data (Y values), User-Provided X Labels, Random Colors, User-Provided Data Rows Legends, User-Provided Y Labels (See section )
  • VerticalBar Chart - one more example, showing positive/negative stacks: (See section )
    • User-Provided Data (Y values), User-Provided X Labels, User-Provided Colors, User-Provided Data Rows Legends, User-Provided Y Labels (See section )
  • Bugs status (See section )
  • Future enhancements and work (See section )
  • Terminology and Selected Classes (See section )
  • Internal notes (See section )
    • Add ability to create a Table of Contents to README.org (See section )
    • Adding images to README.org (See section )
    • Pub - Publishing workflow on https://pub.dartlang.org (See section )

Flutter Charts - How to include the flutter_charts library in your application<a id="sec-2" name="sec-2"></a>

Flutter Charts is a charting library for Flutter, written in Flutter. Currently, column chart and line chart are supported.

The package is published on pub for inclusion in your application's pubspec.yaml: The Installing tab on https://pub.dartlang.org/packages/flutter_charts contains instructions on how to include the flutter_charts package in your application.

An example of Flutter Chart output<a id="sec-3" name="sec-3"></a>

There is one example application in flutter_charts: example/lib/main.dart. It shows how a Flutter Chart can be included in a Flutter application.

You can run the example application using one of the methods (6, 7) in the paragraph below.

This application is also used as a base to show several sample charts in the paragraphs below.

Vertical Bar Chart (Column Chart)

img

Point and Line Chart (Line Chart)

img

Output uses semi-random data. You can click the blue + button to rerun chart with a different dataset.

Known packages, libraries and apps that use this this flutter_charts package<a id="sec-4" name="sec-4"></a>

  1. Michael R. Fairhurst's Language reader app - see https://github.com/MichaelRFairhurst/flutter-language-reader-app

Flutter Charts - an overview: data, options, classes<a id="sec-5" name="sec-5"></a>

Before we show several examples of charts, a few notes.

  • The ChartData class: allows to define data - X labels, Y values, (optional) Y labels, each-dataRow (series) legends, each-dataRow (series) color. The list below provides a summary description of each item
    • X labels: ChartData.xLabels allow to define X labels. Setting xLabels is required, but client can set them to empty strings.
    • Y values: ChartData.dataRows allow to define Y values in rows. Assumption: size of each data row in ChartData.dataRows is the same, and each data row size == ChartData.xLabels.size
    • Y labels (optional): Normally, Y labels are generated from data. The option ChartOptions.useUserProvidedYLabels (default true), asks flutter_charts to data-generate Y labels. If this option is set to false, then ChartData.yLabels must be set. Any number of such user-provided Y labels is allowed.
    • Each-dataRow (each series) legends: ChartData.dataRowsLegends allow to define a legend for each data row in ChartData.dataRows. Assumption: ChartData.dataRows.size == ChartData.dataRowsLegends.size
    • Each-dataRow (each series) color: ChartData.dataRowsColors allow to define a color for each data row in ChartData.dataRows. Assumption: ChartData.dataRows.size == ChartData.dataRowsColors.size
  • The ChartOptions class: allows to define options, by using it's defaults, or setting some options to non default values. There are also LineChartOptions and VerticalBarChartOptions classes.
  • Support for randomly generated data, colors, labels: Flutter Charts also provides randomly generated data, in the class RandomChartData. This class generates:
    • Y values data,
    • X labels,
    • Series colors,
    • Series legends
  • Currently the only purpose of RandomChartData is for use in the examples below. To be clear, RandomChartData Y values, series colors, and series legends are not completely random - they hardcode some demoable label, legends, color values, and data ranges (data random within the range).

Experimenting with Flutter Charts: Using the included example app file:example/lib/main.dart<a id="sec-6" name="sec-6"></a>

There are multiple ways to experiment with Flutter Charts from your computer. We describe running Flutter Charts in development mode on your device (Android, iOS - follow 1, 2 or 3, 4 and 6), or alternatively on a device emulator (device emulator running from an IDE such as IntelliJ with Android Studio installed - follow 1, 2 or 3, 5, 6 or 7).

  1. Install Flutter on your computer. See https://flutter.io/ installation section.

  2. Clone flutter_charts code from Github to your computer. Needs git client.

    cd DIRECTORY_OF_CHOICE
    git clone https://github.com/mzimmerm/flutter_charts.git
    # clone will create directory  flutter_charts
    cd flutter_charts
    
  3. (Alternative to 2.): Download and unzip flutter_charts code from Github

  4. Prepare a physical device (must be set to Development Mode) to run applications from your computer. Then connect a android device in development mode to your computer. See https://www.kingoapp.com/root-tutorials/how-to-enable-usb-debugging-mode-on-android.htm

  5. (Alternative to 4.): Prepare and start an Android device emulator on your computer.

  6. Run Flutter Charts demo app from command line (this will work in both method 4. and method 5.)

    cd DIRECTORY_OF_CHOICE/flutter_charts 
    flutter run example/lib/main.dart
    
  7. (Alternative to 6.) Run Flutter Charts demo app from IDE. This will work only with method 5.

    • Start IntelliJ IDE, create a project in the DIRECTORY_OF_CHOICE/flutter_charts start an Android emulator, then click on the Run button in Intellij (which should show the file:example/lib/main.dart in the run button).

Flutter Charts - examples: LineChart and VerticalBarChart. Code and resulting charts<a id="sec-7" name="sec-7"></a>

Flutter Charts code allow to define the following data elements:

*Data (Y values)* User-Provided or Random
*X Labels* User-Provided or Random
*Options including Colors* User-Provided or Random
*Data Rows Legends* User-Provided or Random
*Y Labels* User-Provided or Data-Generated

The examples below show a few alternative code snippets (User-Provided or Random data, labels, option) and the resulting charts.

The chart images were obtained by substituting the code snippet to the file:example/lib/main.dart code.

Random Data (Y values), Random X Labels, Random Colors, Random Data Rows Legends, Data-Generated Y Labels.<a id="sec-7-1" name="sec-7-1"></a>

This example shows that Data-Generated Y labels is the default.
Flutter Charts support reasonably intelligently generated Y Labels from data, including dealing with negatives.

Code in defineOptionsAndData():

void defineOptionsAndData() {
  _lineChartOptions = new LineChartOptions();
  _verticalBarChartOptions = new VerticalBarChartOptions();
  _chartData = new RandomChartData(useUserProvidedYLabels: _lineChartOptions.useUserProvidedYLabels);
}

Result line chart:

img

Result vertical bar chart:

img

User-Provided Data (Y values), User-Provided X Labels, Random Colors, User-Provided Data Rows Legends, Data-Generated Y Labels,<a id="sec-7-2" name="sec-7-2"></a>

Code in defineOptionsAndData():

void defineOptionsAndData() {
  _lineChartOptions = new LineChartOptions();
  _verticalBarChartOptions = new VerticalBarChartOptions();
  _chartData = new ChartData();
  _chartData.dataRowsLegends = [
    "Spring",
    "Summer",
    "Fall",
    "Winter"];
  _chartData.dataRows = [
    [10.0, 20.0,  5.0,  30.0,  5.0,  20.0, ],
    [30.0, 60.0, 16.0, 100.0, 12.0, 120.0, ],
    [25.0, 40.0, 20.0,  80.0, 12.0,  90.0, ],
    [12.0, 30.0, 18.0,  40.0, 10.0,  30.0, ],
  ];
  _chartData.xLabels =  ["Wolf", "Deer", "Owl", "Mouse", "Hawk", "Vole"];
  _chartData.assignDataRowsDefaultColors();
  // Note: ChartOptions.useUserProvidedYLabels default is still used (false);
}

Result line chart:

img

Result vertical bar chart:

img

User-Provided Data (Y values), User-Provided X Labels, Random Colors, User-Provided Data Rows Legends, User-Provided Y Labels<a id="sec-7-3" name="sec-7-3"></a>

This example show how to use the option useUserProvidedYLabels, and scaling of data to the Y labels range.

Code in defineOptionsAndData():

void defineOptionsAndData() {
  // This example shows user defined Y Labels.
  //   When setting Y labels by user, the dataRows value scale
  //   is irrelevant. User can use for example interval <0, 1>,
  //   <0, 10>, or any other, even negative ranges. Here we use <0-10>.
  //   The only thing that matters is  the relative values in the data Rows.

  // Note that current implementation sets
  // the minimum of dataRows range (1.0 in this example)
  // on the level of the first Y Label ("Ok" in this example),
  // and the maximum  of dataRows range (10.0 in this example)
  // on the level of the last Y Label ("High" in this example).
  // This is not desirable, we need to add a userProvidedYLabelsBoundaryMin/Max.
  _lineChartOptions = new LineChartOptions();
  _verticalBarChartOptions = new VerticalBarChartOptions();
  _chartData = new ChartData();
  _chartData.dataRowsLegends = [
    "Java",
    "Dart",
    "Python",
    "Newspeak"];
  _chartData.dataRows = [
    [9.0, 4.0,  3.0,  9.0, ],
    [7.0, 6.0,  7.0,  6.0, ],
    [4.0, 9.0,  6.0,  8.0, ],
    [3.0, 9.0, 10.0,  1.0, ],
  ];
  _chartData.xLabels =  ["Fast", "Readable", "Novel", "Use"];
  _chartData.dataRowsColors = [
    Colors.blue,
    Colors.yellow,
    Colors.green,
    Colors.amber,
  ];
  _lineChartOptions.useUserProvidedYLabels = true; // use the labels below on Y axis
  _chartData.yLabels = [
    "Ok",
    "Higher",
    "High",
  ];
}

Result line chart:

img (Disclaimer: Not actually measured)

Result vertical bar chart: Here the Y values should be numeric (if any) as manual labeling "Ok", "Higher", High" does not make sense for stacked type charts.

img (Disclaimer: Not actually measured)

VerticalBar Chart - one more example, showing positive/negative stacks:<a id="sec-8" name="sec-8"></a>

User-Provided Data (Y values), User-Provided X Labels, User-Provided Colors, User-Provided Data Rows Legends, User-Provided Y Labels<a id="sec-8-1" name="sec-8-1"></a>

This example has again user defined Y Labels, with a bar chart, using the smart auto-layout of user defined Y Labels. The chart shows negative and positive values similar to %down/%up stock charts.

Code in defineOptionsAndData():

void defineOptionsAndData() {
  // This example shows user defined Y Labels with
  // a bar chart, showing negative and positive values
  // similar to %down/%up stock charts.
  _lineChartOptions = new LineChartOptions();
  _verticalBarChartOptions = new VerticalBarChartOptions();
  _chartData = new ChartData();
  _chartData.dataRowsLegends = [
    "-2%_0%",
    "<-2%",
    "0%_+2%",
    ">+2%"];
  // each column absolute values should add to same number todo - 100 would make more sense, to represent 100% of stocks in each category
  _chartData.dataRows = [
    [-9.0, -8.0,  -8.0,  -5.0, -8.0, ],
    [-1.0, -2.0,  -4.0,  -1.0, -1.0, ],
    [7.0, 8.0,  7.0, 11.0, 9.0, ],
    [3.0, 2.0, 1.0,  3.0,  3.0, ],
  ];
  _chartData.xLabels =  ["Energy", "Health", "Finance", "Chips", "Oil"];
  _chartData.dataRowsColors = [
    Colors.grey,
    Colors.red,
    Colors.greenAccent,
    Colors.black,
  ];
  _lineChartOptions.useUserProvidedYLabels = false; // use labels below
  //_chartData.yLabels = [
  //  "Ok",
  //  "Higher",
  //  "High",
  //];
}

Result vertical bar chart:

img

(there is a bug here,see Known Bugs)

Bugs status<a id="sec-9" name="sec-9"></a>

  • [ ] Chart area needs clipping in the application
  • [ ] Take a look at the stock charts example. There is a bug reverting series on the negative values - both negative dataRows, and dataRowsColors must be reverted for the chart stacks to show in intended order (black, green grey red from top). But even then, dataRowsLegends are incorrect.
  • [X] https://github.com/mzimmerm/flutter_charts/issues/5 - Coloring support: Make line chart dot colors settable
  • [ ]

Future enhancements and work<a id="sec-10" name="sec-10"></a>

Bug fixes:

  • Clip chart to not paint outside area provided by Flutter app.
  • Clip labels and legends not to run into the neighbor, if too long.

On the boundary of bug and enhancement:

  • For ChartOptions.useUserProvidedYLabels = true. See example with User defined YLabels: Current implementation sets the minimum of dataRows range (1.0 in the example) on the level of the first Y Label ("Ok" in this example), and the maximum of dataRows range (10.0 in this example) on the level of the last Y Label ("High" in this example). This is not desirable, we need to add a userProvidedYLabelsBoundaryMin/Max.

Enhancements:

  • Create document / image showing layout and spacing - show option variables on image
  • Simple:
    • Add options to hide the grid (keep axes)
    • Add options to hide axes (if axes not shown, labels should not show?)
    • Decrease option for default spacing around the Y axis.
  • First, probably need to provide tooltips
  • Next, a few more chart types: Spline line chart (stacked line chart), Grouped VerticalBar chart,
  • Next, re-implement the layout more generically and clearly. Space saving changes such as tilting labels.
  • Next, add ability to invert X and Y axis (values on horizontal axis)

TODO Terminology and Selected Classes<a id="sec-11" name="sec-11"></a>

  • (Presenter)Leaf : The finest visual element presented in each "column of view" in chart - that is, all widgets representing series of data displayed above each X label. For example, for Line chart, the leaf would be one line and dot representing one Y value at one X label. For the bar chart, the leaf would be one bar representing one (stacked) Y value at one X label.
    • Classes: Presenter, LineAndHotspotPresenter, VerticalBarPresenter, PresenterCreator
  • Painter : Class which paints to chart to canvas. Terminology and class structure taken from Flutter's Painter and Painting classes.
    • Classes: todo

Internal notes<a id="sec-12" name="sec-12"></a>

DONE Add ability to create a Table of Contents to README.org<a id="sec-12-1" name="sec-12-1"></a>

  • [X] Install toc-org package

  • [X] Add to init.el

    (if (require 'toc-org nil t)
      (add-hook 'org-mode-hook 'toc-org-enable)
    (warn "toc-org not found"))
    
  • [X] Every time README.org is saved, first heading with a :TOC: tag will be updated with the current table of contents.

  • [X] So nothing special need be done after the above is configured.

Adding images to README.org<a id="sec-12-2" name="sec-12-2"></a>

  • [ ] https://pub.dartlang.org does not allow storing images.
  • [ ] Add / move new images to flutter_charts/doc/readme_images
  • [ ] org file, change image links to look like img~

Pub - Publishing workflow on https://pub.dartlang.org<a id="sec-12-3" name="sec-12-3"></a>

Notes:<a id="sec-12-3-1" name="sec-12-3-1"></a>

  1. Pub requires the following file in project to show the correct tabs on pub

    1. Tab README.md - Needs the file

    2. Tab CHANGELOG.md - Needs the file

    3. Tab Example - this tab appears if the project file file:flutter_charts/example/lib/main.dart exists

    4. Tab Installing - shows automatically

IF README.md needs change<a id="sec-12-3-2" name="sec-12-3-2"></a>

  1. README.org: make sure image links point to flutter_charts/doc/readme_images

  2. README.org: Conversion steps to README.md

    To convert README.org to README.md, we need to do a few extra steps for README.md image links to be readable on https://pub.dartlang.org.

    1. Note: Org file which has :TOC: in heading, generates TOC on every save.

    2. README.org: Export org to md: C-c C-e m m in the org file to create the generated md file

    3. README.md: Delete generated TOC

    4. README.md: Generate md-native TOC:

      • Cursor on top
      • M-x: markdown-toc/generate-toc
    5. README.md: Fix image links in the README.md - links must look like this:

      -![img](https://github.com/mzimmerm/flutter_charts/raw/master/doc/readme_images/README.org_20171102_180657_27063rZs.png)
      +![img](https://github.com/mzimmerm/flutter_charts/raw/master/https://github.com/mzimmerm/flutter_charts/raw/master/doc/readme_images/README.org_20171102_180657_27063rZs.png)
      
    6. README.md: This is achieved with: replace-string https://github.com/mzimmerm/flutter_charts/raw/master/doc/readme_images/ https://github.com/mzimmerm/flutter_charts/raw/master/https://github.com/mzimmerm/flutter_charts/raw/master/doc/readme_images/

pubspec.yaml - Increase version number<a id="sec-12-3-3" name="sec-12-3-3"></a>

cd flutter_charts; flutter packages pub upgrade<a id="sec-12-3-4" name="sec-12-3-4"></a>

cd flutter_charts; flutter packages pub get<a id="sec-12-3-5" name="sec-12-3-5"></a>

Test included app from IntelliJ<a id="sec-12-3-6" name="sec-12-3-6"></a>

git push<a id="sec-12-3-7" name="sec-12-3-7"></a>

README.md on https://github.com/mzimmerm/flutter_charts - check if looks ok<a id="sec-12-3-8" name="sec-12-3-8"></a>

flutter packages pub publish --dry-run<a id="sec-12-3-9" name="sec-12-3-9"></a>

flutter packages pub publish<a id="sec-12-3-10" name="sec-12-3-10"></a>

Check https://pub.dartlang.org/packages/flutter_charts<a id="sec-12-3-11" name="sec-12-3-11"></a>

Test the package that was just published<a id="sec-12-3-12" name="sec-12-3-12"></a>

  1. cd flutter_charts_sample_app; flutter packages pub upgrade; flutter packages pub get; flutter run

v0.1.7 (2017-12-17)

Fixed README.md error - images failing to show (https://github.com/mzimmerm/flutter_charts/issues/8)

v0.1.6 (2017-12-03)

Implemented change in https://github.com/mzimmerm/flutter_charts/issues/5 - allows to set paint on line chart hotspot circles

Added the following new line chart options in charts/line/options.dart

  ui.Paint hotspotInnerPaint = new ui.Paint()
    ..color = material.Colors.yellow;

  ui.Paint hotspotOuterPaint = new ui.Paint()
    ..color = material.Colors.black;

  double lineStrokeWidth = 3.0;

Implemented change in https://github.com/mzimmerm/flutter_charts/issues/6 - line chart allows to reverse order of data series (dataRows) to make the significant series line to be on top

Added the following new chart options in charts/options.dart

  bool firstDataRowPaintedFirst = true;

Made several text options configurable

Moved the following to options in charts/options.dart (from being hardcoded)

  painting.TextStyle labelTextStyle = new painting.TextStyle(
    color: material.Colors.grey[600],
    fontSize: 14.0,);

  ui.TextDirection labelTextDirection   = ui.TextDirection.ltr;
  ui.TextAlign     labelTextAlign       = ui.TextAlign.center;
  double           labelTextScaleFactor = 1.0;

Renamed option xTopMinTicksHeight to xTopPaddingAboveTicksHeight

New name reflects the usage better.

v0.1.5 (2017-10-27)

This version finally fixed issue https://github.com/mzimmerm/flutter_charts/issues/2 - flutter charts not actually working as a library package (reason: incorrectly specified dependencies).

v0.1.4 (2017-10-27)

  • Only changes in documentation. Also publishing using flutter packages pub publish instead of previously incorrect pub publish which resulted in a package that reports error on clients' getting the package using flutter pub get. Hopefully this change will fix the issue. Below is the full error this new version is trying to fix:

The following log is from a test app in https://github.com/mzimmerm/flutter_charts_sample_app. It is mostly relevant as a documentation of the issue, client apps can ignore this.

flutter_charts_sample_app> flutter pub get      
Running "flutter packages get" in flutter_charts_sample_app...      
Package flutter_charts has no versions that match >=0.1.3 <0.2.0 derived from:
- flutter_charts_sample_app depends on version ^0.1.3
---- Log transcript ----
FINE: Pub 1.25.0-dev.11.0
MSG : Resolving dependencies...
SLVR: Solving dependencies:
    | - flutter_charts ^0.1.3 from hosted (flutter_charts)
    | - flutter any from sdk (flutter) (locked to 0.0.37)
IO  : Get versions from https://pub.dartlang.org/api/packages/flutter_charts.
IO  : HTTP GET https://pub.dartlang.org/api/packages/flutter_charts
    | Accept: application/vnd.pub.v2+json
    | X-Pub-OS: linux
    | X-Pub-Command: get
    | X-Pub-Session-ID: 8D558B08-DBBE-4D24-AB8F-C0EEC36157B2
    | X-Pub-Environment: flutter_cli
    | X-Pub-Reason: direct
    | user-agent: Dart pub 1.25.0-dev.11.0
IO  : HTTP response 200 OK for GET https://pub.dartlang.org/api/packages/flutter_charts
    | took 0:00:00.332100
    | transfer-encoding: chunked
    | date: Tue, 28 Nov 2017 05:32:06 GMT
    | content-encoding: gzip
    | vary: Accept-Encoding
    | via: 1.1 google
    | content-type: application/json
    | x-frame-options: SAMEORIGIN
    | x-xss-protection: 1; mode=block
    | x-content-type-options: nosniff
    | server: nginx
SLVR: * start at root
SLVR: | flutter 0.0.37 from sdk is locked
SLVR: | * select flutter 0.0.37 from sdk
SLVR: | | collection 1.14.3 from hosted is locked
SLVR: | | * select collection 1.14.3 from hosted
SLVR: | | | http 0.11.3+14 from hosted is locked
SLVR: | | | * select http 0.11.3+14 from hosted
SLVR: | | | | async 1.13.3 from hosted is locked
SLVR: | | | | * select async 1.13.3 from hosted
SLVR: | | | | | http_parser 3.1.1 from hosted is locked
SLVR: | | | | | * select http_parser 3.1.1 from hosted
SLVR: | | | | | | charcode 1.1.1 from hosted is locked
SLVR: | | | | | | * select charcode 1.1.1 from hosted
SLVR: | | | | | | | meta 1.1.1 from hosted is locked
SLVR: | | | | | | | * select meta 1.1.1 from hosted
SLVR: | | | | | | | | path 1.4.2 from hosted is locked
SLVR: | | | | | | | | * select path 1.4.2 from hosted
SLVR: | | | | | | | | | sky_engine 0.0.99 from path is locked
SLVR: | | | | | | | | | * select sky_engine 0.0.99 from path
SLVR: | | | | | | | | | | source_span 1.4.0 from hosted is locked
SLVR: | | | | | | | | | | * select source_span 1.4.0 from hosted
SLVR: | | | | | | | | | | | stack_trace 1.8.2 from hosted is locked
SLVR: | | | | | | | | | | | * select stack_trace 1.8.2 from hosted
SLVR: | | | | | | | | | | | | string_scanner 1.0.2 from hosted is locked
SLVR: | | | | | | | | | | | | * select string_scanner 1.0.2 from hosted
SLVR: | | | | | | | | | | | | | typed_data 1.1.4 from hosted is locked
SLVR: | | | | | | | | | | | | | * select typed_data 1.1.4 from hosted
SLVR: | | | | | | | | | | | | | | vector_math 2.0.5 from hosted is locked
SLVR: | | | | | | | | | | | | | | * select vector_math 2.0.5 from hosted
SLVR: | | | | | | | | | | | | | | | inconsistent source "hosted" for flutter:
    | | | | | | | | | | | | | | | |   flutter_charts 0.1.3 from hosted -> flutter >=0.0.20 <0.1.0 from hosted (flutter)
    | | | | | | | | | | | | | | | |   flutter_charts_sample_app 0.0.0 (root) -> flutter any from sdk (flutter)
SLVR: | | | | | | | | | | | | | | | version 0.1.2 of flutter_charts doesn't match >=0.1.3 <0.2.0:
    | | | | | | | | | | | | | | | |   flutter_charts_sample_app 0.0.0 (root) -> flutter_charts ^0.1.3 from hosted (flutter_charts)
SLVR: | | | | | | | | | | | | | | | version 0.1.1 of flutter_charts doesn't match >=0.1.3 <0.2.0:
    | | | | | | | | | | | | | | | |   flutter_charts_sample_app 0.0.0 (root) -> flutter_charts ^0.1.3 from hosted (flutter_charts)
SLVR: | | | | | | | | | | | | | | | version 0.1.0 of flutter_charts doesn't match >=0.1.3 <0.2.0:
    | | | | | | | | | | | | | | | |   flutter_charts_sample_app 0.0.0 (root) -> flutter_charts ^0.1.3 from hosted (flutter_charts)
SLVR: BacktrackingSolver took 0:00:00.516136 seconds.
    | - Tried 1 solutions
    | - Requested 1 version lists
    | - Looked up 1 cached version lists
    | 
FINE: Resolving dependencies finished (0.5s).
ERR : Package flutter_charts has no versions that match >=0.1.3 <0.2.0 derived from:
    | - flutter_charts_sample_app depends on version ^0.1.3
FINE: Exception type: NoVersionException
FINE: package:pub/src/entrypoint.dart 195                                             Entrypoint.acquireDependencies
    | package:pub/src/command/get.dart 38                                             GetCommand.run
    | package:args/command_runner.dart 194                                            CommandRunner.runCommand
    | package:pub/src/command_runner.dart 168                                         PubCommandRunner.runCommand.<fn>
    | dart:async                                                                      new Future.sync
    | package:pub/src/utils.dart 102                                                  captureErrors.<fn>
    | package:stack_trace                                                             Chain.capture
    | package:pub/src/utils.dart 117                                                  captureErrors
    | package:pub/src/command_runner.dart 168                                         PubCommandRunner.runCommand
    | package:pub/src/command_runner.dart 117                                         PubCommandRunner.run
    | /b/build/slave/dart-sdk-linux-dev/build/sdk/third_party/pkg/pub/bin/pub.dart 8  main
    | ===== asynchronous gap ===========================
    | dart:async                                                                      _Completer.completeError
    | package:pub/src/entrypoint.dart 243                                             Entrypoint.acquireDependencies
    | ===== asynchronous gap ===========================
    | dart:async                                                                      _asyncThenWrapperHelper
    | package:pub/src/entrypoint.dart 192                                             Entrypoint.acquireDependencies
    | package:pub/src/command/get.dart 38                                             GetCommand.run
    | package:args/command_runner.dart 194                                            CommandRunner.runCommand
    | ===== asynchronous gap ===========================
    | dart:async                                                                      new Future.microtask
    | package:args/command_runner.dart 142                                            CommandRunner.runCommand
    | package:pub/src/command_runner.dart 168                                         PubCommandRunner.runCommand.<fn>
    | dart:async                                                                      new Future.sync
    | package:pub/src/utils.dart 102                                                  captureErrors.<fn>
    | package:stack_trace                                                             Chain.capture
    | package:pub/src/utils.dart 117                                                  captureErrors
    | package:pub/src/command_runner.dart 168                                         PubCommandRunner.runCommand
---- End log transcript ----
pub get failed (1)

v0.1.3 (2017-10-03)

  • Only changes in README, to figure out how to include images (turns out all links must be external)

v0.1.0 (2017-10-03)

  • Initial push. Line chart and (vertical) bar chart support. Various options supported.

Semantic Version 2.0.0 Conventions

This package follows Semantic Version 2.0.0. http://semver.org/

Example: 1.2.3 means MAJOR.MINOR.PATCH

Development: Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.

API Stable versions: All versions with the same MAJOR, where MAJOR>0 must have the same API.

example/lib/main.dart

// note: All classes without prefix in this code are either
//       - from material.dart or
//       - from flutter_charts.dart exports (this library)
//       Also, material.dart exports many dart files, including widgets.dart,
//         so Widget classes are referred to without prefix
import 'package:flutter/material.dart';
import 'dart:ui' as ui;

// provides: data.dart, random_chart_data.dart, line_chart_options.dart
import 'package:flutter_charts/flutter_charts.dart';


/// Example of simple line chart usage in an application.
///
/// Library note: This file is same level as _lib_ so everything from _lib_ must
/// be imported using the "package:" scheme, e.g.
/// > import 'package:flutter_charts/flutter_charts.dart';
void main() {
  // runApp is function (not method) in PROJ/packages/flutter/lib/src/widgets/binding.dart.
  //
  // Why we do not have to import binding.dart?
  //
  // In brief, because it is imported through another file, material.dart.
  //
  // Longer reason
  //
  //      - Because Any Flutter app must have:
  //        1) main() { runApp(new MyApp()) } // entry point
  //        2) import 'package:flutter/material.dart';
  //          Note: *NOT* 'package:flutter/material/material.dart'.
  //          Note: material.dart is on path: PROJ/packages/flutter/lib/material.dart
  //          so another note:
  //             * the lib level is skipped int the import reference
  //             * package: represent a directory where packages
  //               for this project are installed in pub update package
  //      - And:
  //        3) The imported 'package:flutter/material.dart' contains line:
  //            export 'widgets.dart';
  //            which references, at the same level, a path:
  //               PROJ/packages/flutter/lib/widgets.dart
  //            which contains:
  //               export 'src/widgets/binding.dart';
  //               on path: PROJ/packages/flutter/lib/src/widgets/binding.dart
  //            which contains the function runApp().
  //
  //  So, eventually, the loading of binding.dart, and it's runApp() function
  //  in MyApp is achieved this way:
  //    1) This file (example/lib/main.dart) has
  //        - import 'package:flutter/material.dart' (references PROJ/packages/flutter/lib/material.dart)
  //    2) material.dart has
  //        - export 'widgets.dart'; (references same dir        PROJ/packages/flutter/lib/widgets.dart)
  //    3) widgets.dart has
  //        - export 'src/widgets/binding.dart'; (references dir PROJ/packages/flutter/lib/src/widgets/binding.dart)
  //    4) binding.dart has
  //        - the runApp() function
  //
  // This process achieves importing (heh via exports) the file
  //    packages/flutter/lib/src/widgets/binding.dart
  //    which has the runApp() function.
  //
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of the application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Charts Demo Title',
      debugShowCheckedModeBanner: false,
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Charts Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful,
  // meaning that it has a State object (defined below) that contains
  // fields that affect how it looks.

  // This class is the configuration for the state. It holds the
  // values (in this case the title) provided by the parent (in this
  // case the App widget) and used by the build method of the State.
  // Fields in a Widget subclass are always marked "final".

  final String title;

  /// Stateful widgets must implement the [createState()] method.
  ///
  /// The [createState()] method will typically return the
  /// new state of the widget.
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

/// State of the page.
class _MyHomePageState extends State<MyHomePage> {

  LineChartOptions _lineChartOptions;
  ChartOptions _verticalBarChartOptions;

  ChartData _chartData;

   _MyHomePageState() {

     // defineOptionsAndData();

   }

  void defineOptionsAndData() {
    _lineChartOptions = new LineChartOptions();
    _verticalBarChartOptions = new VerticalBarChartOptions();
    _chartData = new RandomChartData(useUserProvidedYLabels: _lineChartOptions.useUserProvidedYLabels);
  }

  /* 5 Demonstrate order of painting lines on the line chart,
       when dataRows lines are on top of each other

  void defineOptionsAndData() {
    _lineChartOptions = new LineChartOptions();
    _verticalBarChartOptions = new VerticalBarChartOptions();
    _chartData = new ChartData();
    _chartData.dataRowsLegends = [
      "Spring",
      "Summer",
      "Fall",
      "Winter"];
    _chartData.dataRows = [
      [10.0, 20.0,  5.0,  30.0,  5.0,  20.0, ],
      [10.0, 20.0,  5.0,  30.0,  5.0,  30.0, ],
      [25.0, 40.0, 20.0,  80.0, 12.0,  90.0, ],
      [25.0, 40.0, 20.0,  80.0, 12.0, 100.0, ],
    ];
    _chartData.xLabels =  ["Wolf", "Deer", "Owl", "Mouse", "Hawk", "Vole"];
    _chartData.assignDataRowsDefaultColors();
    // Note: ChartOptions.useUserProvidedYLabels default is still used (false);
  }
   */

   /* 4 Basic simpliest demo

   void defineOptionsAndData() {
     _lineChartOptions = new LineChartOptions();
     _verticalBarChartOptions = new VerticalBarChartOptions();
     _chartData = new RandomChartData(useUserProvidedYLabels: _lineChartOptions.useUserProvidedYLabels);
   }
   */

   /* 3
   void defineOptionsAndData() {
     _lineChartOptions = new LineChartOptions();
     _verticalBarChartOptions = new VerticalBarChartOptions();
     _chartData = new ChartData();
     _chartData.dataRowsLegends = [
       "Spring",
       "Summer",
       "Fall",
       "Winter"];
     _chartData.dataRows = [
       [10.0, 20.0,  5.0,  30.0,  5.0,  20.0, ],
       [30.0, 60.0, 16.0, 100.0, 12.0, 120.0, ],
       [25.0, 40.0, 20.0,  80.0, 12.0,  90.0, ],
       [12.0, 30.0, 18.0,  40.0, 10.0,  30.0, ],
     ];
     _chartData.xLabels =  ["Wolf", "Deer", "Owl", "Mouse", "Hawk", "Vole"];
     _chartData.assignDataRowsDefaultColors();
     // Note: ChartOptions.useUserProvidedYLabels default is still used (false);
   }
   */

   /* 2
   void defineOptionsAndData() {
     // This example shows user defined Y Labels.
     //   When setting Y labels by user, the dataRows value scale
     //   is irrelevant. User can use for example interval <0, 1>,
     //   <0, 10>, or any other, even negative ranges. Here we use <0-10>.
     //   The only thing that matters is  the relative values in the data Rows.

     // Note that current implementation sets
     // the minimum of dataRows range (1.0 in this example)
     // on the level of the first Y Label ("Ok" in this example),
     // and the maximum  of dataRows range (10.0 in this example)
     // on the level of the last Y Label ("High" in this example).
     // This is not desirable, we need to add a userProvidedYLabelsBoundaryMin/Max.
     _lineChartOptions = new LineChartOptions();
     _verticalBarChartOptions = new VerticalBarChartOptions();
     _chartData = new ChartData();
     _chartData.dataRowsLegends = [
       "Java",
       "Dart",
       "Python",
       "Newspeak"];
     _chartData.dataRows = [
       [9.0, 4.0,  3.0,  9.0, ],
       [7.0, 6.0,  7.0,  6.0, ],
       [4.0, 9.0,  6.0,  8.0, ],
       [3.0, 9.0, 10.0,  1.0, ],
     ];
     _chartData.xLabels =  ["Fast", "Readable", "Novel", "Use"];
     _chartData.dataRowsColors = [
       Colors.blue,
       Colors.yellow,
       Colors.green,
       Colors.amber,
     ];
     _lineChartOptions.useUserProvidedYLabels = true; // use labels below
     _chartData.yLabels = [
       "Ok",
       "Higher",
       "High",

     ];
   }
  */

   /* 1
   void defineOptionsAndData() {
     // In each column, adding it's absolute values should add to same number:
     // 100 would make more sense, to represent 100% of stocks in each category.
    _lineChartOptions = new LineChartOptions();
     _verticalBarChartOptions = new VerticalBarChartOptions();
     _chartData = new ChartData();
     _chartData.dataRowsLegends = [
       "-2%_0%",
       "<-2%",
       "0%_+2%",
       ">+2%"];
     // each column should add to same number. everything else is relative.
     _chartData.dataRows = [
       [-9.0, -8.0,  -8.0,  -5.0, -8.0, ],
       [-1.0, -2.0,  -4.0,  -1.0, -1.0, ],
       [7.0, 8.0,  7.0, 11.0, 9.0, ],
       [3.0, 2.0, 1.0,  3.0,  3.0, ],
     ];
     _chartData.xLabels =  ["Energy", "Health", "Finance", "Chips", "Oil"];
     _chartData.dataRowsColors = [
       Colors.grey,
       Colors.red,
       Colors.greenAccent,
       Colors.black,
     ];
     _lineChartOptions.useUserProvidedYLabels = false; // use labels below
     //_chartData.yLabels = [
     //  "Ok",
     //  "Higher",
     //  "High",
     //];
   }
  */

  void _chartStateChanger() {
    setState(() {
      // This call to setState tells the Flutter framework that
      // something has changed in this State, which causes it to rerun
      // the build method below so that the display can reflect the
      // updated values. If we changed state without calling
      // setState(), then the build method would not be called again,
      // and so nothing would appear to happen.

      /// here we create new random data to illustrate state change
      // defineOptionsAndData();
    });
  }

  @override
  Widget build(BuildContext context) {
    // The (singleton?) window object is available anywhere using ui.
    // From window, we can get  ui.window.devicePixelRatio, and also
    //   ui.Size windowLogicalSize = ui.window.physicalSize / devicePixelRatio
    // Note: Do not use ui.window for any sizing: see
    //       https://github.com/flutter/flutter/issues/11697

    // Use MediaQuery.of(context) for any sizing.
    // note: mediaQueryData can still return 0 size,
    //       but if MediaQuery.of(context) is used, Flutter will guarantee
    //       the build(context) will be called again !
    //        (once non 0 size becomes available)
    MediaQueryData mediaQueryData = MediaQuery.of(context);

    // note: windowLogicalSize = size of the media (screen) in logical pixels
    // note: same as ui.window.physicalSize / ui.window.devicePixelRatio;
    ui.Size windowLogicalSize = mediaQueryData.size;

    // devicePixelRatio = number of device pixels for each logical pixel.
    // note: in all known hardware, size(logicalPixel) > size(devicePixel)
    // note: this is also, practically, never needed
    double logicalToDevicePixelSize = mediaQueryData.devicePixelRatio;

    // textScaleFactor = number of font pixels for each logical pixel.
    // note: with some fontSize, if text scale factor is 1.5
    //       => text is 1.5x larger than the font size.
    double fontScale = mediaQueryData.textScaleFactor;

    // Let us give the LineChart full width and half of height of window.
    final ui.Size chartLogicalSize =
        new Size(windowLogicalSize.width, windowLogicalSize.height / 2);

    print(" ### Size: ui.window.physicalSize=${ui.window.physicalSize}, "
        "windowLogicalSize = mediaQueryData.size = $windowLogicalSize,"
        "chartLogicalSize=$chartLogicalSize");

    defineOptionsAndData();

    LineChart lineChart = new LineChart(
      painter: new LineChartPainter(),
      layouter: new LineChartLayouter(
          chartData: _chartData,
          chartOptions: _lineChartOptions),
    );

    VerticalBarChart verticalBarChart = new VerticalBarChart(
      painter: new VerticalBarChartPainter(),
      layouter: new VerticalBarChartLayouter(
          chartData: _chartData,
          chartOptions: _verticalBarChartOptions),
    );

    // [MyHomePage] extends [StatefulWidget].
    // [StatefulWidget] calls build(context) every time setState is called,
    // for instance as done by the _chartStateChanger method above.
    // The Flutter framework has been optimized to make rerunning
    // build methods fast, so that you can just rebuild anything that
    // needs updating rather than having to individually change
    // instances of widgets.
    return new Scaffold(
      appBar: new AppBar(
        // Here we take the value from the MyHomePage object that
        // was created by the App.build method, and use it to set
        // our appbar title.
        title: new Text(widget.title),
      ),
      body: new Center(
        // Center is a layout widget. It takes a single child and
        // positions it in the middle of the parent.
        child: new Column(
          // Column is also layout widget. It takes a list of children
          // and arranges them vertically. By default, it sizes itself
          // to fit its children horizontally, and tries to be as tall
          // as its parent.
          //
          // Invoke "debug paint" (press "p" in the console where you
          // ran "flutter run", or select "Toggle Debug Paint" from the
          // Flutter tool window in IntelliJ) to see the wireframe for
          // each widget.
          //
          // Column has various properties to control how it sizes
          // itself and how it positions its children. Here we use
          // mainAxisAlignment to center the children vertically; the
          // main axis here is the vertical axis because Columns are
          // vertical (the cross axis would be horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new RaisedButton(
              color: Colors.green,
              onPressed: _chartStateChanger,
            ),
            new Text(
              'vvvvvvvv:',
            ),

            // Expanded can be around one child of a Row or a Column
            // (there can be one or more children of those layouts).
            //
            // In this document below, we use | as abbreviation for vertical expansion,
            // <--> for horizontal expansion.
            //
            // "new Expanded()" around one of children of Row, or Column,
            // stretches/pulls the expanded child in the parent's
            // "growing" direction.
            //
            // So:
            //   - Inside Column (e.g. children: [A, B, Expanded (C)]) stretches C in
            //     column's "growing" direction (that is vertically |)
            //     to the fullest available outside height.
            //   - For Row  (e.g. children: [A, B, Expanded (C)]) stretches C in
            //     rows's "growing" direction (that is horizontally <-->)
            //     to the fullest available outside width.
            // The layout of this code, is, structurally like this:
            //   Column (children: [
            //      vvv,
            //      Expanded (
            //        Row  (children: [
            //        >>>, Expanded (Chart), <<<,
            //        ]),
            //      ^^^
            //    ])
            // The outer | expansion, in the Column's middle child
            //   pulls/stretches the row vertically |
            //   BUT also needs explicit
            //   crossAxisAlignment: CrossAxisAlignment.stretch.
            //   The cross alignment stretch carries
            //   the | expansion to all <--> expanded children.
            //  Basically, while "Expanded" only applies stretch in one
            //    direction, another outside "Expanded" with CrossAxisAlignment.stretch
            //    can force the innermost child to be stretched in both directions.
            new Expanded( // expansion inside Column pulls contents |
              child:
              new Row(
                // this stretch carries | expansion to <--> Expanded children
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: [
                  new Text('>>>'),
                  // LineChart is CustomPaint:
                  // A widget that provides a canvas on which to draw
                  // during the paint phase.

                  // Row -> Expanded -> Chart expands chart horizontally <-->
                  new Expanded(
                    child:  lineChart,
                  ),
                  new Text('<<<'),
                ],
              ), //
            ), // Column -> Expanded

            new Text('^^^^^^:'),
            new RaisedButton(
              color: Colors.green,
              onPressed: _chartStateChanger,
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: _chartStateChanger,
        tooltip: 'New Random Data',
        child: new Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_charts: "^0.1.7"

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:flutter_charts/flutter_charts.dart';
  
Version Uploaded Documentation Archive
0.1.7 Dec 17, 2017 Go to the documentation of flutter_charts 0.1.7 Download flutter_charts 0.1.7 archive
0.1.6 Dec 4, 2017 Go to the documentation of flutter_charts 0.1.6 Download flutter_charts 0.1.6 archive
0.1.5 Nov 28, 2017 Go to the documentation of flutter_charts 0.1.5 Download flutter_charts 0.1.5 archive
0.1.4 Nov 28, 2017 Go to the documentation of flutter_charts 0.1.4 Download flutter_charts 0.1.4 archive
0.1.3 Nov 3, 2017 Go to the documentation of flutter_charts 0.1.3 Download flutter_charts 0.1.3 archive
0.1.2 Nov 3, 2017 Go to the documentation of flutter_charts 0.1.2 Download flutter_charts 0.1.2 archive
0.1.1 Nov 3, 2017 Go to the documentation of flutter_charts 0.1.1 Download flutter_charts 0.1.1 archive
0.1.0 Nov 3, 2017 Go to the documentation of flutter_charts 0.1.0 Download flutter_charts 0.1.0 archive

Analysis

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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
87 / 100
Health:
Code health derived from static analysis. [more]
89 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
93 / 100
Overall score:
Weighted score of the above. [more]
89
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • Documentation URL does not exists.

    We were unable to access https://pub.dartlang.org/packages/flutter_charts/doc at the time of the analysis.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 2 errors 34 hints.

    Strong-mode analysis of lib/src/chart/layouters.dart failed with the following error:

    line: 1169 col: 34
    The argument type '(StackableValuePoint) → Null' can't be assigned to the parameter type '(dynamic) → void'.

    Strong-mode analysis of lib/src/chart/presenters.dart failed with the following error:

    line: 84 col: 24
    The argument type '(StackableValuePoint) → Null' can't be assigned to the parameter type '(dynamic) → void'.

    Similar analysis of the following files failed:

    • lib/flutter_charts.dart (hint)
    • lib/src/chart/bar/chart.dart (hint)
    • lib/src/chart/bar/layouters.dart (hint)
    • lib/src/chart/bar/presenters.dart (hint)
    • lib/src/chart/data.dart (hint)
    • lib/src/chart/line/chart.dart (hint)
    • lib/src/chart/line/layouters.dart (hint)
    • lib/src/chart/line/options.dart (hint)
    • lib/src/chart/line/presenters.dart (hint)
    • lib/src/chart/options.dart (hint)
    • lib/src/chart/painter.dart (hint)
    • lib/src/util/label_painter.dart (hint)
    • lib/src/util/line_presenter.dart (hint)
    • lib/src/util/random_chart_data.dart (hint)
    • lib/src/util/range.dart (hint)
    • lib/src/util/util.dart (hint)
  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • 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 API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
decimal >=0.1.4 <0.2.0 0.1.4 0.2.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
rational 0.1.11 0.2.0
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7
Dev dependencies
flutter_test
test