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

Trend: Support disconnect values and connect nulls options #70616

Merged
merged 26 commits into from
Jul 14, 2023

Conversation

drew08t
Copy link
Contributor

@drew08t drew08t commented Jun 23, 2023

What this PR does / why we need it:
Currently in trend, a user has the option to connect all null values or null values within a certain threshold of time range. Users do not however have the ability to disconnect non-null values that are outside of a time range from each other. This adds the option for users to disconnect non-null values that are outside of a threshold of time range.

  • Define refField inside of applyNullInsertThreshold for trend (currently undefined because not time field)
  • Support connect nulls option - testing locally and it seems like this isn't working as expected
Screen.Recording.2023-07-07.at.9.29.20.PM.mov

Closes #70284

Key Value
Panel trend @ 10.1.0-pre (2b7af77)
Grafana 10.1.0-pre (2b7af77) // Open Source
Panel debug snapshot dashboard
{
  "panels": [
    {
      "datasource": {
        "type": "grafana",
        "uid": "grafana"
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "linear",
            "barAlignment": 0,
            "lineWidth": 1,
            "fillOpacity": 0,
            "gradientMode": "none",
            "spanNulls": false,
            "insertNulls": 25,
            "showPoints": "auto",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "axisLabel": "",
            "axisColorMode": "text",
            "scaleDistribution": {
              "type": "linear"
            },
            "axisCenteredZero": false,
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "color": {
            "mode": "palette-classic"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 13,
        "w": 15,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "legend": {
          "showLegend": true,
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        }
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "grafana",
            "uid": "grafana"
          },
          "queryType": "snapshot",
          "snapshot": [
            {
              "schema": {
                "refId": "A",
                "fields": [
                  {
                    "name": "x",
                    "type": "number",
                    "typeInfo": {
                      "frame": "int64",
                      "nullable": true
                    },
                    "config": {}
                  },
                  {
                    "name": "y",
                    "type": "number",
                    "typeInfo": {
                      "frame": "int64",
                      "nullable": true
                    },
                    "config": {}
                  }
                ]
              },
              "data": {
                "values": [
                  [
                    0,
                    5,
                    10,
                    20,
                    30,
                    40,
                    60
                  ],
                  [
                    5,
                    5,
                    10,
                    20,
                    20,
                    20,
                    10
                  ]
                ]
              }
            }
          ]
        }
      ],
      "title": "Reproduced with embedded data",
      "type": "trend"
    },
    {
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 15,
        "y": 0
      },
      "id": 5,
      "options": {
        "content": "<table width=\"100%\">\n    <tr>\n      <th width=\"2%\">Panel</th>\n      <td >trend @ 10.1.0-pre (2b7af7798c)</td>\n    </tr>\n    <tr>\n      <th>Queries</th>\n      <td>A[testdata]</td>\n    </tr>\n    \n    <tr><th>Data</th><td> 1 frames, 2 fields, 7 rows </td></tr>\n    \n    <tr>\n      <th>Grafana</th>\n      <td>10.1.0-pre (2b7af7798c) // Open Source</td>\n    </tr>\n  </table>",
        "mode": "html"
      },
      "title": "Debug info",
      "type": "text"
    },
    {
      "id": 6,
      "title": "Original Panel JSON",
      "type": "text",
      "gridPos": {
        "h": 13,
        "w": 9,
        "x": 15,
        "y": 7
      },
      "options": {
        "content": "{\n  \"datasource\": {\n    \"type\": \"testdata\",\n    \"uid\": \"PD8C576611E62080A\"\n  },\n  \"fieldConfig\": {\n    \"defaults\": {\n      \"custom\": {\n        \"drawStyle\": \"line\",\n        \"lineInterpolation\": \"linear\",\n        \"barAlignment\": 0,\n        \"lineWidth\": 1,\n        \"fillOpacity\": 0,\n        \"gradientMode\": \"none\",\n        \"spanNulls\": false,\n        \"insertNulls\": 25,\n        \"showPoints\": \"auto\",\n        \"pointSize\": 5,\n        \"stacking\": {\n          \"mode\": \"none\",\n          \"group\": \"A\"\n        },\n        \"axisPlacement\": \"auto\",\n        \"axisLabel\": \"\",\n        \"axisColorMode\": \"text\",\n        \"scaleDistribution\": {\n          \"type\": \"linear\"\n        },\n        \"axisCenteredZero\": false,\n        \"hideFrom\": {\n          \"tooltip\": false,\n          \"viz\": false,\n          \"legend\": false\n        },\n        \"thresholdsStyle\": {\n          \"mode\": \"off\"\n        }\n      },\n      \"color\": {\n        \"mode\": \"palette-classic\"\n      },\n      \"mappings\": [],\n      \"thresholds\": {\n        \"mode\": \"absolute\",\n        \"steps\": [\n          {\n            \"color\": \"green\",\n            \"value\": null\n          },\n          {\n            \"color\": \"red\",\n            \"value\": 80\n          }\n        ]\n      }\n    },\n    \"overrides\": []\n  },\n  \"gridPos\": {\n    \"h\": 8,\n    \"w\": 12,\n    \"x\": 0,\n    \"y\": 0\n  },\n  \"id\": 3,\n  \"options\": {\n    \"tooltip\": {\n      \"mode\": \"single\",\n      \"sort\": \"none\"\n    },\n    \"legend\": {\n      \"showLegend\": true,\n      \"displayMode\": \"list\",\n      \"placement\": \"bottom\",\n      \"calcs\": []\n    }\n  },\n  \"targets\": [\n    {\n      \"csvContent\": \"x, y\\n0, 5\\n5, 5\\n10, 10\\n20, 20\\n30, 20\\n40, 20\\n60, 10\",\n      \"datasource\": {\n        \"type\": \"testdata\",\n        \"uid\": \"PD8C576611E62080A\"\n      },\n      \"refId\": \"A\",\n      \"scenarioId\": \"csv_content\"\n    }\n  ],\n  \"title\": \"Panel Title\",\n  \"type\": \"trend\"\n}",
        "mode": "code",
        "code": {
          "language": "json",
          "showLineNumbers": true,
          "showMiniMap": true
        }
      }
    },
    {
      "id": 3,
      "title": "Data from panel above",
      "type": "table",
      "datasource": {
        "type": "datasource",
        "uid": "-- Dashboard --"
      },
      "gridPos": {
        "h": 7,
        "w": 15,
        "x": 0,
        "y": 13
      },
      "options": {
        "showTypeIcons": true
      },
      "targets": [
        {
          "datasource": {
            "type": "datasource",
            "uid": "-- Dashboard --"
          },
          "panelId": 2,
          "withTransforms": true,
          "refId": "A"
        }
      ]
    }
  ],
  "schemaVersion": 37,
  "title": "Debug: Panel Title // 2023-07-07 21:30:03",
  "tags": [
    "debug",
    "debug-trend"
  ],
  "time": {
    "from": "1970-01-01T00:01:40.000Z",
    "to": "1970-01-01T00:33:20.000Z"
  }
}

