+ Start a Discussion

Does anyone know/recognise the format of Apex Charts’ rendererFn javascript function?



In most chart related tags there is an attribute called rendererFn which is usually defined in the docs as “A string that specifies the name of a JavaScript function that augments or overrides how each data point is rendered. Implement to provide additional styling or to augment data.”


Well that’s nice. May be I am looking in the wrong place (or using the wrong search terms) but I can’t seem to find any documentation on the format required for these functions. There is one repeated code example that someone wrote (I think this is the original source, apologies to the author if not).


The thing I find fascinating is that in the Visualforce tag the attribute is written as rendererFn="renderer" yet the function definition has two parameters function renderer(klass, item).


I have tested this code and it fully works so the author is correct. Does anyone know where I can get the definition of klass and item and how to interact with them? Or can anyone with better Javascript knowledge make an educated guess? “item” allows you do access the data record values (e.g. var type = item.storeItem.get('ctype'); ). I have no idea how that works but it does and it is easy enough to modify for my own data structures. What other information can be pulled out of these variables?


My main goal is to be able to get more information about what item is being hovered over (actually clicked but regardless same problem). For instance, my chart has multiple lineSeries tags. I am wondering if through klass or item I can determine which particular lineSeries called the function (better than writing a separate script for each one).


Would be great if Salesforce was using a known Javascript java package that had documentation but I can't seem to find that either.


Any insights appreciated.