Closed happyshows closed 6 years ago
Hi,
Probleme solved, we have adapt legend contol in amOptions :
data(data_bar)
amBarplot(x = "country", y = "visits", data = data_bar, labelRotation = -45, legend = TRUE)
amBarplot(x = "country", y = "visits", data = data_bar[1,], labelRotation = -45, legend = TRUE)
data_bar$color <- NULL
amBarplot(x = "country", y = "visits", data = data_bar, labelRotation = -45, legend = TRUE, groups_color = "#FF0000")
amBarplot(x = "country", y = "visits", data = data_bar[1,], labelRotation = -45, legend = TRUE, groups_color = "#FF0000")
To adapt group name, you can use :
data_bar$description = "test" amBarplot(x = "country", y = "visits", data = data_bar[1,], labelRotation = -45, legend = TRUE, groups_color = "#FF0000")
Regards, Titouan
@TitouanRobert Thanks, the legend color portion is fixed. However if I just want change the label on legend section to 'test'(instead of the hover over text on bar) what should I do then?
You can change column name legend section is based on column name,
data_bar$Mylegend <- data_bar$country amBarplot(x = "Mylegend", y = "visits", data = data_bar[1,], labelRotation = -45, legend = TRUE)
Regards, Titouan
Actually let me use this example:
library(dplyr) library(rAmCharts) data("data_bar") dat <- data_bar %>% select(country,visits) %>% mutate(enter = visits*0.9)
amBarplot(x = 'country',y = c('visits','enter'), data = dat, legend = TRUE)
When I have two y axis (which is my expectation), I saw two measures in legend section. However when I switch to one y axis, the legend began to plot against the x axis.
amBarplot(x = 'country',y = 'visits', data = dat, legend = TRUE)
based on current setup, I will have to transform the data set to make it work: dat2 <- data_bar %>% mutate(color = '#FF6600') %>% rename(qty = visits,visits = country) amBarplot(x = 'visits',y = 'qty', data = dat2, legend = TRUE)
Should I be expected to do such transformation?
The reason I asked for this is the end user has no knowledge about the dataset and they just use R shiny app to explore with data. They expect the color and format to be identical. So if the 'enter' measure is gone and visits is the only quantitative measure, it should follow the dat2 format.
Hi, package just has been updated. Could you try it now ?
@ElenaDatak I just updated the package. My problem still remain the same.
I'd like to use amBarplot to color different measures. and when the # of quantitative measures > 1, behavior is aligned with my expectation. However when there's only one measure in y argument, it seems the barplot switch to x argument for its legend.
Does it answer to your question ? amBarplot(x = "country", y = "visits", data = data_bar[1,], labelRotation = -45, legend = TRUE, legendPosition = "right")
If not please provide an illustrated example
I thought I already explained in previous post which has 3 images. I am expecting the number 3 to show up but only got number 2 if the # of factors on y axis reduced to 1. I still want to visualize all records not just the first row of data.
In addition, the color legend will be wrong if I use the setLegend approach not legend = TRUE inside amOptions.
amBarplot(x=c('Quarter'),y= nms, data = dat,labelRotation = 90,groups_color = customColor) %>% amOptions(export = TRUE,legend=TRUE, creditsPosition = 'bottom-right')
amBarplot(x=c('Quarter'),y= nms, data = dat,labelRotation = 90,groups_color = customColor) %>% amOptions(export = TRUE,creditsPosition = 'bottom-right') %>% setLegend(position = 'bottom')
Last point is not a bug.
Using setLegend
, you use directly the amChart
API. So you have find the way to have the legend you want, and as you can see, it can be difficult with amChart
.
Using simple amFunction, like amBarplot
, and amOptions
, we try to do our best to build legend for the user, as well as possible and for the most of graphics. It's really a long job.
Data Quarter QTY Y16Q01 8000
amBarplot(x=c('Quarter'),y= 'QTY', data = dat, groups_color = '#00A73C') %>% amOptions(legend = TRUE)
I don't know if it's happening in other chart types, but it's wrong in barplot. In addition, when you hover over the bar, the group name (supposedly QTY) is missing.