I would like to allow a user to manipulate the segments of a pie-chart, which is to be generated from a list of a specific format.
The code looks something like the following:
pieChartList = {
{category1, 1},
{category2, 2}
};
generatePieChart[dataList_List, plotLabel_String] :=
Manipulate[
PieChart[
{category1, category2},
PlotLabel -> plotLabel
],
{{category1, 1}, 0, 10}, {{category2, 2}, 0, 10}
];
generatePieChart[pieChartList, "Test pie chart"]
As you can see, the lists are being written "manually," even though pieChartList
contains all the information to generate the necessary structures. Is there an elegant way to generate the manipulation list automatically? In other words, if I were to add {category3, 3}
to pieChartList
, the function generatePieChart
should pick up the new value automatically.
Thanks in advance for your help.