Created
January 18, 2019 00:29
-
-
Save simon-lang/fd056190c1685c9a260b46ebccc3304e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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