0

I would like to present a chart in my LWC with both absolute value and percentage. This can be easily achieved if data is exported to Google Docs and then Google Chart is created from the data. There is similar Google Charts JS library, however, it is incompatible with Lightning Security Locker https://github.com/google/google-visualization-issues/issues/2962

I tried to add Visualforce Charts to FlexiPage containing LWC, however, it doesn't work good, since:

  1. This is a real pain to embed a Visualforce inside FlexiPage (it is not alighed correctly and cannot be scaled).
  2. Still, it is possible only to present either absolute number values of percentage, but not both.
  3. It doesn't look good

I know that there is some alternate Charts Library for Salesforce, but still it is possible only to present either absolute number values of percentage, but not both.

Is there any way to embed Google Charts in LWC or is there any other library to display both values and percentage of total like Google Charts does?

2
  • Have you taken a look at d3js? It's more functional than Visualforce charts, and can probably generate the type of chart you're looking for, and definitely works in lwc. Alternatively, you could always just write your own chart if you don't need all the bells and whistles. You can use both canvas and svg in LWC.
    – sfdcfox
    Aug 2, 2022 at 4:23
  • I can see d3js supports labels with lines bl.ocks.org/dbuezas/9306799, need to check if it supports percentage
    – Patlatus
    Aug 2, 2022 at 7:15

0

You must log in to answer this question.