Example: Treemap with unsorted data

A treemap is constructed from business analytics data. The area is proportional to the company's sales volume and the color scale maps to a performance indicator. The raw data are unsorted and must be sorted by the area values before creating the chart.
using Imsl.Chart2D;
using System;
using System.Windows.Forms;

public class TreemapEx2 : FrameChart 
{
    public TreemapEx2() 
    {
        Chart chart = this.Chart;
        AxisXY axis = new AxisXY(chart);

        double[] areas = {834, 11359, 1621, 12282, 14646, 8686, 12114,
                          61402, 582, 9448, 1678};
        double[] perf = {-1.75, -.99, -1.4, 0.12, -0.28, -1.14, -0.06,
                          0.37, -0.66, 0, 0.75};
        string[] labels = {"Amer. It. Pasta", "Campbell Soup",
                           "Dean Foods", "General Mills", "Heinz",
                           "Hershey Foods", "Kellogg", "Kraft Foods",
                           "Ralston Purina", "Sara Lee", "Suiza Foods"};

        // sort data
        double[] s_perf = new double[perf.Length];
        String[] s_lab = new String[perf.Length];
        int[] idx = new int[perf.Length];
        Imsl.Stat.Sort.Descending(areas, idx);
        for (int i = 0; i < perf.Length; i++) 
        {
            s_perf[i] = perf[idx[i]];
            s_lab[i] = labels[idx[i]];
        }

        Treemap treemap = new Treemap(axis, areas, s_perf,
            Colormap_Fields.BLUE_GREEN_RED_YELLOW);
        treemap.SetTreemapLabels(s_lab);
        treemap.TextColor = System.Drawing.Color.Gray;
        treemap.TreemapLegend.IsVisible = true;
        treemap.TreemapLegend.SetTitle("Scale");
        treemap.TreemapLegend.TextFormat = "0.0";
    }

    public static void Main(string[] argv) 
    {
        System.Windows.Forms.Application.Run(new TreemapEx2());
    }
}

Output

Link to C# source.