0

In the javafx barchart, want to add two horizontal parallel lines originating from some point on y axis and possibly passing through the bars till the width of the x axis.

Sample Barchart

Dota2
  • 456
  • 4
  • 16
  • 1
    You can take a look on this: http://stackoverflow.com/questions/28952133/how-to-add-two-vertical-lines-with-javafx-linechart – DVarga Sep 06 '16 at 08:34
  • @James_D In javafx barchart, x axis is always category axis, so one cannot plot point 0,25, since there is no 0 on the x axis. Sample pic is basically line chart, do not fall for that. – Dota2 Sep 06 '16 at 13:58
  • It's exactly the same: the category axis still has a [`getDisplayPosition(...)`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/CategoryAxis.html#getDisplayPosition-java.lang.String-) method. Just pass in the first and last categories to get the coordinates of the ends of the axis. I haven't tested, but you might need to adjust each end by [`getStartMargin()`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/CategoryAxis.html#getStartMargin--) and [`getEndMargin()`](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/CategoryAxis.html#getEndMargin--). – James_D Sep 06 '16 at 14:12
  • @James_D getDisplayPosition(String) gives 0.0 if passed a value from categorical axis, therefore fails to plot it. Same issue addressed here. http://stackoverflow.com/questions/39287063/javafx-charts-setting-origin-point-on-category-axis – Dota2 Sep 07 '16 at 06:18
  • That's not what is implied by the [documentation](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/chart/CategoryAxis.html#getDisplayPosition-java.lang.String-), and it works fine for me. If it doesn't work for you, [edit] your question to include a [MCVE]. As your question currently stands, it is fully answered in the link I provided. – James_D Sep 07 '16 at 11:59
  • Maybe http://stackoverflow.com/questions/38871202/how-to-add-shapes-on-javafx-linechart would have been a better duplicate... – James_D Sep 07 '16 at 12:22

0 Answers0