ツリーマップチャートの作成方法

可能な使用シナリオ

ツリーマップチャートは、データを階層ビューで表し、店舗の売れ筋商品などのパターンを簡単に把握できます。ツリーのブランチは長方形で表され、各サブブランチは小さな長方形として表示されます。ツリーマップチャートは、色と近接性でカテゴリを表示し、他のチャートタイプでは難しい大量のデータを簡単に表示できます。

todo:image_alt_text

ツリーマップチャート

以下のコードを実行すると、下記のツリーマップチャートが表示されます。

todo:image_alt_text

サンプルコード

下記のサンプルコードは、サンプルExcelファイルを読み込み、出力Excelファイルを生成します。

from aspose.cells import Workbook
from aspose.cells.charts import ChartType
from aspose.cells.drawing import FillType
# Create an instance of Workbook
workbook = Workbook("treemap.xlsx")
# Access the first worksheet
worksheet = workbook.worksheets[0]
# Add a Treemap chart
pieIdx = worksheet.charts.add(ChartType.TREEMAP, 5, 6, 20, 12)
# Retrieve the Chart object
chart = worksheet.charts[pieIdx]
# Set the legend can be showed
chart.show_legend = True
# Set the chart title name
chart.title.text = "TreeMap Chart"
# Add series data range(D2:D13,actually)
chart.n_series.add("D2:F13", True)
# Set category data(A2:A13 is incorrect )
chart.n_series.category_data = "A2:C13"
# Show the DataLabels with category names
chart.n_series[0].data_labels.show_category_name = True
# Fill the PlotArea area with nothing
chart.plot_area.area.fill_format.fill_type = FillType.NONE
# Save the Excel file
workbook.save("out.xlsx")