Google图表,注释和标签问题

时间:2018-01-11 14:10:09

标签: javascript html css charts google-visualization

我正在使用谷歌图表生成图表,但是我有几个问题。

首先:当前注释显示在第二个系列中,其中显示了排名中的位置。但是,如果第二个系列(灰色背景)中有更多空间,则文本会向下移动或完全消失。我希望注释(“排名中的位置”)总是在一行上,如果空间不足,它会重叠两个系列(蓝色和灰色)。

第二:在标签(1月,2月,3月等)的情况下,当标签太长或由几个单词组成时,我希望它移动到下一行。

如何解决这个问题?提前感谢您的回答。

var data = google.visualization.arrayToDataTable([
        ['Genre', 'Zrealizowane', {role: 'annotation'}, 'Niezrealizowane', {role: 'annotation'}],
        ['january', 10, '', 90, '7th place in the ranking'],
        ['february', 16, '', 84, '7th place in the ranking'],
        ['march', 16, '', 84, '12th place in the ranking'],
        ['april', 10, '', 90, '7th place in the ranking'],
        ['may', 16, '', 84, '12th place in the ranking'],
        ['june', 100, '', 9, '7th place in the ranking'],
        ['juli', 16, '', 84, '12th place in the ranking'],
        ['august', 81, '', 90, '2nd place in the ranking']
    ]);

    var options = {
        chartArea: {width: size, height: '90%', right: 20},
        legend: {position: 'top', maxLines: 2},
        bar: {groupWidth: '46px'},
        isStacked: 'percent',
        hAxis: {
            minValue: 0,
            ticks: [0, .25, .5, .75, 1]
        },
        series: {
            0: {color: '#0077c4'},
            1: {color: '#f2f2f2'}
        }
    };

    var chart = new google.visualization.BarChart(document.getElementById('chart_progress'));
    chart.draw(data, options);

enter image description here

0 个答案:

没有答案