Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]}, 
            ChartElementFunction -> DataDrilldownBubble]

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

share|improve this question


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]}, 
   va = Style[Row[{meta[[1]], ": ", meta[[2]]}], 12, 
     FontFamily -> "Kartika", Blue], va = ""]]
Column[{BubbleChart[data, ChartElementFunction -> g], Dynamic@va}, 
 Alignment -> Center]

enter image description here

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.

share|improve this answer
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 – 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.