# Arguments for ChartElementFunction

I was reading the documentation for BubbleChart and I saw this example

DataDrilldownBubble[{{xmin_, xmax_}, {ymin_, ymax_}}, v_, {meta_}, style___] := PopupWindow[
Polygon[{{xmin, ymin}, {xmax, ymax}, {xmin, ymax}, {xmax, ymin}}], PieChart[meta]]

DataDrilldownBubble[{{xmin_, xmax_}, {ymin_, ymax_}}, y_, ___] := Rectangle[
{xmin, ymin}, {xmax, ymax}]

BubbleChart[{{1, 0, 1} -> Range[5], {0, 1, 2}, {1, 2, 3} -> RandomReal[1, 10]},


How exactly the ChartElementFunction works? Which arguments are passed to it?

In this answer the claim is that the arguments are [region, values, metadata]. The use of style___ in the documentation may suggest that there is another optional argument.

Is there an official documentation for that? How are exactly the metadata defined? The Mathematica help for ChartElementFunction is not very helpful here.

In the above examples metadata are given by the lists Range[5] and RandomReal[1, 10] respectively

-

EDIT

As per advice from Kuba, my answer was terse. Also see here re: an instructive use of DynamicWrapper by Kuba.

Here is a toy example for illustrative purposes:

data = {{{1, 2, 3} -> "apple", {2, 3, 4} -> "banana"} ->
"fruit", {{3, 4, 5} -> "celery"} -> "vegetable"};
va = "";
co["fruit"] := Red;
co["vegetable"] := Yellow;
g[___, {x_, y_, z_}, meta_] :=
DynamicWrapper[{co[First@meta], Disk[{x, y}, z/40]},
If[CurrentValue["MouseOver"],
va = Style[Row[{meta[[1]], ": ", meta[[2]]}], 12,
FontFamily -> "Kartika", Blue], va = ""]]
Column[{BubbleChart[data, ChartElementFunction -> g], Dynamic@va},
Alignment -> Center]


This follows the documentation for use of ChartElementFunction for BubbleChart. The structure of the data determines how the metadata is extracted. I wished to illustrate this with the toy example showing the relationship between data structure and ChartElementFunction. I hope this motivates more creative functions than my own.

-
You could add some explanation :) – Kuba Mar 8 '14 at 11:45
@Kuba you are correct. As you see I have started playing with DynamicWrapper exploiting your code from mathematica.stackexchange.com/a/43504/1997 – ubpdqn Mar 8 '14 at 12:09
I see :) I think OP (and me too) missed that in Details in Options there is a desctiption that form_i->m_i syntax is responsible for this what is a metadata. Maybe worth to stress it in the answer. – Kuba Mar 8 '14 at 12:20