Line limit Google Charts

Asked

Viewed 581 times

0

I am facing a problem that I do not find the solution rs I need to add a line limit on my chart, I’m going to put an image down on how it is now and how it should look. Can you guide me on this?

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

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['2017', 'Minima', 'Máxima', 'Média'],
        ['Jan', 15, 23, 21],
        ['Fev', 17, 25, 20],
        ['Mar', 18, 30, 22],
        ['Abr', 20, 27, 27],
        ['Mai', 21, 23, 21],
        ['Jun', 23, 28, 26],
        ['Jul', 27, 32, 28],
        ['Ago', 22, 25, 24],
        ['Set', 26, 30, 28],
        ]);

    var options = {

        title: 'Relatório Temperatura Mensal',
        colors: ['#cfcfcf', '#1c1c1c', '#828282'],
    };

    var chart = new google.charts.Bar(document.getElementById('columnchart_material'));

    chart.draw(data, google.charts.Bar.convertOptions(options));

Current: inserir a descrição da imagem aqui

As it should be: inserir a descrição da imagem aqui

From now on. I thank you.

  • Do you want the media? Or do you not want the graphic to cross the red line?

  • Hey buddy, no, the average already got on a bar chart. What I need is a line set at a limit, for example, 23ºC, that line will stay fixed at this location always, so the bar charts will cross this "limit" and I will get some visualization in the report.

1 answer

1


You can always use this graph and use "Average" to put the average value there. https://developers.google.com/chart/interactive/docs/gallery/combochart

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

  function drawVisualization() {
    // Some raw data (not necessarily accurate)
    var data = google.visualization.arrayToDataTable([
     ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
     ['2004/05',  165,      938,         522,             998,           450,      614.6],
     ['2005/06',  135,      1120,        599,             1268,          288,      682],
     ['2006/07',  157,      1167,        587,             807,           397,      623],
     ['2007/08',  139,      1110,        615,             968,           215,      609.4],
     ['2008/09',  136,      691,         629,             1026,          366,      569.6]
  ]);

var options = {
  title : 'Monthly Coffee Production by Country',
  vAxis: {title: 'Cups'},
  hAxis: {title: 'Month'},
  seriesType: 'bars',
  series: {5: {type: 'line'}}
};

var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
  • Thanks Adelino, it went super well ;D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.