chartisan 1.4.0 copy "chartisan: ^1.4.0" to clipboard
chartisan: ^1.4.0 copied to clipboard

Chartisan's Dart backend

example/main.dart

import 'dart:io';
import 'package:chartisan/chartisan.dart';

Future main() async {
  var server = await HttpServer.bind(
    InternetAddress.loopbackIPv4,
    9000,
  );
  print('Listening on localhost:${server.port}');

  await for (HttpRequest request in server) {
    final chart = Chartisan.build().labels(['a', 'b', 'c']).dataset(
        'Sample 1', [1, 2, 3]).dataset('Sample 2', [3, 2, 1]).toJSON();
    request.response.headers
      ..add('Content-Type', 'application/json')
      ..add('Access-Control-Allow-Origin', '*');
    request.response.write(chart);
    await request.response.close();
  }
}