How to create a chart where each data mark has a color based on its value? Like this chart: https://observablehq.com/@d3/gradient-encoding
With the following code, the whole curve has one color only. My function Color.forTemperature()
returns different colors for different temperatures.
Chart(temperatures) { temperature in
LineMark(
x: .value("Day", temperature.date, unit: .day),
y: .value("Temperature", temperature.value)
)
.foregroundStyle(Color.forTemperature(temperature.value))
}