ukhsa-collaboration / fingertipscharts

11 stars 6 forks source link

Add value labels to the compare areas chart #6

Closed catriggwalk closed 5 years ago

catriggwalk commented 5 years ago

Would it be possible to add value labels to the "compare areas" chart? This would make the chart more like the "compare areas" view on the Fingertips site.

I have been able to add value labels by adding a rounded version of the "Value" to the df dataframe, named "Value_rounded" and then adding the the following at the end of the compare_areas() but this seems to make a mess of the key:

+geom_text(mapping = aes(label=df$Value_rounded, size=4, lineheight=1, hjust=2)

catriggwalk commented 5 years ago

I would still suggest the addition of labels to this chart as an enhancement for future consideration. Meanwhile, one of my local authority contacts worked out how to do this without making a mess of the key, by adding:

+geom_text(label=df$Value_rounded, nudge_y=-1)

sebastian-fox commented 5 years ago

Hi @DavidNphe - apologies, I don't think I've been getting notifications from this repo. Yes, this should be possible. I'll look to do this in the next release of the package.

sebastian-fox commented 5 years ago

I've added a display.values argument to compare_areas(). This is available in the dev version of the package if you want to start trying it out. (4daad99ca340fc45dc4aa7ed174e265014d465aa)

catriggwalk commented 5 years ago

Many thanks @sebastian-fox . I've checked this in the development version and it works.

Anyone who wants the values at the inside right end of the bars can still achieve this via the workaround that my GM colleague devised ie adding the following after compare_areas()

+geom_text(label=df$Value_rounded, nudge_y=-1) By the way, it took me about 25 minutes to install the development version using devtools. I kept getting error messages about being unable to remove existing versions of dependent packages. This was the case when I chose the option to update only CRAN packages or the option to update all. I kept restarting R to resolve this. I had to install some dependent packages manually ie by entering install.packages(...) This may be because I am not very good at keeping packages up to date. I tend to work on the "if it ain't bust don't fix/update it" approach. I doubt this will be a problem with the next production version but I thought it might be worth mentioning.

Thanks again, David