IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 102 forks source link

Add labels to bar charts #6550

Open rdstern opened 3 years ago

rdstern commented 3 years ago

There is now a new version of the bar chart dialogue to be merged. It has 2 options for frequency and data.

There are 3 improvements to be added, namely back-to-back charts (including population pyramids as an example, pie and donut charts and labels

This issue discusses how to add texts (labels) as simply as possible. If flexibility is needed, then it should be possible by adding a label or text layer instead.

So, one key limitation here is that it simply adds what is in the bars. If a count, then it adds the count. If data, then it adds the data. If you want to get clever, say displaying counts and adding percents, then add the layer instead.

@volloholic is keen that it just does it, i.e. add labels checkbox and a single pull-down. (I suggest we may find we need at least 2 and probably 3 options.)

From examples I have seen, there are 3 aspects to consider. Position: Out, In, Middle Colour: Usually Black or White Size: Default, or Small or Large

So we might start with a single pull-down, where we have a single size of the labels, and 6 options, namely Out, In and Middle. The default bars are dark, so a text that's white os quite good when inside. Black is nice and clear when outside.

Here are some simple examples: image

So, when in or middle we use colour="white" and leave it with the default, namely black, when outside.

That's for data, for frequency we use ..count.., or stat(count) I understand is now more recommended. image

Sorting out a sensible vjust is going to be interesting! If that gets too tricky, then we use an up-down instead, with a tooltip to provide guidance. If so, perhaps call it Position and it can be negative.

I think the book makes a meal out of the stacked option, but adjusting the code for dodge will be important.

I wonder if we might consider adding a button for Label Options. (We have Bar chart options) It is disabled unless the Label Bars is ticked. Though it would do geom text, rather than geom label.

shadrackkibet commented 3 years ago

I will wait until PR #6561 is reviewed and merged then I will work on this.

maxwellfundi commented 2 years ago

@shadrackkibet now that #6561 was merged, this could be something you work with an @anastasia-mbithe ?

shadrackkibet commented 2 years ago

Yes sure, we will be working on it during the sprint.

anastasia-mbithe commented 2 years ago

@shadrackkibet, Can I take this over?

shadrackkibet commented 2 years ago

Yes, please.

N-thony commented 2 years ago

Yes, please.

@anastasia-mbithe how is it going with this? Any progress?