Multi-line Title for Treemap Node

428 views
Skip to first unread message

Chris123

unread,
Jul 10, 2019, 12:37:52 PM7/10/19
to Google Visualization API
Hello, I'm currently trying to implement a Treemap within my Angular application. I have it working, but the only issue I'm facing is that I'd like to have a multi-line title for each node. I want to have the title, then display a value directly underneath for each node. I've tried adding \n, <br> etc. to the title value in the data array but nothing works. I've included the relevant code, any advice would be greatly appreciated.

SetupTreemap() {
        this.googleChartLibrary = (<any>window).google;

        this.googleChartLibrary.charts.load('current', {'packages':['treemap']});
        this.googleChartLibrary.charts.setOnLoadCallback(this.DrawTreemap.bind(this));
    }

    DrawTreemap () {
        let treemapData = this.googleChartLibrary.visualization.arrayToDataTable([
          ['Title', 'Parent', 'Size', 'Color'],
          ['Global',null,0,0],
          ['Header 1' + '(This should be on line 2)','Global',144179.10,0],
          ['Header 2','Global',58095.20,25],
          ['Header 3','Global',143034.89,50],
          ['Header 4','Global',36163.36,75],
          ['Header 5','Global',28000,100],
        ]);

        let tree = new this.googleChartLibrary.visualization.TreeMap(document.getElementById('treemap-div'));

        this.googleChartLibrary.visualization.events.addListener(tree, 'select', function () {
            tree.setSelection([]);
          });

        tree.draw(treemapData, {
          minColor: this._chartColor1,
          midColor: this._chartColor2,
          maxColor: this._chartColor3,
          textStyle: {
              color: '#ffffff',
              fontSize: 16,
              bold: true,
              italic:false
          },
          showScale: false,
          showTooltips: false,
          maxDepth: 1,
          height: 350,
          headerHeight: 0,
          highlightOnMouseOver: false,
          useWeightedAverageForAggregation: true
          
        });
    }

Screen+Shot+2019-07-10+at+1.35.35+PM.png
Reply all
Reply to author
Forward
0 new messages