Vertical lines Google Chart

I would like to add vertical lines to this chart. But I can't. I would like each group to draw a vertical line, as in this image.

insert the description of the image here

My current Code:

google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Pergunta', 'Valor 1', 'Valor 2'],
        ['Pergunta 1', 2, 3],
        ['Pergunta 2', 4, 1],
        ['Pergunta 3', 1, 1]
    ]);

    var options = {
        title: '2016',
        subtitle: 'Resultados',
        legend: 'none',
        height: 600,
        pointSize: 3,
        vAxis: {title: "Status", ticks: [{v: 1, f: "Ótimo"}, {v: 2, f: "Bom"}, {v: 3, f: "Regular"}, {v: 4, f: "Ruim"}]

        }
    };

    var chart = new google.visualization.LineChart(document.getElementById('grafico'));

    chart.draw(data, options);
}

Rendering:

insert the description of the image here

I would like it to look like this:

insert the description of the image here

Notice the vertical lines in each "X-axis question".

Author: Comunidade, 2016-11-08

1 answers

You can reproduce this effect using "annotation":

  1. adds One More column with the role "annotation". {type: 'string', role: 'annotation'}
  2. in its options adds the option annotations: { style: 'line' }.
  3. in your data add an empty value to the column of annotation.
    Obs.: Cannot be null, if none has value does not display the row.

Example

google.charts.load('current', {'packages': ['corechart']});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Pergunta', {type: 'string', role: 'annotation'}, 'Valor 1', 'Valor 2'],
        ['Pergunta 1', '', 2, 3],
        ['Pergunta 2', '', 4, 1],
        ['Pergunta 3', '', 1, 1]
    ]);

    var options = {
        title: '2016',
        subtitle: 'Resultados',
        legend: 'none',
        height: 600,
        pointSize: 3,
        vAxis: {
          title: "Status", 
          ticks: [
            {v: 1, f: "Ótimo"}, 
            {v: 2, f: "Bom"}, 
            {v: 3, f: "Regular"}, 
            {v: 4, f: "Ruim"}
          ]
        },
        annotations: {
            style: 'line'
        }
    };

    var chart = new google.visualization.LineChart(document.getElementById('grafico'));

    chart.draw(data, options);
}
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="grafico">
</div>

Source

Http://jsfiddle.net/NC37X /

 3
Author: Guilherme Lautert, 2016-11-08 12:24:04