New in Wolfram Mathematica 7: Automated Charting Graphics  previous | next 
Use Tooltips for Easy Drilldown through Data
In[1]:=

Click for copyable input
portfolioData["Technology"] = {"AAPL", "MSFT", "GOOG", "INTC", "CSCO"};

portfolioData["Banking"] = {"JPM", "BAC", "GS", "WFC", "C"};

portfolioData["Food"] = {"MCD", "PEP", "DEO", "HNZ", "GIS"};

portfolioData["Drugs"] = {"MRK", "PFE", "GSK", "SGP", "TEVA"};

portfolioData["Oil"] = {"XOM", "COP", "OXY", "SLB", "RIG"};

sectors = {"Banking", "Technology", "Food", "Drugs", "Oil"};
In[2]:=

Click for copyable input
portfolioData["MarketCap"] = 0;

Function[{sector}, 

   portfolioData[

     "MarketCap"] += (portfolioData[sector, "MarketCap"] = 

      Total[FinancialData[#, "MarketCap"] & /@ 

        portfolioData[sector]])] /@ sectors;
In[3]:=

Click for copyable input
labelStyle[label_] := Style[label, 12, FontFamily -> "Helvetica"]
In[4]:=

Click for copyable input
drilldown[sector_] := 

 PieChart[FinancialData[#, "MarketCap"] & /@ portfolioData[sector], 

  ChartStyle -> 46, 

  ChartLabels -> labelStyle /@ portfolioData[sector], 

  ChartElementFunction -> "PlateauSector"]
In[5]:=

Click for copyable input
chartOptions = {ChartStyle -> "FallColors", 

   ChartLabels -> labelStyle /@ sectors, 

   SectorOrigin -> {{0, 1}, 0.5}, ImageSize -> 500, 

   PlotLabel -> 

    Style["Portfolio Market Capitalization", 

     FontFamily -> "Helvetica", 14], 

   ChartElementFunction -> 

    ChartElementDataFunction["ProfileSector3D", "Profile" -> 5]};
In[6]:=

Click for copyable input
PieChart3D[

  Tooltip[portfolioData[#, "MarketCap"], drilldown[#]] & /@ sectors, 

  chartOptions];
Out[7]=