wa0x6e/cal-heatmap

get other info from source data

jacksalici opened this issue · 3 comments

Hello, and thank you for this awesome work! I would like to know about the possibility of using data for every row other than the values itself. For instance, when the source is a CSV, I'd like to get all the dict of the single row and use the data of other columns in places like the tooltip or the subdomain text...
Is there a way to achieve this? Thank you in advance.

Can you elaborate more with an example of csv content?

Sure, thank you for the interest.

Let's suppose to have the next table like a CSV:

date distance location
2024-1-1 100 "Italy"

Is it possible to get the "location" value in the tooltip and or in the subdomain label?
Let me show you an example with code...

const cal = new CalHeatmap();
cal.paint(
  {
    data: {
      source: 'my.csv',
      type: 'csv',
      x: 'date',
      y: d => +d['distance'], //the y value is for the distance
      groupY: 'max',
    },
    date: { start: new Date('2024-01-01') },
    
    subDomain: { 
         type: 'day', 
         radius: 2, 
         label: (t, v) => {return v['location']} //<= this not works, but i'd like to achieve something like this, where v is the dict of the entire row not only the y value...

     },
    itemSelector: '#ex-year',
  },

I have looked in the docs and I found nothing, I was wondering if there could be some workarounds...

Hope this is a bit clearer, thank you in advance.

I see, it’s not possible at the moment, but seems like a good feature to add, will add to todo list