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

Fix for tooltip issue #379

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Entries

## v2.1.10

- Fix for filtering triggered composites in tooltips [[[#368](https://github.com/grafana/grafana-polystat-panel/issues/368)]]
- Remove deprecated ArrayVector usage (G11 compatibility)

## v2.1.9

- NEW: Option to display timestamp of metric inside polygon, available in Global Configuration Section
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grafana-polystat-panel",
"version": "2.1.9",
"version": "2.1.10",
"description": "Grafana Polystat Panel",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down Expand Up @@ -34,7 +34,7 @@
"@babel/helper-validator-option": "7.18.6",
"@braintree/sanitize-url": "^7.0.1",
"@grafana/eslint-config": "^7.0.0",
"@grafana/plugin-e2e": "^1.0.1",
"@grafana/plugin-e2e": "1.2.0",
"@grafana/tsconfig": "^1.3.0-rc1",
"@playwright/test": "^1.42.1",
"@swc/core": "^1.3.90",
Expand Down
13 changes: 10 additions & 3 deletions src/components/tooltips/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,26 @@ export const Tooltip = ({
}
return triggered;
};

const filterTriggered = (items: PolystatModel) => {
const triggerCount = getTriggeredCount(items);
// clone model
const compositeWithTriggeredItemsOnly = Object.assign({}, items);
// start with no triggered members
compositeWithTriggeredItemsOnly.members = [];
if (triggerCount > 0) {
for (let i = 0; i < items.members.length; i++) {
if (items.members[i].thresholdLevel === 0) {
items.members.splice(i, 1);
// non-OK (state 0) members will be appended to the cloned model
if (items.members[i].thresholdLevel !== 0) {
compositeWithTriggeredItemsOnly.members.push(items.members[i]);
}
}
return items;
return compositeWithTriggeredItemsOnly;
} else {
return null;
}
};

const getCompositeMetrics = (data: PolystatModel | null) => {
let dataToSort = data;
if (dataToSort && data && displayMode === 'triggered') {
Expand Down
6 changes: 3 additions & 3 deletions src/data/deframer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DataFrame, Field, FieldType, FieldConfig, ArrayVector, Labels } from '@grafana/data';
import { DataFrame, Field, FieldType, FieldConfig } from '@grafana/data';

// Inserts a "Time" field into each dataframe if it is missing
// the value of the timestamp is "now"
Expand Down Expand Up @@ -32,7 +32,7 @@ export function InsertTime(data: DataFrame[]): DataFrame[] {
newFrame.fields.push({
...copiedField,
labels: flattenLabels(frame, rowNum),
values: new ArrayVector([getValueOfField(copiedField, rowNum)]),
values: [getValueOfField(copiedField, rowNum)] as any,
});
}
}
Expand All @@ -47,7 +47,7 @@ export function InsertTime(data: DataFrame[]): DataFrame[] {
}
}
if (!hasTimestamp) {
const z = new ArrayVector();
const z = [] as any;
z.add(timeToInsert);
const fc: FieldConfig = {};
const timeField: Field = {
Expand Down
Loading
Loading