Skip to content

A library for creating simple plots in Dart and exporting them as SVG. One may need this if they want to generate a PDF report with plots in Dart.

License

Notifications You must be signed in to change notification settings

denshion/dart_svgplot

Repository files navigation

dart-svgplot

A library for creating simple plots in Dart and exporting them as SVG. One may need this if they want to generate a PDF report with plots in Dart.

Features

Can generate simple 2D line and scatter plots. Styles are customized using CSS directly.

Getting started

TODO: List prerequisites and provide or point to information on how to start using the package.

Usage

Example: ./example.svg

  List<double> x = List.generate(55, (i) => i / 5);
  final plot = SvgGraphFigure(
    absoluteGeometry: Rect.fromLTWH(0, 0, 453.5, 283.5),
    lengthUnit: SvgGraphUnit.point
  );
  final ax = plot.axis(
    labelTextStyle: {
      'font-size': '14'
    },
    tickLabelTextStyle: {
      'font-size': '11'
    },
    xlabel: 'Time, s',
    ylabel: 'Signal, V',
  );
  ax.plot(
    x.map((x) => Point(x, sin(x))).toList(),
    marker: SvgGraphMarker.circle,
    lineStyle: {
      'stroke': 'none'
    }
  );
  ax.plot(
    x.map((x) => Point(x, 1.5 * cos(x))).toList(),
    lineStyle: {
      'stroke': '#0000ff',
    },
  );
  final document = plot.toSvgXml();
  (await File('example.svg')).writeAsString(document.toXmlString());

Additional information

About

A library for creating simple plots in Dart and exporting them as SVG. One may need this if they want to generate a PDF report with plots in Dart.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages