Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
KatrinaTurner committed Apr 30, 2024
2 parents 189a86d + e037886 commit 403b48c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netsage-sankey-panel",
"version": "1.1.1",
"version": "1.1.2",
"description": "Sankey Panel Plugin for Grafana",
"license": "Apache-2.0",
"repository": "https://github.com/netsage-project/netsage-sankey-panel",
Expand Down
10 changes: 6 additions & 4 deletions src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ export const Tooltip: React.FC<TooltipProps> = ({ rowNames, field, panelId }) =>
return text;
})
.style('padding', '10px 15px')
.style('background', 'black')
.style('background', '#19191A')
.style('color', 'white')
.style('border', '#A8A8A8 solid 5px')
.style('border', '#A8A8A8 solid 2px')
.style('border-radius', '5px')
.style('left', mousePosition.mouseX + 'px')
.style('top', mousePosition.mouseY + 'px')
.style('opacity', 0)
.style('z-index','1')
.style('position', 'absolute');
div.transition().duration(200).style('opacity', 0.8);
})
Expand Down Expand Up @@ -91,13 +92,14 @@ export const Tooltip: React.FC<TooltipProps> = ({ rowNames, field, panelId }) =>
return text;
})
.style('padding', '10px 15px')
.style('background', 'black')
.style('background', '#19191A')
.style('color', 'white')
.style('border', '#A8A8A8 solid 5px')
.style('border', '#A8A8A8 solid 2px')
.style('border-radius', '5px')
.style('left', mousePosition.mouseX + 'px')
.style('top', mousePosition.mouseY + 'px')
.style('opacity', 0)
.style('z-index', '1')
.style('position', 'absolute');
div.transition().duration(200).style('opacity', 0.8);
})
Expand Down
24 changes: 18 additions & 6 deletions src/dataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DataFrameView, Field, getFieldDisplayName, Vector } from '@grafana/data
* @return {valueField[0]}
*/
export function parseData(data: { series: any[] }, options: { valueField: any }, monochrome: boolean, color: any) {
const valueFieldName = options.valueField;


/**
* Colors
Expand Down Expand Up @@ -126,13 +126,25 @@ export function parseData(data: { series: any[] }, options: { valueField: any },
});

// Find selected value field or default to the first number field and use for values.
const valueField = valueFieldName
? data.series.map((series: { fields: any[] }) =>
series.fields.find((field: { name: any }) => field.name === valueFieldName)
)
: data.series.map((series: { fields: any[] }) =>
// const valueFieldName = options.valueField;
// const valueField = options.valueField
// ? data.series.map((series: { fields: any[] }) =>
// series.fields.find((field: { name: any }) => field.name === options.valueField)
// )
// : data.series.map((series: { fields: any[] }) =>
// series.fields.find((field: { type: string }) => field.type === 'number')
// );
// Fix to avoid erroring out when value field is hidden by transform
let valueField = data.series.map((series: { fields: any[] }) =>
series.fields.find((field: { name: any }) => field.name === options.valueField)
)
if(!valueField[0]) {
valueField = data.series.map((series: { fields: any[] }) =>
series.fields.find((field: { type: string }) => field.type === 'number')
);
}



let values = [];
valueField[0].values.map((value: any) => {
Expand Down

0 comments on commit 403b48c

Please sign in to comment.