HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
687 stars 129 forks source link

Max value cannot be set with large values #206

Closed NeslihanKolukisa closed 3 years ago

NeslihanKolukisa commented 3 years ago

Max value cannot be set with large values. As an example, I give the number 21055406.

HanSolo commented 3 years ago

It would have been helpful to get a little code snippet that shows the problem because it seems that the issue is dependent on the skin that you use. So it looks like for the Gauge skin it has problems. Will look into that. Thanks for the heads up.

HanSolo commented 3 years ago

The problem is related to the tickmarks and the major- and minor tickspace. You can imagine that if you create tickmarks and labels for every 10th number from 0 - 21055406 the library has to draw a lot of tickmarks and ticklabels which is the reason for the problem. There are different ways to face this problem, first thing I would do with such large numbers, I would ask myself if I need to have them in all detail or if it won't be enough to for example divide the values by 10000 before I pass them to the gauge. If the gauge has a size of 400x400px you won't be able to visual determine the difference between values in the range of 1000. The other approach would be to adjust the major- and minor tickspace according to your values. The following code works with the large number you mentioned:

        gauge = GaugeBuilder.create()
                            .skinType(SkinType.GAUGE)
                            .prefSize(400, 400)
                            .decimals(0)
                            .maxValue(21055406)
                            .majorTickSpace(100000)
                            .minorTickSpace(10000)
                            .tickLabelsVisible(false)
                            .minorTickMarksVisible(false)
                            .mediumTickMarksVisible(false)
                            .autoScale(false)
                            .animated(true)
                            .build();