Skip to content

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

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) : [];
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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