Skip to content

Commit 8ba9f74

Browse files
committed
clean up
1 parent ac0d745 commit 8ba9f74

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

src/EsnetMatrix.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ import { useTheme2, CustomScrollbar } from '@grafana/ui';
88
import * as Matrix from './matrix.js';
99
// import * as Legend from 'matrixLegend.js';
1010

11-
interface Props extends PanelProps<MatrixOptions> {}
11+
interface Props extends PanelProps<MatrixOptions> {
12+
fieldConfig: any;
13+
options: MatrixOptions;
14+
}
1215

1316
export const EsnetMatrix: React.FC<Props> = ({ options, data, width, height, id }) => {
17+
// console.log(data);
1418
const theme = useTheme2();
19+
console.log(options);
1520
const parsedData = parseData(data, options, theme);
1621
try {
1722
if (parsedData.data === 'too many inputs') {

src/dataParser.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function parseData(data: { series: any[] }, options: any, theme: any) {
3838
if (!targetKey) {
3939
targetKey = 1;
4040
}
41+
4142
// assign valueField to the specified field or use the first number field by default
4243
const val = options.valueField;
4344
const valueField = val
@@ -105,6 +106,7 @@ export function parseData(data: { series: any[] }, options: any, theme: any) {
105106

106107
////////////////////////////
107108

109+
// console.log(options);
108110
// create data matrix
109111
let dataMatrix: any[][] = [];
110112
for (let i = 0; i < rowNames.length; i++) {
@@ -128,9 +130,10 @@ export function parseData(data: { series: any[] }, options: any, theme: any) {
128130
// parse data for legend
129131
let legendData: any[] = [];
130132
if (options.showLegend) {
133+
131134
// let allVals = frame.fields[valKey].values;
132135
let tempValues: any[] = [];
133-
if (options.legendType == 'range') {
136+
if (options.legendType === 'range') {
134137
//get min & max, steps
135138
let allValues: number[] = Object.values(frame.fields[valKey].values);
136139
let thisMin = Math.min(...allValues);
@@ -160,8 +163,8 @@ export function parseData(data: { series: any[] }, options: any, theme: any) {
160163
});
161164
});
162165
}
163-
console.log(legendData);
166+
// console.log(legendData);
164167

165-
var dataObject = { rows: rowNames, columns: colNames, data: dataMatrix, legend: legendData };
168+
let dataObject = { rows: rowNames, columns: colNames, data: dataMatrix, legend: legendData };
166169
return dataObject;
167170
}

src/matrix.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
2424
urlVar1 = options.urlVar1,
2525
urlVar2 = options.urlVar2,
2626
defaultColor = theme.visualization.getColorByName(options.defaultColor);
27+
2728
// urlOther = options.urlOther,
2829
// urlOtherText = options.urlOtherText;
2930

@@ -250,6 +251,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
250251
.append('svg')
251252
.attr('id', legendClass);
252253

254+
////////////// range - bar //////////////////////
253255
if (options.legendType == 'range') {
254256
var svg = d3.select(`#${legendClass}`);
255257
svg
@@ -287,7 +289,7 @@ function createViz(elem, id, height, rowNames, colNames, matrix, options, theme,
287289
})
288290
.attr('fill', theme.colors.text.primary);
289291
} else {
290-
// categorical
292+
/////////// categorical - circles ////////////////////////////
291293
var svg = d3.select(`#${legendClass}`);
292294
svg
293295
.append('g')

src/module.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { FieldOverrideContext, getFieldDisplayName, PanelPlugin, FieldConfigProperty } from '@grafana/data';
2-
import { standardOptionsCompat } from 'grafana-plugin-support';
2+
// import { standardOptionsCompat } from 'grafana-plugin-support';
33
import { MatrixOptions } from './types';
44
import { EsnetMatrix } from './EsnetMatrix';
5+
// import { FieldConfig } from './panelcfg.gen';
56

67
/**
78
* Grafana panel plugin main module
@@ -20,15 +21,28 @@ const urlBool = (addUrl: boolean) => (config: MatrixOptions) => config.addUrl ==
2021
const staticBool = (inputList: boolean) => (config: MatrixOptions) => config.inputList === inputList;
2122
const legendBool = (showLegend: boolean) => (config: MatrixOptions) => config.showLegend === showLegend;
2223

23-
const buildStandardOptions = (): any => {
24-
const options = [FieldConfigProperty.Unit, FieldConfigProperty.Color, FieldConfigProperty.Thresholds];
25-
return standardOptionsCompat(options);
26-
};
24+
// const buildStandardOptions = (): any => {
25+
// const options = [FieldConfigProperty.Unit, FieldConfigProperty.Color, FieldConfigProperty.Thresholds];
26+
// return standardOptionsCompat(options);
27+
// };
2728

2829
export const plugin = new PanelPlugin<MatrixOptions>(EsnetMatrix);
30+
2931
plugin.useFieldConfig({
30-
standardOptions: buildStandardOptions(),
32+
standardOptions: {
33+
[FieldConfigProperty.Thresholds]: {},
34+
[FieldConfigProperty.Color]: {
35+
settings: {
36+
preferThresholdMode: true,
37+
}
38+
}
39+
},
40+
disableStandardOptions: [
41+
FieldConfigProperty.NoValue,
42+
FieldConfigProperty.Links,
43+
]
3144
});
45+
3246
plugin.setPanelOptions((builder) => {
3347
/////////--------- Row and Column options ---------////////////////
3448
builder.addBooleanSwitch({
@@ -283,5 +297,3 @@ plugin.setPanelOptions((builder) => {
283297
// showIf: urlOtherBool(true),
284298
// });
285299
});
286-
287-
// .useFieldConfig({});

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ export interface MatrixOptions {
2222
staticColumns: string[];
2323
showLegend: boolean;
2424
legendType: string;
25+
thresholds: any[];
2526
}

0 commit comments

Comments
 (0)