Skip to content

Commit aaf3b66

Browse files
Merge pull request #27 from netsage-project/1.1.3
1.1.3
2 parents 403b48c + bbd8e89 commit aaf3b66

6 files changed

Lines changed: 25 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netsage-sankey-panel",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Sankey Panel Plugin for Grafana",
55
"license": "Apache-2.0",
66
"repository": "https://github.com/netsage-project/netsage-sankey-panel",

src/SankeyPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const SankeyPanel: React.FC<Props> = ({ options, data, width, height, id
5151
field={field}
5252
nodeWidth={graphOptions.nodeWidth}
5353
nodePadding={graphOptions.nodePadding}
54+
labelSize={graphOptions.labelSize}
5455
iteration={graphOptions.iteration}
5556
/>
5657
</g>

src/components/Node.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react';
2-
import { useTheme2 } from '@grafana/ui';
2+
// import { useTheme2 } from '@grafana/ui';
33

44
interface NodeProps {
55
data: any;
66
textColor: string;
77
nodeColor: string;
88
panelId: any;
9+
labelSize: number;
910
}
1011

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

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

3031
const width = x1 - x0;
3132
const strokeColor = 'black';
32-
const fontSize = theme.typography.fontSize;
33+
// const fontSize = theme.typography.fontSize;
34+
const fontSize = labelSize+'px';
3335
const className = `sankey-node${panelId}`;
3436

3537
return (

src/components/Sankey.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface SankeyProps {
2222
field: any;
2323
nodeWidth: number;
2424
nodePadding: number;
25+
labelSize: number;
2526
iteration: number;
2627
}
2728

@@ -40,6 +41,7 @@ export const Sankey: React.FC<SankeyProps> = ({
4041
field,
4142
nodeWidth,
4243
nodePadding,
44+
labelSize,
4345
iteration,
4446
}) => {
4547
// const theme = useTheme2();
@@ -78,7 +80,7 @@ export const Sankey: React.FC<SankeyProps> = ({
7880
</g>
7981
<g transform={`translate(${MARGIN.left}, ${MARGIN.top})`}>
8082
{nodes.map((d: { index: any; x0: any; x1: any; y0: any; y1: any; name: any; value: any }, i: any) => (
81-
<Node data={d} key={i} textColor={textColor} nodeColor={nodeColor} panelId={id} />
83+
<Node data={d} key={i} textColor={textColor} nodeColor={nodeColor} panelId={id} labelSize={labelSize} />
8284
))}
8385
</g>
8486
</svg>

src/module.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ export const plugin = new PanelPlugin<SankeyOptions>(SankeyPanel)
5151
step: 1,
5252
},
5353
})
54+
.addSliderInput({
55+
path: 'labelSize',
56+
name: 'Label Size',
57+
description: 'The font size of the labels in px',
58+
defaultValue: 14,
59+
settings: {
60+
min: 6,
61+
max: 24,
62+
step: 1,
63+
},
64+
})
5465
.addSelect({
5566
path: 'valueField',
5667
name: 'Value Field',
@@ -73,7 +84,8 @@ export const plugin = new PanelPlugin<SankeyOptions>(SankeyPanel)
7384
},
7485
},
7586
// defaultValue: options[0],
76-
}).addSliderInput({
87+
})
88+
.addSliderInput({
7789
path: 'iteration',
7890
name: 'Layout iterations',
7991
defaultValue: 7,

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface SankeyOptions {
77
nodePadding: number;
88
iteration: number;
99
valueField: string;
10+
labelSize: number;
1011
}
1112

1213
export interface SankeyFieldConfig {}

0 commit comments

Comments
 (0)