Hello colleague,
i wrote in a similar discussion about the concept of a hit-map, that
records the painting of objects internally (no on screen) and can be used
to look up an object identifier by screen coordinates. Yesterday i looked
around a little bit in libcairo for some internals to get help on this (e.g
copy_path, context.in_fill). This might be a good option for scattered data
points. For 'simple' line plots i think that searching the data for
nearests point could be easier and low overhead. In any case this needs to
be tuned for the actual situation.