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

可能な使用シナリオ

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

todo:image_alt_text

ツリーマップチャート

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

todo:image_alt_text

サンプルコード

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

// Create an instance of Workbook
Workbook workbook = new Workbook("treemap.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Add a Treemap chart
int pieIdx = worksheet.Charts.Add(ChartType.Treemap, 5, 6, 20, 12);
// Retrieve the Chart object
Chart chart = worksheet.Charts[pieIdx];
// Set the legend can be showed
chart.ShowLegend = true;
// Set the chart title name
chart.Title.Text = "TreeMap Chart";
// Add series data range(D2:D13,actually)
chart.NSeries.Add("D2:F13", true);
// Set category data(A2:A13 is incorrect )
chart.NSeries.CategoryData = "A2:C13";
// Show the DataLabels with category names
chart.NSeries[0].DataLabels.ShowCategoryName = true;
// Fill the PlotArea area with nothing
chart.PlotArea.Area.FillFormat.FillType = FillType.None;
// Save the Excel file
workbook.Save("out.xlsx");;