title: Algorithm for self-scaling ruler in plotter GUI component
body: <p>I am designing (not programming) a data-series viewer program for medical data, using C#/WPF. There is one main panel which shows the data, with the common mouse pan/zoom functionality (pan with left drag, horizontal zoom with scroll, vertical auto-fit with double click, selection with right drag).</p>
  
  <p>The problem is: I need vertical and horizontal grid with rulers on the top/left, similar to those seen in audio-editing (goldwave, audacity), cartography (gpsTrackmaker) and ilustration (photoshop, inkscape) programs. Besides, these rulers are even configurable in most plotting APIs (Matlab, GNUPlot, Matplotlib) and even office programs (Excel, Calc).</p>
  
  <p>The main requisite, besides being always aligned and scaled to content, is to have an "anti-clutter" algorithm which only draws tick labels with the maximum granularity possible without the labels "hitting" or hiding one another.</p>
  
  <p>Below is an image showing two zoom levels of the same drawing on Inkscape. The first row shows each hundred labels. The second row shows each decade labels.</p>
  
  <p>The question is: "Since this (the auto-resolution of viewing rulers) seems to be a solved problem in many programs, how should I look for / what are the available resouces/tutorials so I can specify and implement such a control that suits my needs?"</p>
  
  <p>I would appreciate any suggestion or example, preferrably in C#, but could be in any language.</p>
  
  <p><img src="https://i.stack.imgur.com/ycyM6.png" alt="enter image description here"></p>