Skip to content

Default on canvas legend callback should also get data from config #2281

Closed
@etimberg

Description

@etimberg

The default legend callback, reproduced below, should fallback to the values in the config if possible.

generateLabels: function(data) {
  return helpers.isArray(data.datasets) ? data.datasets.map(function(dataset, i) {
    return {
      text: dataset.label,
      fillStyle: dataset.backgroundColor,
      hidden: dataset.hidden,
      lineCap: dataset.borderCapStyle,
      lineDash: dataset.borderDash,
      lineDashOffset: dataset.borderDashOffset,
      lineJoin: dataset.borderJoinStyle,
      lineWidth: dataset.borderWidth,
      strokeStyle: dataset.borderColor,
      // Below is extra data used for toggling the datasets
      datasetIndex: i
    };
  }, this) : [];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions