Skip to content

Instantly share code, notes, and snippets.

@simon-lang
Created January 18, 2019 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simon-lang/fd056190c1685c9a260b46ebccc3304e to your computer and use it in GitHub Desktop.
Save simon-lang/fd056190c1685c9a260b46ebccc3304e to your computer and use it in GitHub Desktop.
const grouped = _.groupBy(this.state.deepAnalysisGroupedBarChart, 'color')
this.state.deepAnalysisMaxValue = max.value
const _encoding = {
x: {
field: 'value',
type: 'quantitative',
scale: {
domain: [0, max.value]
}
},
y: {
field: 'label',
type: 'nominal',
sort: {
field: 'value'
},
axis: {
title: null
}
},
color: {
field: 'label',
type: 'nominal',
scale: { range: { scheme: 'category20c' } }
}
}
// Grouped bar chart using vconcat
this.state.deepAnalysisBarChartSpec = {
$schema: 'https://vega.github.io/schema/vega-lite/v3.json',
vconcat: _.keys(grouped).map(k => {
let encoding = _cloneDeep(_encoding)
encoding.y.axis.title = k
return {
data: { values: grouped[k] },
mark: 'bar',
encoding
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment