0

I created a highchart and hope to pass the point information (name, description etc...) into another function. However I can't seem to find a way to access the point name. Below is my current attempt.

  # Generate chart
  
  highchart() %>%
    hc_chart(type = 'organization', inverted = TRUE) %>%
    hc_title(text = sprintf('%s Org Chart', chartName)) %>%
    hc_add_series(
      name = chartName,
      data = hierarchyList,
      nodes = nodeList,
      colorByPoint = FALSE,
      color = '#D6E8F3',
      dataLabels = list(color = 'black', 
                        nodeFormat = getNodeFormat("{point.image}", "{point.name}", "{point.title}", "{point.description}", ...), 
      borderColor = 'white',
      nodeWidth = 190
    ) %>%
    hc_tooltip(outside = TRUE)
}


getNodeFormat <- function(image, name, title, description...) {
    ... #more codes here
}

In the getNodeFormat function, there are other computations and data accessing that requires the actual name string of the point. However, when I try to print out name in getNodeFormat, it displays "{point.name}" instead of the actual name of the point.

Other attempts instead of "{point.name}" are point.name, and {point.name}. None of them worked and the error stated "object not found".

Is there a way where I can access the point information directly? Any help will be appreciated!

cel-0207
  • 31
  • 7
  • Use dataLabels.nodeFormatter (there you will pull out these options and arrange them as you like): https://api.highcharts.com/highcharts/series.sankey.dataLabels.nodeFormatter – madepiet May 31 '22 at 09:40
  • If what @madepiet provided doesn't help, it would probably be a good idea to make your question reproducible. This includes sample data like the output from `dput(head(dataObject))` or `dput(dataObject)`. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat May 31 '22 at 14:51

0 Answers0