I am trying to create a chart for which yAxis is intended to display the number of employees, so it should only show integers.
But I didn’t find it as easy as I already tried yAxis.setTickUnit (1) , but it will not work when the values are small (etc. The maximum value is 3, it will still show 0.5.1, 5 ..., I only need a check mark, for example, 1,2,3,4 ..)
How could I achieve this?
According to @jewelsea's answer, I tried this (in javafx 2.2 jdk7)
class IntegerStringConverter extends StringConverter<Number>{
public IntegerStringConverter() {
}
@Override
public String toString(Number object) {
if(object.intValue()!=object.doubleValue())
return "";
return ""+(object.intValue());
}
@Override
public Number fromString(String string) {
Number val = Double.parseDouble(string);
return val.intValue();
}
}
This is an acceptable result. The double meaning has disappeared, but there is still there.
