I need to change X Axis appearance in google line chart

Here is my google line graph

I want to “dilute” the appearance of values on x axis

Here in the var options:

var options = {
        
          title: 'Box Office Earnings in First Two Weeks of Opening',
          subtitle: 'in millions of dollars (USD)',
		  curveType: 'function',
	      hAxis: { showTextEvery: 10, minTextSpacing: 30}
        };

why don’t the values "dilute or become more spacious ? I tried each of the hAxis objects alone nothing works. Why ?

Sorry, but I don’t know what you mean by “dilute” or “spacious”. Maybe “don’t include all the data” and “bar chart instead of line chart”?

Please explain, or maybe better yet post a mock up of how you would prefer the chart to look.

It would help to know the charting library which you are using. Displaying an object literal of configuration values alone is no enough to diagnose a problem.

hERE IS THE CHART CODE

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script type="text/javascript">

	////////       Convert PhP $data array to JavaScript array    //////////
	  var datum = <?php echo json_encode($items); ?>;
	  
	  /////////  Creating the data for the line graph: accumulating value with time  //////
	  datum[0].profit = parseFloat(datum[0].profit);
	  for(var i = 1; i < datum.length; i++){
		  datum[i].profit = parseFloat(datum[i].profit) + parseFloat(datum[i-1].profit);
		}
	 // console.log(datum);
     google.charts.load('current', {'packages':['line']});
      google.charts.setOnLoadCallback(drawChart);

    function drawChart() {

      var data = new google.visualization.DataTable();
      data.addColumn('string', ' ');
      data.addColumn('number', 'profit');

      for(var i = 0; i < datum.length; i++){
		  		var obj = datum[i];
				data.addRow([obj.time, obj.profit]);
				
			}

	  

      var options = {
        
          title: 'Box Office Earnings in First Two Weeks of Opening',
          subtitle: 'in millions of dollars (USD)',
		  curveType: 'function',
	      hAxis: { showTextEvery: 10, minTextSpacing: 30}
        };

      var chart = new google.charts.Line(document.getElementById('chart_div'));
	  
      chart.draw(data, google.charts.Line.convertOptions(options));
    }//END CHART 1

hERE IS A MOCK UP

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.