0

I recently discovered highcharts, and I really like the dynamic aspect of the pie charts. However, I am having trouble finding a good way to group my charts together. The code below is investigating gaming console distribution per gender, and I would like all 3 pie charts to be aligned, with a larger pie chart above them that breaks down total console distribution, but I am unable to find anything that works.

# For larger platform pie chart
platform <- gaming_survey %>% 
  count(Platform, sort = TRUE) %>%
  rename(Count = n)

# For gender based pie charts
platform_gender <- gaming_survey %>% 
  count(Platform, Gender, sort = TRUE) %>%
  rename(Count = n)

# The 4 pie charts I am trying to group into one display
platform %>% 
  hchart('pie', hcaes(x = Platform, y = Count)) %>% 
  hc_title(text = 'Gaming Platform Distribution',
           style = list(fontSize = '30px'),
           align = 'center') %>% 
  hc_tooltip(pointFormat = '<b>Total:</b> {point.y} <br>
                 <b>Percentage</b> {point.percentage:,.1f}%') %>% 
  hc_credits(
    enabled = TRUE, 
    text = 'Source: <em>Online Gaming Anxiety Data </em> || Kaggle.com',
    style = list(fontSize = '15px', color = 'black',type = 'spline')
  ) 


platform_gender %>%
  subset(Gender == 'Female', select = c(Platform, Count)) %>% 
  hchart('pie', hcaes(x = Platform, y = Count)) %>% 
  hc_title(text = 'Female Platform Distribution',
           style = list(fontSize = '30px'),
           align = 'center') %>% 
  hc_tooltip(pointFormat = '<b>Total:</b> {point.y} <br>
                 <b>Percentage</b> {point.percentage:,.1f}%') %>% 
  hc_credits(
    enabled = TRUE, 
    text = 'Source: <em>Online Gaming Anxiety Data </em> || Kaggle.com',
    style = list(fontSize = '15px', color = 'black',type = 'spline')
  )
platform_gender %>% 
  subset(Gender == 'Male', select = c(Platform, Count)) %>% 
  hchart('pie', hcaes(x = Platform, y = Count)) %>% 
  hc_title(text = 'Male Platform Distribution',
           style = list(fontSize = '30px'),
           align = 'center') %>% 
  hc_tooltip(pointFormat = '<b>Total:</b> {point.y} <br>
                 <b>Percentage</b> {point.percentage:,.1f}%') %>% 
  hc_credits(
    enabled = TRUE, 
    text = 'Source: <em>Online Gaming Anxiety Data </em> || Kaggle.com',
    style = list(fontSize = '15px', color = 'black',type = 'spline')
  )
platform_gender %>% 
  subset(Gender == 'Other', select = c(Platform, Count)) %>% 
  hchart('pie', hcaes(x = Platform, y = Count)) %>% 
  hc_title(text = 'Other Platform Distribution',
           style = list(fontSize = '30px'),
           align = 'center') %>% 
  hc_tooltip(pointFormat = '<b>Total:</b> {point.y} <br>
                 <b>Percentage</b> {point.percentage:,.1f}%') %>% 
  hc_credits(
    enabled = TRUE, 
    text = 'Source: <em>Online Gaming Anxiety Data </em> || Kaggle.com',
    style = list(fontSize = '15px', color = 'black',type = 'spline')
  )

I am very new R, so forgive me if I am using any confusing wording. Thanks.

iRevan
  • 53
  • 4
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Since we can't run your code, we really have no idea what you are looking at or what you want. – MrFlick Feb 15 '22 at 06:36

0 Answers0