Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] legend: Provide key and value as arguments for format #3663

Open
adschmu opened this issue Feb 23, 2024 · 0 comments
Open

Comments

@adschmu
Copy link

adschmu commented Feb 23, 2024

Description

With #3662 fixed, one could provide both the identifier (key in data.names) and the friendly name (value in data.names) as arguments in the legend.format function. If data.names is not used in the config, both arguments could just contain the same value.

  data: {
    names: {"data": "Detailed Name"},
    columns: [
      ["data", 91.4]
    ],
    type: "gauge"
  },
  legend: {
      format: function (key, value) {
        if (key == "data")
          return value.substr(0 ,5) + "..."; // Would return "Detai..."
        else
          return value;
      },
      tooltip: true
  }

This would allow to use systematically named "keys"/"identifiers" and then apply different formattings based on them.

Imagine variable language-localized friendly names ("values") loaded from an external source and invariant identifiers ("keys"). One could then easily switch based on the known keys to shorten/adjust the localized values without having to parse the latter.

netil pushed a commit that referenced this issue Feb 28, 2024
Update description based on changes of #3663
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants