0

I am using LineGraph to draw datapoints and then creating curves. The X,Y axis lowest datapoints are allways 0 but the symbol gets cut off like in picture #1. I need it to look more like picture #2, where you can see the whole datapoint but I need the X,Y axis tickmarks to only start at 0 and ignore the values below 0. Is this even possible with LineGraph.

Picture #1

picture#1

Picture #2

picture#2

This is how I am setting the values:

    xAxis.setUpperBound(maxTime);
    xAxis.setLowerBound(minX - (maxTime * 0.01));
    xAxis.setTickUnit(xAxis.getUpperBound() * 0.333 - ((maxTime * 0.01)));

    yAxis.setUpperBound(maxActivity);
    yAxis.setTickUnit(maxActivity / 4);
    yAxis.setLowerBound(minY - (maxActivity * 0.05));

But then the tickmarks will start from the calculated values of the lower bounds instead of at 0

James_D
  • 201,275
  • 16
  • 291
  • 322
  • 1
    set the range of the axis explicitly (and remember: the api doc is your friend :) – kleopatra Aug 09 '20 at 13:28
  • @kleopatra i editted my post to show what i have it set as – Shane Andrews Aug 09 '20 at 14:02
  • 1
    Can you post a [mre] demonstrating the issue? In theory you can override the `calculateTickMarks()` method, if necessary, but the [documentation](https://openjfx.io/javadoc/14/javafx.controls/javafx/scene/chart/NumberAxis.html#calculateTickValues(double,java.lang.Object)) is vague (that's being kind), and you'd almost certainly have to dig into the [source code](https://github.com/openjdk/jfx/tree/master/modules/javafx.controls/src/main/java/javafx/scene/chart) to figure out how to do that. – James_D Aug 09 '20 at 14:25
  • That said, try setting the tick unit to an integer value; that may fix it. – James_D Aug 09 '20 at 14:29
  • still not quite understand: do you want "pretty" tickmarks (like every 10 or so) and at the same time the x-value starting "before" the prettified 0? – kleopatra Aug 09 '20 at 15:57
  • @kleopatra As I understand it, the requirement is that the axes should start a little before zero, to give some "breathing room" around the first data point, but that the first tick mark should be zero. It's undocumented, but making the tick unit an integer should at least [have a similar result](https://github.com/openjdk/jfx/blob/af000b285a328f89258a699292e2ea245cf73cf6/modules/javafx.controls/src/main/java/javafx/scene/chart/NumberAxis.java#L247). – James_D Aug 09 '20 at 16:53
  • @kleopatra no the tickmarks will be (max number / 4) but i want it to start at 0. And if you look at picture #2 it is like -.3. b/c thats the lowest number(for being able to display the full datapoint of 0 on the graph). basically im trying to find a way to ignore anything below 0 and show 0 tickmark, max number tic mark with 3 tick marks in between – Shane Andrews Aug 09 '20 at 17:28
  • @James_D, the problem with using integer. Is that alot of the times there is alot of data points between 0 and 1. Like these for example--0.0000089678 – Shane Andrews Aug 09 '20 at 17:35
  • For that specific requirement, I think you need to subclass `NumberAxis` and override `calculateTickMarks()` – James_D Aug 09 '20 at 17:35
  • @kleopatra, James_D. Thank you both i found something that kleopatra actually commented on couple of years ago. That will most likely work for what i need just a little editing required to match my requirements. Solution here https://stackoverflow.com/questions/49462938/javafx-manually-set-numberaxis-ticks – Shane Andrews Aug 09 '20 at 18:49

0 Answers0