I have a plot with two marks, one line and one dot, as below:
this.chart = Plot.plot({
height: 750,
width: 1200,
x: {interval: "month", ticks: 'month'},
y: {grid: true, domain: [30, 100]},
style: {
backgroundColor: '#eeeeee',
fontSize: '14'
},
color: {legend: true},
marks: [
Plot.lineY(
this.data,
Plot.binX<LineYOptions>({y: 'mean'}, {
x: 'ord_datetime',
y: 'metric',
interval: 'month',
tip: true,
})
),
Plot.dot(this.data,
Plot.binX<LineYOptions>({y: 'mean'}, {
x: 'ord_datetime',
y: 'metric',
interval: 'month',
stroke: d => d.metric > 50 ? 'green': 'red',
strokeWidth: 9,
})
),
}
)
]
});
But since I’m using a bin for the dot, I don’t know how to evaluate the mean value and not all the individual values. When I try something like what I have above, it has unintended effects in that it shows the mark in a different position than if I remove it, I suppose because it’s affecting the underlying aggregate value somehow.
How can I base the color logic on the aggregate, monthly, binned value, rather than for individual row values?