render({
data: { values: birds },
layer: [
{
mark: 'circle',
encoding: {
x: { field: 'bill_length', type: 'Q', scale: { zero: false } },
y: { field: 'bill_depth', type: 'Q', scale: { zero: false } },
color: { field: 'condition', type: 'N' }
}
},
{
mark: { type: 'line', stroke: 'black' },
transform: [{ regression: 'bill_depth', on: 'bill_length' }],
encoding: {
x: { field: 'bill_length', type: 'Q', scale: { zero: false } },
y: { field: 'bill_depth', type: 'Q', scale: { zero: false } }
}
},
{
mark: 'line',
transform: [
{
regression: 'bill_depth',
on: 'bill_length',
groupby: ['condition']
}
],
encoding:{
x: {field: 'bill_length', type: 'Q', scale: { zero: false }},
y: {field: 'bill_depth', type: 'Q', scale: { zero: false }},
color: {field: 'condition'}
}
}
]
})