cal-heatmap
cal-heatmap copied to clipboard
Legend colors/values not working properly
I appear to have an issue where data values of 1 are sometimes colored properly, and sometimes colored as "less than 1" per the legend. See attached image with a tooltip for the day, the first legend entry, and the second legend entry. This is the legend code I'm using:
legend: [1,4,8,12,20]}
Not sure why days with a value of 1 are randomly showing gray.
Do you have a sample of the dataset ? Are the number Integer of Float ?
They are all integers. Can't attach dataset, so I'll just paste it here:
{"1405317660":5,"1405663260":6,"1406527260":5,"1412143260":14,"1405404060":5,"1405490460":6,"1406613660":4,"1406700060":5,"1406786460":6,"1406872860":7,"1407132060":4,"1407218460":4,"1407304860":3,"1407391260":4,"1407477660":4,"1407736860":5,"1407823260":5,"1407909660":5,"1407996060":7,"1408082460":7,"1408341660":8,"1408428060":9,"1408514460":9,"1408600860":10,"1408687260":10,"1408946460":10,"1409032860":10,"1409119260":10,"1409205660":10,"1409292060":10,"1412229660":14,"1412316060":14,"1412575260":15,"1412661660":16,"1412748060":17,"1412834460":18,"1412920860":18,"1413180060":14,"1413266460":17,"1413352860":17,"1413439260":18,"1413525660":18,"1413784860":15,"1413871260":16,"1413957660":16,"1414044060":17,"1414130460":17,"1414389660":15,"1414476060":16,"1414562460":16,"1414648860":17,"1414735260":17,"1414994460":16,"1415080860":16,"1415167260":16,"1415253660":17,"1415340060":17,"1415599260":13,"1415685660":16,"1415772060":16,"1415858460":17,"1415944860":17,"1416204060":15,"1416290460":16,"1416376860":16,"1416463260":17,"1416549660":17,"1416808860":15,"1416895260":16,"1416981660":16,"1417068060":16,"1417154460":16,"1417413660":16,"1417500060":17,"1417586460":17,"1417672860":18,"1417759260":17,"1418018460":14,"1418104860":17,"1418191260":17,"1418277660":18,"1418364060":18,"1418623260":16,"1418709660":17,"1418796060":17,"1404367260":4,"1404972060":5,"1406181660":3,"1409810460":13,"1410415260":11,"1411020060":11,"1411624860":12,"1405058460":5,"1406268060":3,"1409896860":13,"1410501660":11,"1411106460":11,"1404453660":2,"1409551260":9,"1409637660":12,"1409724060":12,"1410156060":9,"1410242460":10,"1410328860":10,"1410760860":8,"1410847260":10,"1410933660":10,"1411365660":10,"1411452060":11,"1411538460":11,"1411711260":11,"1411970460":12,"1412056860":12,"1403244060":1,"1404108060":2,"1404799260":3,"1404194460":2,"1404885660":4,"1403762460":3,"1403848860":3,"1404712860":2,"1405576860":5,"1404280860":2,"1403676060":1,"1405922460":2,"1406008860":2,"1406095260":2,"1402984860":0,"1403071260":0,"1403157660":0,"1403503260":0,"1403589660":0}
I'm seeing a similar issue and I'm only using integers. For example:
I can see from the key that the lightest green should show less than 2 (i.e. any entries with only 1 item):
An entry with 1 resource is coloured correctly, however an entry with 2 resources is also coloured under the lightest green:
My legend setting is [2, 4, 6, 8, 10]
I think that perhaps the legend description is incorrect?
Less than 2 actually corresponds to 1-2 items. Between 2 and 5 corresponds to 3-5 items. etc.
I'm having the same problem.
Agree with @jamesburke-examtime that it looks like it's the legend title text that is wrong, with less than actually being less than or equal to etc... This (<=) is actually the behaviour I want (although perhaps it should be optional?), so it's just the title text that's wrong from my perspective.
Another thing with the legend is that if you're only using integers and have the legend set to single values (so [1, 2, 3, 4, 5]) then it'd be good to have the option to just show the actual numbers in the key, rather than "Less than 1", "Less than 2" etc...
Having this same issue. I think you can fix this by treating the legend values as the upper bound (inclusive) while the lower bound is the prev_value + 1
.
So let's say a setting of [10, 20, 30, 40]
would be interpreted as:
Legend 1: <= 10
Legend 2: 11-20
Legend 3: 21-30
Legend 4: 31-40
Legend 5: >= 40
I would personally include: Legend 0: empty
- but that's for another discussion.
Comment above is right, the legend array values are threshold
Next v4 legend is rewritten from the ground up, and will allow more flexibility