C3JS 中按组排列的堆积条形图

Stacked bar chart by groups in C3JS

如何在堆叠条形图的组中创建一个组?

I have multiple accounts, which have buys and sells. 

I need to display the buys and sells in a stacked bar chart for each account. 

我只能显示买卖。棘手的一点是显示每个账户的买卖。有什么想法吗?

试试这个:https://jsfiddle.net/tqwxx50a/1

HTML:

<div id="chart1"></div>

Javascript:

var months = ['Jan 2016', 'Feb2016'];
var columnData = [
  ['account1buy', 20, 15],
  ['account1sell', 18, 25],
  ['account2buy', 33, 45],
  ['account2sell', 54, 21],
];


var chart = c3.generate({
    bindto: '#chart1',
  data: {
    columns: columnData,
    type: 'bar',

    groups: [['account1buy', 'account1sell'], ['account2buy', 'account2sell']],
  },

  axis: { x: {
    type: 'category',
    categories: months,
  }},
});