Left space for right legend

See https://stackoverflow.com/questions/6869967/how-to-set-google-charts-legend-width-in-javascript

by Leonam, Carlos

HTML

<script src="https://www.gstatic.com/charts/loader.js" type="text/javascript"></script>
<div id="chart_div"></div>

CSS

#chart_div {
    width: 400px;
    height: 300px;
    border: 1px solid black;
}

JavaScript

google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
      
function drawChart() {
		var data = google.visualization.arrayToDataTable([
      	['Year', 'Total Sales', 'Total Expenses'],
      	['2004', 1000, 400],
      	['2005', 1170, 460],
      	['2006', 660, 1120],
      	['2007', 1030, 540]
    ]);

		var options = {
      	title: 'Company Performance',
      	curveType: 'function',
      	legend: { position: 'right' },
      	chartArea: {
        		right: 130, 	// set this to adjust the legend width
        		left: 40, 		// set this to adjust the left margin
      	},
        hAxis: { title: "year" },
        vAxis: { title: "quantity" },
		};

		new google.visualization
    		.LineChart(document.getElementById('chart_div'))
				.draw(data, options);
}