poloto-project icon indicating copy to clipboard operation
poloto-project copied to clipboard

Add annotation API

Open tiby312 opened this issue 3 years ago • 1 comments

Something like this:

use poloto::build;
// PIPE me to a file!
fn main() {
    let data = vec![[0, 0], [1, 2], [2, 3]];

    let a = build::plot("label").line(data);

    poloto::data(a)
        .build_and_label(("hello world", "x", "y"))
        .annotate(|w|{
            let point=w.convert_point([1,2]);
            
            let circle=hypermelon::build::elem("circle").with(attrs!(("x",point.x),("y",point.y)))

            let text_pos=w.request_text_position();

            let text=hypermelon::build::elem("text").with(attrs!(("x",text_pos.x),("y",text_pos.y)))

            circle.append(text)
        })
        .append_to(poloto::header().light_theme())
        .render_stdout();
}

tiby312 avatar Nov 30 '22 00:11 tiby312

Or at-least just provide a projection matrix that you can feed data points, and have the point in the svg canvas space.

tiby312 avatar Jan 20 '23 14:01 tiby312