如何将x轴线和谷歌条形图的值放到图表的顶部

时间:2013-11-28 09:22:23

标签: charts google-visualization

我使用谷歌图表作为我的应用程序。我需要一个像

这样的图表

预期 enter image description here

我用这段代码得到了预期的图表。

 google.load("visualization", "1", {packages: ["corechart"]});
            function drawVisualization() {
                // Create and populate the data table.
                var data = google.visualization.arrayToDataTable([
                    ['numbers', 'Austria', 'Bulgaria'],
                    [2003, 1336060, 400361],
                    [2004, 1538156, 366849],
                    [2005, 1576579, 440514],
                    [2006, 1600652, 434552],
                    [2007, 1968113, 393032],
                    [2008, 1901067, 517206]
                ]);
                var hAxisTick = [{v: '2003', f: "3-4"}, {v: '2004', f: "5-9"}, {v: '2005', f: "9-13"}, {v: '2006', f: "13-14"}, {v: '2007', f: "14-24"}, {v: '2008', f: "24-84"}];
                var vAxisTick = [0, 1968113];
                // Create and draw the visualization.
                new google.visualization.BarChart(document.getElementById('chart_div')).
                        draw(data,
                                {width: 600, height: 250,
                                    colors: ['706C6B', 'D6D3D3'],
                                    legend: {position: 'none'},
                                    vAxis: {ticks: hAxisTick, gridlines: {color: 'FFFFFF'}},
                                    hAxis: {gridlines: {color: 'FFFFFF'}, ticks: vAxisTick, baselineColor: '#FFFFFF'},
                                    enableInteractivity: false}
                        );
            }
            google.setOnLoadCallback(drawVisualization);

但是,

实际

enter image description here

如何将x轴线放到顶部,我还需要显示给定点的刻度线。

0 个答案:

没有答案