Come creare un grafico TreeMap con C++
Contents
[
Hide
]
Possibili Scenari di Utilizzo
Un grafico a mappa a riquadri fornisce una visualizzazione gerarchica dei tuoi dati e rende facile individuare modelli, ad esempio quali articoli sono i più venduti in un negozio. I rami dell’albero sono rappresentati da rettangoli e ogni sotto-ramo è mostrato come un rettangolo più piccolo. Il grafico a mappa a riquadri visualizza le categorie per colore e prossimità e può facilmente mostrare molti dati che sarebbero difficili da visualizzare con altri tipi di grafico.
Grafico TreeMap
Dopo aver eseguito il codice qui sotto, vedrai il grafico TreeMap come mostrato di seguito.
Codice di Esempio
Il seguente codice di esempio carica il file Excel di esempio e genera il file Excel di output.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create an instance of Workbook
Workbook workbook(u"treemap.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Add a Treemap chart
int32_t pieIdx = worksheet.GetCharts().Add(ChartType::Treemap, 5, 6, 20, 12);
// Retrieve the Chart object
Chart chart = worksheet.GetCharts().Get(pieIdx);
// Set the legend can be showed
chart.SetShowLegend(true);
// Set the chart title name
chart.GetTitle().SetText(u"TreeMap Chart");
// Add series data range (D2:F13, actually)
chart.GetNSeries().Add(u"D2:F13", true);
// Set category data (A2:C13 is incorrect)
chart.GetNSeries().SetCategoryData(u"A2:C13");
// Show the DataLabels with category names
chart.GetNSeries().Get(0).GetDataLabels().SetShowCategoryName(true);
// Fill the PlotArea area with nothing
chart.GetPlotArea().GetArea().GetFillFormat().SetFillType(FillType::None);
// Save the Excel file
workbook.Save(u"out.xlsx");
Aspose::Cells::Cleanup();
}