advent-of-code-charts icon indicating copy to clipboard operation
advent-of-code-charts copied to clipboard

Make "double-click legend" feature discoverable

Open jeroenheijmans opened this issue 5 years ago • 4 comments

Previous year a community PR added the feature to double-click users in the legend to "invert" the selection of shown series.

This feature is not very discoverable. Let's improve the UX/UI to help people find that feature.

jeroenheijmans avatar Dec 05 '19 07:12 jeroenheijmans

A legend title would be perfect for this but there's an open issue at chart.js for that feature... 😢

jeroenheijmans avatar Dec 08 '19 16:12 jeroenheijmans

Linked issue seems resolved :tada: so this issue seems fixable now, after an update of chart.js!

jeroenheijmans avatar Sep 26 '20 20:09 jeroenheijmans

PS. There's a advent-of-code-charts channel in the contributing.today Discord where I'll be if anyone has hacktoberfest-related questions!

jeroenheijmans avatar Oct 01 '20 10:10 jeroenheijmans

Hi, I start working on #36, 'cause it's related to this issue I can work on both.

Let me know ;)

zbolo avatar Oct 13 '20 07:10 zbolo

The issue was fixed and legends are now possible. Note to self, I checked that feature works like this:

document.addEventListener("DOMContentLoaded", () => {
  new Chart(document.getElementById('chart'), {
    type: 'bar',
    data: {
      datasets: [{
        label: 'Nr of items',
        data: [{x:"A",y:23}, {x:"B",y:11}, {x:"C",y:19}],
      }],
    },
    options: {
      plugins: {
        legend: {
          title: {
            display: true,
            text: "My Title Here",
          },
        },
      },
    },
  });
});

However, it doesn't seem to work if I add a title to the existing way legend is configured in the code, not sure why yet. That is, if I just add it here:

https://github.com/jeroenheijmans/advent-of-code-charts/blob/9024661a962f9e0128438ea2de409c17531b039a/src/js/app.js#L899-L905

nothing seems to happen. Need to figure out why...

I tried adding this into the legend object:

title: {
    display: true,
    text: "Legend title",
},

Again, the above sample works just fine (and goes via options on a different object), so something going on there probably.

jeroenheijmans avatar Jan 06 '23 00:01 jeroenheijmans

Well, apparently the index.html for testing purposes didn't have #81 Chart.js v4 yet, so this feature wasn't there yet. Now that #81 has been solved, the legend title also works. Slipstreaming this fix in #79 (2023 updates).

jeroenheijmans avatar Jan 06 '23 20:01 jeroenheijmans