简体   繁体   中英

Increase width of svg rectangle bar in google chart

I am working on Google Timeline chart and the bar width in each row is very smaller in size.

I want to increase the size of that bar but it was tough luck. Using the inspect element of browser, I could able to increase the size but when I tried to apply the same in my code, it isnt working.

Here is what I got from Inspect element section related to SVG

<rect x="0" y="0" width="6000" height="40.992" stroke="none" stroke-width="0" fill="#ffffff"></rect>

Below is my google timeline chart code:

<html>
            <head>
                <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['timeline']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var container = document.getElementById('timeline');
        var chart = new google.visualization.Timeline(container);
        var dataTable = new google.visualization.DataTable();

        dataTable.addColumn({ type: 'string', id: 'President' });
        dataTable.addColumn({ type: 'date', id: 'Start' });
        dataTable.addColumn({ type: 'date', id: 'End' });
        dataTable.addRows([
          [ 'Test1', new Date(1789, 3, 30), new Date(1789, 4, 01) ],
          [ 'Test2',      new Date(1789, 4, 02),  new Date(1789, 4, 03) ],
          [ 'Test3',  new Date(1789, 4, 04),  new Date(1789, 4, 06) ]]);

        chart.draw(dataTable);
      }
    </script>
  </head>
  <body>
            </head>
            <body>
                
                <div id="chart_div">
                </div>
            </body>
        </html>

Can anyone please let me know how to increase the width of bars or svg rectangle in this google chart.

Thanks!

you can increase the width with the help of options in google charts,

https://developers.google.com/chart/interactive/docs/gallery/barchart

var options = {
        title: "Timeline chart",
        width: 600,
        height: 400,
        bar: {groupWidth: "95%"},
      };
        chart.draw(dataTable, options);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM