Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vertical alignment label google charts

How do I vertically align label in google chart say on y or r axis?

like image 660
dhaval Avatar asked Dec 03 '22 15:12

dhaval


1 Answers

Yes, vertical Align is possible now.

You can do them by

var options = {
  title: "Test",
   hAxis: {
        direction:-1,
        slantedText:true,
        slantedTextAngle:90 // here you can even use 180
    }
};

I am adding full codes for testing

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
          google.load("visualization", "1", {packages:["corechart"]});
          google.setOnLoadCallback(drawChartModeldaily);

          function drawChartModeldaily() {
            var data = google.visualization.arrayToDataTable(
                [
                    ['daily', 'Views', 'Likes'],
                    ['Tue',  4, 19],
                    ['Mon',  22, 16],
                    ['Sat',  3, 1],
                    ['Fri',  15, 34],
                    ['Thu',  27, 44],
                    ['Wed',  17, 23],
                ]
            );

var options = {
  title: "Test",
   hAxis: {
        direction:-1,
        slantedText:true,
        slantedTextAngle:90
    }
};

var chart = new google.visualization.LineChart(document.getElementById("chart_div_daily"));
chart.draw(data, options);
          }
        </script>
     <div id="chart_div_daily" style="width: 900px; height: 500px;"></div>

I am working with latest Google Chart. Please check them at https://developers.google.com/chart/

like image 55
subingeorge Avatar answered Jan 21 '23 10:01

subingeorge