Algorithm for self-scaling ruler in plotter GUI component

隐身守侯 提交于 2019-12-04 13:59:44
  • W = visible protion of the ruler
  • X = range (right-left) represented by W
  • w = label width

n = W/w (maximum number of labels you can display)

x = X*w/W (minimal range between two labels)

Then you have to round x to some larger, cooler value 1, 2 or 5 in any magnitude.

For example

  • x=18.4 => x1=20
  • x=539 => x1=1000

w1 = x1/X*W (label width, or space between ticks)

n1 = W/w1 (number of ticks)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!