Positive / Negative Chart in the Google Visualization API

I need to create a chart like this:

positve / negative chart

In particular, I want to show both a positive value and a negative value for a time period (maybe an hour, a minute, etc.) and display it as follows.

I could have sworn that the other day I saw something similar in the Google Visualization API Gallery , but I can’t find it now, and I don’t even know what this type of chart is called.

First, you know what is called such a chart, so I can find the documentation? Secondly, is there a way to implement such a diagram using the Google visualization API? If not, is there another general solution for building web pages that I can achieve with?

Thank you for your time.

+3
2

"Stacked Bar Chart" API Google.

isStacked ( : http://code.google.com/apis/visualization/documentation/gallery/barchart.html).

( , Google, , isStacked );

function drawVisualization() {

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

  data.addRows(12);

  data.setCell(0, 0, 'January');
  data.setCell(1, 0, 'February');
  data.setCell(2, 0, 'March');
  data.setCell(3, 0, 'April');
  data.setCell(4, 0, 'May');
  data.setCell(5, 0, 'June');
  data.setCell(6, 0, 'July');
  data.setCell(7, 0, 'August');
  data.setCell(8, 0, 'September');
  data.setCell(9, 0, 'October');
  data.setCell(10, 0, 'November');
  data.setCell(11, 0, 'December');

  data.setCell(0, 1, 19);
  data.setCell(1, 1, 18);
  data.setCell(2, 1, 20);
  data.setCell(3, 1, 19);
  data.setCell(4, 1, 18);
  data.setCell(5, 1, 20);
  data.setCell(6, 1, 19);
  data.setCell(7, 1, 18);
  data.setCell(8, 1, 20);
  data.setCell(9, 1, 19);
  data.setCell(10, 1, 18);
  data.setCell(11, 1, 20);

  data.setCell(0, 2, -12);
  data.setCell(1, 2, -13);
  data.setCell(2, 2, -11);
  data.setCell(3, 2, -12);
  data.setCell(4, 2, -13);
  data.setCell(5, 2, -11);
  data.setCell(6, 2, -12);
  data.setCell(7, 2, -13);
  data.setCell(8, 2, -11);
  data.setCell(9, 2, -12);
  data.setCell(10, 2, -13);
  data.setCell(11, 2, -11);
  data.setCell(0, 2, -12);
  data.setCell(1, 2, -13);
  data.setCell(2, 2, -11);

  // Create and draw the visualization.
  new google.visualization.ColumnChart(document.getElementById('visualization')).
      draw(data,
           {title:"S&P 500 Up/Down Performance Since 1980", 
            width:600, height:400,
            isStacked:"true",
            legend:"none" }
      );
}

...

Stacked bar chart

+11

ColumnChart BarChart:

var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));

https://jsfiddle.net/0rrar9oq/16

0

Source: https://habr.com/ru/post/1796595/


All Articles