@drew08t drew08t added this to the 10.1.x milestone Jun 23, 2023
@drew08t drew08t self-assigned this Jun 23, 2023
@grafanabot grafanabot added the area/panel/timeseries The main time series Graph panel label Jun 23, 2023
@drew08t drew08t marked this pull request as ready for review July 8, 2023 01:14
@drew08t drew08t requested a review from a team as a code owner July 8, 2023 01:14
@drew08t drew08t changed the title [WIP] Trend: Add disconnect value option Trend: Add disconnect value option Jul 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2023

⚠️   Possible breaking changes

(Open the links below in a new tab to go to the correct steps)

grafana-ui has possible breaking changes (more info)

Console output
Read our guideline

@grafanabot grafanabot added the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Jul 8, 2023
@nmarrs nmarrs changed the title Trend: Add disconnect value option Trend: Support disconnect values and connect nulls options Jul 8, 2023
@nmarrs nmarrs self-assigned this Jul 10, 2023
val = rangeUtil.intervalToMs(txt);
} else {
val = Number(txt);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This block determines how we handle user input for threshold - by default isTime is set to true - in the case of trend panel we are passing false in module.tsx

packages/grafana-ui/src/components/GraphNG/utils.ts Outdated Show resolved Hide resolved
public/app/plugins/panel/timeseries/config.ts Show resolved Hide resolved
@nmarrs nmarrs requested review from leeoniya and ryantxu July 10, 2023 23:27
…f refFieldName is null / undefined; fix test
@leeoniya leeoniya force-pushed the drew08t/trend-disconnect-values branch from 467dab4 to c8bb9a8 Compare July 11, 2023 15:34
@nmarrs nmarrs removed the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Jul 12, 2023
@grafanabot grafanabot added the levitate breaking change A label indicating a breaking change and assigned by Levitate. label Jul 12, 2023
@tolzhabayev
Copy link
Contributor

@drew08t can you please take a look at breaking changes report?

@leeoniya
Copy link
Contributor

@drew08t can you please take a look at breaking changes report

GraphNG and its util funcs are all internal, so these arent real breaking changes. do we know if annotating them with @internal will help avoid this breaking-changes noise?

@nmarrs nmarrs requested a review from leeoniya July 14, 2023 00:16
leeoniya and others added 2 commits July 13, 2023 20:01
@nmarrs nmarrs requested a review from a team as a code owner July 14, 2023 01:46
@nmarrs nmarrs requested review from ivanortegaalba and polibb and removed request for a team July 14, 2023 01:46
@nmarrs nmarrs merged commit 1a85755 into main Jul 14, 2023
15 of 16 checks passed
@nmarrs nmarrs deleted the drew08t/trend-disconnect-values branch July 14, 2023 02:28
polibb pushed a commit that referenced this pull request Jul 14, 2023
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
@adela-almasan adela-almasan mentioned this pull request Jul 28, 2023
20 tasks
@ricky-undeadcoders ricky-undeadcoders modified the milestones: 10.1.x, 10.1.0 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend area/panel/state-timeline area/panel/timeseries The main time series Graph panel area/panel/trend levitate breaking change A label indicating a breaking change and assigned by Levitate. no-backport Skip backport of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trend: Add disconnect feature
6 participants