Thursday, 12 March 2015

Dart POW - ( Package Of The Week) #1 : modern_charts

New feature for the blog - Dart POW! A weekly look at an interesting Package on pub.dartlang.org

modern_charts is a great canvas based graphs package with support for Bar, Gauge, Line, Pie/Donut and Radar graphs.

The API is nice and straightforward too - didn't take long for me to create a LineChart:

import 'dart:html';
import 'package:modern_charts/modern_charts.dart';

void main() {

  DataTable table = new DataTable(
 [['Categories', 'Bears', 'Giraffes', 'Rabbits'],
  ['Monday', 12, 23, 25], ['Tuesday', 23, 24, 26],
  ['Wednesday', 24, 23, 21], ['Thursday', 44, 25, 21],
  ['Friday', 23, 24, 22], ['Saturday', 25, 10, 24],
  ['Sunday', 24, 12, 28]]);

  Map options = {
    'colors': ['#cbcbcb', '#00aa00', '#990000'],
    'series': {
      'labels': {
        'enabled': true
      }
    }
  };

  LineChart chart = new LineChart(document.body);
  chart.draw(table, options);

}

Feel free to leave a comment with suggestions for the next Dart POW post! Don't be too shy to suggest your own package :-)