kivy-garden / graph

Displays plots on a graph.
MIT License
50 stars 18 forks source link

Implement 'unit' property #34

Open Matrx007 opened 2 years ago

Matrx007 commented 2 years ago

Implementing x-axis units. This PR also solves issue (feature-request) #13.

Description: The new 'unit' property determines the unit of x-axis values. The distance between the tick marks is divided by this number. Settings this to 0 will work as if it was set to 1, to avoid division by 0. Negative numbers are allowed.

For example, setting this and x_ticks_major to 60 will display x-axis ticks in minutes (by dividing major ticks by 60), assuming that data rate is once per second.

Use case: At the moment, when data is fed into a graph 20 times per second, the best way to make it readable is to set x_ticks_major to 20, so that every vertical grid line represents one second. The x-axis labels are multiples of 20 though, which is confusing to end-users.

Settings the new 'unit' property to 20 in that case will divide the x-axis labels by 20, therefore making it more understandable to the end-user.