Skip to content

Conversation

leeoniya
Copy link
Contributor

@leeoniya leeoniya commented Nov 23, 2023

alternative approach to #78494

legend-calcs.json
{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 588,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "grafana-testdata-datasource",
        "uid": "PD8C576611E62080A"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 23,
        "w": 17,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "maxDataPoints": 10,
      "options": {
        "legend": {
          "calcs": [
            "last",
            "first",
            "mean"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "single",
          "sort": "none"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "grafana-testdata-datasource",
            "uid": "PD8C576611E62080A"
          },
          "noise": 1000,
          "refId": "A",
          "scenarioId": "random_walk",
          "seriesCount": 30,
          "spread": 100
        }
      ],
      "title": "Panel Title",
      "type": "timeseries"
    }
  ],
  "refresh": "",
  "revision": 1,
  "schemaVersion": 39,
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "legend-calcs",
  "uid": "qXFG4jT4k",
  "version": 5,
  "weekStart": ""
}

may be easiest to review each commit by itself. also hide whitespace changes:

image

@leeoniya leeoniya added type/bug no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes area/legend labels Nov 23, 2023
@leeoniya leeoniya added this to the 10.3.x milestone Nov 23, 2023
@leeoniya leeoniya self-assigned this Nov 23, 2023
@leeoniya leeoniya requested review from grafanabot and a team as code owners November 23, 2023 02:10
@leeoniya leeoniya requested review from drew08t and adela-almasan and removed request for a team November 23, 2023 02:10
Comment on lines +942 to +945
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"]
Copy link
Contributor Author

@leeoniya leeoniya Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure how to TS my way out of this without adding unnecessary runtime coercion code 😢

Copy link
Contributor

@bobrik bobrik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The end result is same as #78494, and that what matters most to me.

@leeoniya leeoniya merged commit b022dde into main Nov 27, 2023
@leeoniya leeoniya deleted the leeoniya/legend-name-natural-sort branch November 27, 2023 22:39
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend area/legend no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants