Difference chart - understand the x-position for city names

Hello. Can someone explain me how x is found for the text mark without using ‘x:’?

Bonus point to explaining the use of …Plot.selectMinY(…) too :slight_smile:

Plot.text(data, {
  ...Plot.selectMinY({
    x: "date",
    y: "New York",
    text: () => "San Francisco"
  }),
  y: "San Francisco",
  dy: -40
})

x is defined on line 3. selectMinY will only consider the index of the data point that has the minimum temperature in New York (line 4), and will return both channels x and y (and also text, for that matter).

Then on line 7 we override the y channel by the temperature in San Francisco, so we end up with the x channel being all the dates, the y channel being all the temperatures in SF, and the index being the one that gives the minimum temperature in NYC.

Thank you for the explanation.

When reading it initially It felt that by having x embedded in the selectMinY it was not out of scope for the text mark.

In my head (i.e. wrong) I was expecting something like:
x:
…Plot.selectMinY({
x: “date”,
y: “New York”,
text: () => “San Francisco”
})