範例 共 2 個步驟,在同一個工作階段中依序執行。每一步都在引擎上實際執行過,下方的輸出就是它產生的結果。
countries = CountryData["G7"];
gdp = CountryData[#, {"GDP", 2020}]& /@ countries;gdpPerCapita = CountryData[#, {"GDPPerCapita", 2020}]& /@ countries;population = CountryData[#, {"Population", 2020}]& /@ countries;data = Transpose[{population, gdpPerCapita}];dollarForm[a_Real] := Row[{"$", NumberForm[a, {10, 2}, NumberPadding -> {"", "0"}]}]
dollarForm[q_Quantity] := dollarForm[QuantityMagnitude[q]]沒有輸出——這個步驟是在為下一步做準備。
SectorChart[data, SectorOrigin -> {Automatic, 15000}, LabelingFunction -> (Placed[#, Tooltip, Style[Column[{Row[{"GDP: ", dollarForm[First@# * Last@#]}], Row[{"Population: ", NumberForm[First@#, {10, 2}, NumberPadding -> {"", "0"}]}], Row[{"GDP Per Capita: ", dollarForm[First@#]}]}, Alignment -> {Left, Bottom}, Frame -> True], 14, FontFamily -> "Helvetica"]&]&), ChartStyle -> 2, ChartLabels -> Placed[countries, "RadialCallout", Style[#, 12, FontFamily -> "Helvetica", Darker@Brown]&], PlotLabel -> Style["Visualizing GDP for the G7 Countries", 14, Bold, FontFamily -> "Helvetica", Darker@Brown], PlotRange -> All, ChartLegends -> Placed[gdp, Right, Style[dollarForm[#], FontFamily -> "Helvetica"]&]]-Graphics-所有操作範例 · 函式參考 · 從 MCP 用戶端使用這個