plotters icon indicating copy to clipboard operation
plotters copied to clipboard

More shorthand functions and ergonomics

Open kangalio opened this issue 5 years ago • 3 comments
trafficstars

What is the feature ?

I'm trying out this library for the first time and there's some places where it would be delightful to have shorthand functions:

  1. Shorthand functions for Pos: Pos::top_right, Pos::bottom_right, Pos::bottom_center etc..
  2. Short way to set colors for components. Currently, lots of boilerplate is required for e.g. white-on-black plotos
    • a cool start would be to have IntoTextStyle implementation for (FontFamily, T, RGBAColor)
  3. A direct way to create an RGBAColor
  4. A more sensible default font size than one pixel see here
  5. Common trait derives for RGBColor, i.e. Copy, Clone, Eq, PartialEq, Default, Hash
  6. From<RGBColor> impl for RGBAColor
  7. Expose BitMapBackendError to allow handling those errors

Why this feature is useful and how people would use the feature ?

More shorthand functions and ergonomics are always good, I think

kangalio avatar Jul 21 '20 21:07 kangalio

Thanks for the suggestions and sorry for the delay. I haven't got a chance to look at the issue since a few month ago.

Most of suggestion seems really helpful, but I would like to understand more about few things:

1. Shorthand functions for Pos: `Pos::top_right`, `Pos::bottom_right`, `Pos::bottom_center` etc..

What is this particularly for ? Since we have positioning enums used in both ChartBuilder and legends, which one are you referring or both?

Thanks!

38 avatar Aug 28 '20 23:08 38

Just put the items here for tracking purposes.

  • [x] Short way to set colors for components: e.g. IntoTextStyle implementation for (FontFamily, T, RGBAColor)

  • [x] A direct way to create an RGBAColor

  • [x] Default font size? (This might be a chance to revisit #73 )

  • [x] RGBColor should impl more traits

  • [x] From<RGBColor> for RGBAColor

  • [x] BitmapBackendError visibility

38 avatar Aug 29 '20 00:08 38

1. Shorthand functions for Pos: `Pos::top_right`, `Pos::bottom_right`, `Pos::bottom_center` etc..

What is this particularly for ? Since we have positioning enums used in both ChartBuilder and legends, which one are you referring or both?

Looking back at it, I think I had in mind a shorthand for Pos::new(HPos::XXX, VPos::XXX). So,

  • Pos::new(HPos::Center, VPos::Center) => Pos::Center
  • Pos::new(HPos::Top, VPos::Right) => Pos::TopRight

Something like that. On second thought, I'm not sure if this would be worth it.

Also, please excuse my tone in the first message I posted. I was in a bad mood and wanted to show it, sorry

kangalio avatar Aug 29 '20 07:08 kangalio

I am not sure what is meant by "Expose BitMapBackendError to allow handling those errors". The error seems already publicly exposed.

antglb avatar Sep 02 '22 16:09 antglb

Oh now it apparently is

It wasn't in 0.3.1 https://docs.rs/plotters-bitmap/0.3.1/plotters_bitmap/?search=BitMapBackendError

Would be nice to add this to the 0.3.2 changelog

kangalio avatar Sep 03 '22 18:09 kangalio

I think the list is complete now. Feel free to close this issue or comment if something is still missing :)

AaronErhardt avatar Sep 05 '22 19:09 AaronErhardt