acep-uaf / aetr-web-book-2024

Alaska Electricity Trends Report as a web book
https://acep-uaf.github.io/aetr-web-book-2024/
Creative Commons Attribution Share Alike 4.0 International
0 stars 0 forks source link

Add custom tooltip descriptors #53

Closed jikaczmarski closed 2 months ago

jikaczmarski commented 2 months ago

Through out the capacity, net/gross generation, and consumption pages, there are tooltips that have variable names as descriptors (e.g., fy: Coastal). Go back through and adjust all tooltips so that they make sense (e.g., ACEP Region: Coastal).

jikaczmarski commented 2 months ago

I've searched around and here's what I know so far. It is simple enough to change the labels inside of a tooltip through the use of a channels: plot option call,

Plot.plot({
  marks: [
    Plot.barY(
      x: "x",
      y: "y",
      fill: "fuel_type",
      channels: {'Percentage Point Change':"x", Region:"y", 'Fuel Type':"fuel_type"},
      tip: true
    )
  ]
})

However, this does not work for fills since they seem to be handled differently. In my searches, I have not seen and tips on this - most ignore the styling of the fill label entirely. I have made a forum post and hope to hear back soon (I have had lots of success with community support in the past).

jikaczmarski commented 2 months ago

No solution was immediately apparent. Thanks to MP_Li, the work around being used now is to modify the imported data by changing the label on the fill at the header level. For example,

original_data = FileAttachment("datafile.csv").csv({ typed: true })
data = data.map((d) => ({...d, "Fill Name": d.fill_name}))

Once this is done, I used replace all to change fill: "fill_name" to fill: "Fill Name".