Would like to plot with multi-select option


I am trying to replace this with a multi-select plot instead of using checkboxes:

So I want to use a solution like this to plot it based on country. Is this possible?


This is the closest I got so far:

viewof CountryCodesMulti = yamultiselect(
    value: (d) => d, // Use the value directly from cCodesList
    label: (d) => {
      const countryData = flatteneddata.find((item) => item.country_code === d);
      return countryData ? `${cCodesList.year}: ${cCodesList.emission}` : ""; // Concatenate year and emission
    title: `${cCodesList.year}: ${cCodesList.emission}` // Use the function reference directly in the title option

label is the label for the entire widget and needs to be a string. If you want custom labels for the individual items, try transforming your items to a Map. All the available configuration options are demonstrated in the widget’s notebook.

If you can also share a link to your notebook it will be easier to provide an example.

By the way, if any code that you share is generated by ChatGPT (or similar models), please mark it as such. Language models tend to “hallucinate” and make up inaccurate code that they present as correct.

Sure, here is the link: Plot: Stacked Plots / ME_Test | Observable

Also your suggestions seems like it made it work!

(This time, corrected chatgpt 4.0)

Thank you.

Looking for additional insights as well.