Skip to content

Commit

Permalink
Merge pull request #27 from netsage-project/1.1.3
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
KatrinaTurner committed May 1, 2024
2 parents 403b48c + bbd8e89 commit aaf3b66
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 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.2",
"version": "1.1.3",
"description": "Sankey Panel Plugin for Grafana",
"license": "Apache-2.0",
"repository": "https://github.com/netsage-project/netsage-sankey-panel",
Expand Down
1 change: 1 addition & 0 deletions src/SankeyPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const SankeyPanel: React.FC<Props> = ({ options, data, width, height, id
field={field}
nodeWidth={graphOptions.nodeWidth}
nodePadding={graphOptions.nodePadding}
labelSize={graphOptions.labelSize}
iteration={graphOptions.iteration}
/>
</g>
Expand Down
10 changes: 6 additions & 4 deletions src/components/Node.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { useTheme2 } from '@grafana/ui';
// import { useTheme2 } from '@grafana/ui';

interface NodeProps {
data: any;
textColor: string;
nodeColor: string;
panelId: any;
labelSize: number;
}

/**
Expand All @@ -16,8 +17,8 @@ interface NodeProps {
* @param nodeColor is set in the editor panel, the fill color of the nodes
* @return {*} the node and its label
*/
export const Node: React.FC<NodeProps> = ({ data, textColor, nodeColor, panelId }) => {
const theme = useTheme2();
export const Node: React.FC<NodeProps> = ({ data, textColor, nodeColor, panelId, labelSize }) => {
// const theme = useTheme2();

let x0 = data.x0;
let x1 = data.x1;
Expand All @@ -29,7 +30,8 @@ export const Node: React.FC<NodeProps> = ({ data, textColor, nodeColor, panelId

const width = x1 - x0;
const strokeColor = 'black';
const fontSize = theme.typography.fontSize;
// const fontSize = theme.typography.fontSize;
const fontSize = labelSize+'px';
const className = `sankey-node${panelId}`;

return (
Expand Down
4 changes: 3 additions & 1 deletion src/components/Sankey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface SankeyProps {
field: any;
nodeWidth: number;
nodePadding: number;
labelSize: number;
iteration: number;
}

Expand All @@ -40,6 +41,7 @@ export const Sankey: React.FC<SankeyProps> = ({
field,
nodeWidth,
nodePadding,
labelSize,
iteration,
}) => {
// const theme = useTheme2();
Expand Down Expand Up @@ -78,7 +80,7 @@ export const Sankey: React.FC<SankeyProps> = ({
</g>
<g transform={`translate(${MARGIN.left}, ${MARGIN.top})`}>
{nodes.map((d: { index: any; x0: any; x1: any; y0: any; y1: any; name: any; value: any }, i: any) => (
<Node data={d} key={i} textColor={textColor} nodeColor={nodeColor} panelId={id} />
<Node data={d} key={i} textColor={textColor} nodeColor={nodeColor} panelId={id} labelSize={labelSize} />
))}
</g>
</svg>
Expand Down
14 changes: 13 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ export const plugin = new PanelPlugin<SankeyOptions>(SankeyPanel)
step: 1,
},
})
.addSliderInput({
path: 'labelSize',
name: 'Label Size',
description: 'The font size of the labels in px',
defaultValue: 14,
settings: {
min: 6,
max: 24,
step: 1,
},
})
.addSelect({
path: 'valueField',
name: 'Value Field',
Expand All @@ -73,7 +84,8 @@ export const plugin = new PanelPlugin<SankeyOptions>(SankeyPanel)
},
},
// defaultValue: options[0],
}).addSliderInput({
})
.addSliderInput({
path: 'iteration',
name: 'Layout iterations',
defaultValue: 7,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface SankeyOptions {
nodePadding: number;
iteration: number;
valueField: string;
labelSize: number;
}

export interface SankeyFieldConfig {}

0 comments on commit aaf3b66

Please sign in to comment.