chartist-js / chartist

Simple responsive charts
https://chartist.dev
MIT License
13.33k stars 2.54k forks source link

Support plot legends #1410

Open umayrh opened 1 year ago

umayrh commented 1 year ago

Would you like to work on this feature?

What problem are you trying to solve?

Since chartist-plugin-legend seem inactive, and is incompatible with Chartist v1 [1], there doesn't seem to be a way to put legends in Chartist plots anymore. Chart legends should be part of Chartist core lib and not a plugin since it's essential to make non-trivial plots meaningful.

[1] Upgrading the chartist CSS and JS sources in https://codepen.io/chimmer/pen/QVvMgz?editors=1111 breaks the demo

Describe the solution you'd like

By default, the legend should be constructed from the name field provided in the series list, and default to using the alpha-numerated classnames (so, Plot A, Plot B etc).

    new Chartist.LineChart(
      '#chart',
      {
        labels: ['a', 'b', 'c'],
        series: [{'name': 'Plot 1', data: [1, 3, 4, 7, 11, 18]}, {'name': 'Plot 2', data: [1, 2, 3, 5, 8, 13]]
      }, {
        fullWidth: false,
        },
    });

Describe alternatives you've considered

No response

Documentation, Adoption, Migration Strategy

No response