views:

552

answers:

1

How could I draw a straight line with the equation y=m*x+n in a jfreechart chart?

A: 

Sounds simple enough ... I've never used it, but there is a XYPlot class which sounds like a decent place to start. You can create one using the ChartFactory, to make it a bit easier. You will need to implement a class that implements the XYDataSet interface, to return the actual points (i.e. evalutate your equation).

unwind
By default XYPlot draws line(s) between the specified datapoints, so for a straight line you only need to specify two points. For instance (0, n) and (1, m+n).
Joonas Pulakka