Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center Align Title Google Chart

Tags:

How can I center the title in a Line Chart from Google Charts API (Not Google Chart Images)

I don't see any options like titlePosition: 'center'

Thanks!

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['xValues', 'yValues'],
    [0, 34.92],
    [389, 39.44],
    [488, 52.11],
    [652, 55.4]
  ]);

  var options = {
    curveType: 'none', // 'function'
    title: 'Title',
    titleTextStyle: {
      color: '333333',
      fontName: 'Arial',
      fontSize: 10
    },
    legend: 'none',
    enableInteractivity: false
  };

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

like image 969
Turnercj65 Avatar asked Jun 29 '12 17:06

Turnercj65


People also ask

How do I center a chart title in Google?

What I would do is remove the title from the chart and add a header above the chart which would allow you to center it using CSS. To remove the title from the chart use titlePosition: 'none' . For more info: Google Chart Documentation - Configuration Options. Agree, there is no other option to centre the title.

Is the area where actual chart is drawn?

Plot area is a window with in the Chart area. It contains the actual chart itself, and includes plotted data, data series, category, and value axis.

How do I exclude zeros from a Google chart?

The easiest way to exclude x-axis labels from a chart if the corresponding y-axis values are 0 or blank is by simply hiding the rows containing the 0/null values.


2 Answers

This option is not provided by the API; you simply cannot do this.

like image 68
Lightness Races in Orbit Avatar answered Sep 21 '22 15:09

Lightness Races in Orbit


I use: titlePosition: 'none'

And insert a title with normal HTML

like image 35
Werner Avatar answered Sep 21 '22 15:09

Werner