Gruber
Gruber

Reputation: 4558

Google Charts compound charts after deprecation

I am using Google Charts to draw compound charts, similar to the one depicted below (bar charts and line combined). Just learned that it has been deprecated.

Compound graph

It seems the replacement is Google Chart Tools, and I need to recode my stuff. But despite my best search efforts I can't find any examples or ways to make compound charts using the new API.

Is it possible to make compound charts with the new API? Anybody has a link to documentation?

Upvotes: 1

Views: 1677

Answers (3)

Amit Agarwal
Amit Agarwal

Reputation: 121

function priceChart(a) {
var data = google.visualization.arrayToDataTable(a, true);
var options = {
   legend: 'none',
   bar: { groupWidth: '100%' },   // Remove space between bars.
  seriesType: 'candlesticks',
candlestick: {
      fallingColor: { strokeWidth: 0, fill: '#a52714' }, // red
      risingColor: { strokeWidth: 0, fill: '#0f9d58' }   // green
   },
    series: {1: {type: 'line'},2: {type: 'line'}},
};

var chart = new google.visualization.ComboChart(document.getElementById(vname));
chart.draw(data, options);

}

Upvotes: 0

Arun Panneerselvam
Arun Panneerselvam

Reputation: 2335

The best way is to

  1. Use Combo charts

  2. repeat the data array and change it to the type you want.

    for instance,

use stacked bar charts and concat the data array before google visualization and use

seriesType: 'bars',
      series: {5: {type: 'line'}, {6: {type: 'line'}, .... } 

and so on. It's just a hack method. Or you can use some other JS chart libraries.

Upvotes: 0

Related Questions