将空白添加到Google Chart Label

时间:2014-03-19 17:58:04

标签: javascript google-visualization

最近谷歌图表启用了标签,并对结果布局进行了说明

“如果标签太大而无法完全放入栏内,则会显示在”https://google-developers.appspot.com/chart/interactive/docs/gallery/barchart

之外

然而,我发现如果标签是一个字符串,并且有空格,如果接近“太大”的阈值,它会分成两行。请参阅下面的示例。

有没有人知道一个空白解决方案,使其成为一个实心字符串?还是其他任何想法?

http://jsfiddle.net/gbzLB/32/

var data = new google.visualization.DataTable();

data.addColumn('string', 'Name');
data.addColumn('number', 'Percent');
data.addColumn({type: 'string', role: 'annotation'});
data.addColumn({type: 'string', role: 'style'});
data.addRows([
    ['Greek', 55, '216 Votes - 72%', 'color: #FFCC00'],
    ['Italian', 5, '15 Votes - 5%', 'color: #FF6688'],
    ['Polish', 16, '48 Votes - 16%', 'color: #33CCFF']
]);

var chart = new google.visualization.BarChart(document.querySelector('#chart_div'));
chart.draw(data, {
    height: 150,
    backgroundColor: {fill: '#F2EFFB'},
    hAxis: {title: "Percentage", maxValue: '100', gridlines: {
            color: 'black'

    },
    width: 480,
    legend: {
        position: 'none'
    }
});

0 个答案:

没有答案