Comments (3)
Hi!
So there is no option to place the labels at different position, but you can use a JavaScript callback (warning you cannot select an axis by names, e.g. "Speed", only by position, see the arrow in JS function) :
library("billboarder")
library("dplyr")
data("avengers")
avengersSub <- avengers %>%
filter(group == 'Thor') %>%
filter(axis %in% c('Durability','Speed','Energy'))
bb <- billboarder() %>%
bb_radarchart(
data = avengersSub,
mapping = bbaes(x = axis, y = value, group = group)
) %>%
bb_radar(level = list(show = FALSE)) %>%
bb_data(
labels = TRUE # list(position = list(x = 10))
)
bb$x$bb_opts$onrendered <- htmlwidgets::JS(
"function() {
// Durability
d3.selectAll('.bb-texts .bb-text-1').each(function() { // <<<<<-------- Durability is 'bb-text-1' (only for this chart)
var text = d3.select(this);
text.attr('x', (+text.attr('x') - 10)).attr('y', (+text.attr('y') + 20))
});
// Energy
d3.selectAll('.bb-texts .bb-text-2').each(function() { // <<<<<-------- Energy is 'bb-text-2' (only for this chart)
var text = d3.select(this);
text.attr('x', (+text.attr('x') + 10)).attr('y', (+text.attr('y') + 20))
});
}"
)
bb
Victor
from billboarder.
Victor,
Thank you for your help. The provided code serves the purpose perfectly.
Regards,
André
from billboarder.
I added a function to use callbacks, so with dev version you can add the onrendered
func in the pipe workflow :
billboarder() %>%
bb_radarchart(
data = avengersSub,
mapping = bbaes(x = axis, y = value, group = group)
) %>%
bb_radar(level = list(show = FALSE)) %>%
bb_data(
labels = TRUE # list(position = list(x = 10))
) %>%
bb_callbacks(
onrendered = "function() {
// Durability
d3.selectAll('.bb-texts .bb-text-1').each(function() { // <<<<<-------- Durability is 'bb-text-1' (only for this chart)
var text = d3.select(this);
text.attr('x', (+text.attr('x') - 10)).attr('y', (+text.attr('y') + 20))
});
// Energy
d3.selectAll('.bb-texts .bb-text-2').each(function() { // <<<<<-------- Energy is 'bb-text-2' (only for this chart)
var text = d3.select(this);
text.attr('x', (+text.attr('x') + 10)).attr('y', (+text.attr('y') + 20))
});
}"
)
Victor
from billboarder.
Related Issues (20)
- download HOT 8
- using different line type HOT 1
- updated billboarder 2.7 HOT 12
- Tooltip does not appear when linked between charts HOT 3
- After installing newer version of R 3-6 Billboarder donut chart is not showing both in shiny and Rmarkdown HOT 2
- Lower part of caption is cut HOT 2
- Double Click HOT 4
- BarChart/lines with errors
- Customize text font HOT 2
- Combination chart (bar + line) HOT 2
- Scatterplot with region & custom tooltip HOT 1
- Possible bug / conflict with line ranges HOT 4
- Hover Possible? HOT 4
- Stacked Barchart with Customizations
- shinymanager logs graphics not showing HOT 3
- legend in RMarkdown
- Scatterplot in which the grouping variable takes more than 4 different values does not work HOT 2
- Charts not being loaded using flexdashboard and rmarkdown (>= 1.11) HOT 2
- Would u mind posting an example of a rotated axis groupd bar chart? HOT 2
- Treemap with nested categories HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from billboarder.