Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
components
/
GraphNG
/
File Content:
hooks.ts
import React, { useCallback, useContext } from 'react'; import { DataFrame, DataFrameFieldIndex, Field } from '@grafana/data'; import { XYFieldMatchers } from './types'; /** @alpha */ interface GraphNGContextType { mapSeriesIndexToDataFrameFieldIndex: (index: number) => DataFrameFieldIndex; dimFields: XYFieldMatchers; data: DataFrame; } /** @alpha */ export const GraphNGContext = React.createContext<GraphNGContextType>({} as GraphNGContextType); /** * @alpha * Exposes API for data frame inspection in Plot plugins */ export const useGraphNGContext = () => { const { data, dimFields, mapSeriesIndexToDataFrameFieldIndex } = useContext<GraphNGContextType>(GraphNGContext); const getXAxisField = useCallback(() => { const xFieldMatcher = dimFields.x; let xField: Field | null = null; for (let j = 0; j < data.fields.length; j++) { if (xFieldMatcher(data.fields[j], data, [data])) { xField = data.fields[j]; break; } } return xField; }, [data, dimFields]); return { dimFields, mapSeriesIndexToDataFrameFieldIndex, getXAxisField, alignedData: data, }; };
Edit
Rename
Chmod
Delete
FILE
FOLDER
INFO
Name
Size
Permission
Action
__snapshots__
---
0755
GraphNG.tsx
8225 bytes
0644
hooks.ts
1147 bytes
0644
types.ts
431 bytes
0644
utils.test.ts
12132 bytes
0644
utils.ts
3996 bytes
0644
N4ST4R_ID | Naxtarrr