使用Google图表创建包含不同数据的单个栏

时间:2013-11-06 16:06:20

标签: charts google-visualization

我可以使用Google图表创建这些类型的图表,我也可以将目标设置在顶部。

这些图表是否为栏类型。我没有找到任何可以制作这样的条形图的东西,或者这是一个完全不同的图表类型。

修改

我在Google Chart Tools - How to create stacked bar chart找到了解决方案。这些是堆积的条形图。但我仍然没有找到如何将目标放在顶部

1 个答案:

答案 0 :(得分:1)

使用ComboChart,并将series.<series index>.type选项设置为'bars'以用于“待定”,“丢失”和“赢”系列。为“目标”系列设置series.<series index>.type'steppedArea'series.<series index>.opacity0。将connectSteps选项设置为false。这是一种方法,假设您的数据按“赢”,“丢失”,“待定”,“目标”的顺序:

var chart = new google.visualization.ComboChart(document.querySelector('#chart_div'));
chart.draw(data, {
    height: 400,
    width: 600,
    isStacked: true,
    connectSteps: false,
    series: {
        0: {
            // Won
            type: 'bars'
        },
        1: {
            // Loss
            type: 'bars'
        },
        2: {
            // Pending
            type: 'bars'
        },
        3: {
            // Target
            type: 'steppedArea',
            areaOpacity: 0
        }
    }
});