I am using R Shiny to visualize data as some pie charts using Plotly package. The problem is that I would like to re-size the pie charts and navigate them horizontally not vertically, picture is shown below.
I will appreciate for helps experts!
Here is the code
#UI part
dashboardBody(
fluidRow(
plotlyOutput("PieDistribution"),
plotlyOutput("PieHealth")
)
#server part
output$PieDistribution <- renderPlotly({
plot_ly(PD, labels = ~PD$VP, values = ~PD$V1, type = 'pie',
textposition = 'inside',
textinfo = 'percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~paste(PD$VP),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1))) %>%
layout(title = 'Project Distribution by Vice President',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
showlegend = FALSE,
legend = list(x = 50, y = 0.5))
})
output$PieHealth <- renderPlotly({
plot_ly(PD2, labels = ~PD2$HealthName, values = ~PD2$V1, type = 'pie',
textposition = 'inside',
textinfo = 'percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~paste(PD2$HealthName),
marker = list(colors = c('#229954', '#d32f2f','#ffc107'),
line = list(color = '#FFFFFF', width = 1))) %>%
layout(title = "Project Health",
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
showlegend = FALSE)
})
Create new columns within fluidrow in your ui. Something like:
fluidRow(column(6,
plotlyOutput("PieDistribution")),
column(6,
plotlyOutput("PieHealth"))
)