如何在一个组中为一个堆积条形图设置一个组?
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.
我只能展示购买和出售。棘手的一点是显示每个账户的买入和卖出。任何想法?
答案 0 :(得分:2)
试试这个: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,
}},
});