-
Notifications
You must be signed in to change notification settings - Fork 0
stacked bar
XING Yun edited this page Mar 27, 2018
·
2 revisions
import { stackedBar } from 'vizart-basic';
import 'vizart-basic/dist/vizart-basic.css';
const options = {
chart: {
height: 420,
margin: { left: 30, right: 30, top: 10, bottom: 30 }
},
data: {
s: { name: 'Department', type: 'string', accessor: 'dep'},
x: { name: 'Age', type: 'string', accessor: 'age'},
y: [ { name: 'Monthly Income', type: 'number', accessor: 'income'} ],
},
};
const _data = [
{ age: 19, income: 9, dep: 'science' }
]
const chart = stackedBar('#chart', options);
chart.render(_data);
switch to group layout
switch to 100% percent expand layout
switch to stacked layout
animation: {
duration: {
layout: 500,
},
},
chart: {
type: 'bar_grouped',
},
plots: {
stackLayout: false,
stackMethod: 'zero',
opacity: 1,
barLabel: {
enabled: true,
color: 'black',
},
metricLabel: {
enabled: true,
color: 'black',
offset: 10,
},
},
display grouped bars when stackLayout is false
Stack method, takes effect only when stackLayout is set to true. can be 'zero', 'expand'
bar opacity, 1 by default
display dimension label within bars
dimension label color
display metric label on top of bars
metric label color, black by default
metric label offset against bar top