eclipse / swtchart

Eclipse Public License 2.0
44 stars 41 forks source link

Handle axis formatters that are lossy (Major vs Minor ticks) #214

Closed MatthewKhouzam closed 4 years ago

MatthewKhouzam commented 4 years ago

Currently the implementation of swtchart looks to see if value -> formatted -> returned == value in order to determine if a value is a major tick (and thus shown) leads to unexpected behaviors when the formatter truncates decimals.

We use it in trace compass, and the Y axis does not display all the time for values divided by 1024 rather than 1000. The results are therefore a bit odd. See pic below

Memory Usage

I don't have a solution to propose yet.

1- we could have an API to say : No minor ticks 2- we could have an API to state if a tick is minor 3- we could give a precision to the double compare (I like this one personally) 4- other more robust and correct solution I didn't think about yet.

MatthewKhouzam commented 4 years ago

I put up a patch that fixes the issue, but I am not sure if it is inline with the swtchart way of working. :)

eselmeister commented 4 years ago

@MatthewKhouzam SWTChart allows to add secondary axes. A secondary axis requires a converter, e.g. to convert from the base value Kilobyte to the secondary value Kibibyte. I'm just back from a business trip. I'll review your issue the next days.

eselmeister commented 4 years ago

@MatthewKhouzam I've added a demo. It shows how to use a secondary axis. org.eclipse.swtchart.extensions.examples.charts.SecondaryAxisChart

You can place the axis either on secondary position (right) or primary position (left). The primary axis can be also set to visible = false.

Bildschirmfoto von 2020-08-03 10-16-38

Does this match your requirements?

eselmeister commented 4 years ago

You can simply run the demo from within Eclipse as a Java application.

eselmeister commented 4 years ago

Patch merged into develop.