I want to plot a function with canvas in Flutter/Dart. Let's say we have an expression like that: y = 2x^2 4x. I have already tried drwaing a lot of little filled circles one near to another and this gives to me the desidered output. But I'm still searching for a more professional and right way to do that. Any help will be very appreciated, thank you!
CodePudding user response:
If you want a fancy chart I would recommend fl_chart package. You could precalculate a list of values from your function and let fl_chart display them.
You could also use the CustomPaint widget and a CustomPainter to draw these values in different ways.
You could simply draw a line from the current point to the next point which results in a (possibly not smooth) graph. Or add them to a curve with some bezier like interpolation to get a smooth graph without increasing the samples to much.
CodePudding user response:
thank you for the reply, I appreciate it. fl_chart package seems to be a good one, but then I will need something more complex, like semi logarithmic cartesian charts. I know how to do that, but I need a way to draw a decent smooth curve line. I have already used CustomPaint and CustomPainter with the method showed before. Interpolation sounds very interesting, but how to do that? I haven't seen functions for that yet... Thank you
