RCHowell / Flutter-Plot

A pretty plotting package for Flutter apps

Home Page:https://pub.dartlang.org/packages/flutter_plot#-readme-tab-

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plotting problem

h80r opened this issue · comments

commented

Maybe this isn't the supposed usage, but I was using your lib to plot geometrical transformations, and simply can't plot a square.
Is there any way to get this right?

Example:

class _PlotterState extends State<Plotter> {
  List<Point> originalShape = [
    Point(1, 1),
    Point(4, 1),
    Point(1, 4),
    Point(4, 4)
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Shape Plotting"),
        backgroundColor: Colors.blueGrey[900],
      ),
      body: Center(
        child: Container(
          width: 500,
          padding: EdgeInsets.all(10),
          child: Plot(
            height: 400.0,
            data: originalShape,
            centered: true,
            gridSize: Offset(2.0, 2.0),
            style: PlotStyle(
                pointRadius: 3.0,
                outlineRadius: 1.0,
                primary: Colors.white,
                secondary: Colors.blueAccent,
                textStyle: TextStyle(
                  fontSize: 10.0,
                  color: Colors.blueGrey,
                ),
                axis: Colors.blueGrey[600],
                gridline: Colors.blueGrey[100],
                trace: true,
                traceClose: true),
            padding: EdgeInsets.fromLTRB(40.0, 12.0, 12.0, 40.0),
            xTitle: 'X',
            yTitle: 'Y',
          ),
        ),
      ),
    );
  }

Result

image

Calculating min/max X/Y mutates the list and messes up your order. I'm checking in a commit that fixes this. Then the order of your points will need to be changed, because order matters.

List<Point> originalShape = [
  Point(1, 1),
  Point(4, 1),
  Point(1, 4),
  Point(4, 4)
];

square