plotters icon indicating copy to clipboard operation
plotters copied to clipboard

Can I add text in the graph?

Open baiguoname opened this issue 1 year ago • 2 comments

I tried add a multi lines text in the graph, but the text can only shown in one line, like this: pub fn plot_test() -> evcxr::SVGWrapper { evcxr_figure((500, 500), |root| { root.fill(&WHITE)?; let te = Text::new(format!("a \n b"), (40, 20), ("sans-serif", 15.0).into_font()); root.draw(&te)?; Ok(()) }) }

图片 As can be seen in the above figure, the "\n" between a and b does not work.

baiguoname avatar May 30 '23 13:05 baiguoname

If you know exactly where you want to put the text, you could draw the chart to a buffer, drop the chart, then pass the buffer directly into skia_safe and draw the text from there

matteopolak avatar Jun 03 '23 04:06 matteopolak

There is a MultiLineText, which can show a multiline string. I mean you need to call MultiLineText::push_line() multiple times to push your lines into it one by one.

AliMMehr avatar Nov 06 '23 08:11 AliMMehr