mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Moves GraphSeriesXY and DisplayValue to grafana/data (#18400)
* Chore: Move DisplayValue to grafana/data * Chore: Move GraphSeriesXY to grafana/data
This commit is contained in:
parent
ead2d6e88f
commit
b05afd7e4e
@ -7,3 +7,5 @@ export * from './time';
|
|||||||
export * from './threshold';
|
export * from './threshold';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
export * from './valueMapping';
|
export * from './valueMapping';
|
||||||
|
export * from './displayValue';
|
||||||
|
export * from './graph';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
import { DisplayValue } from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
BarGauge,
|
BarGauge,
|
||||||
Props,
|
Props,
|
||||||
@ -9,7 +10,7 @@ import {
|
|||||||
getTitleStyles,
|
getTitleStyles,
|
||||||
getValuePercent,
|
getValuePercent,
|
||||||
} from './BarGauge';
|
} from './BarGauge';
|
||||||
import { VizOrientation, DisplayValue } from '../../types';
|
import { VizOrientation } from '../../types';
|
||||||
import { getTheme } from '../../themes';
|
import { getTheme } from '../../themes';
|
||||||
|
|
||||||
// jest.mock('jquery', () => ({
|
// jest.mock('jquery', () => ({
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// Library
|
// Library
|
||||||
import React, { PureComponent, CSSProperties, ReactNode } from 'react';
|
import React, { PureComponent, CSSProperties, ReactNode } from 'react';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
|
import { Threshold, TimeSeriesValue, getActiveThreshold, DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getColorFromHexRgbOrName } from '../../utils';
|
import { getColorFromHexRgbOrName } from '../../utils';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { DisplayValue, Themeable, VizOrientation } from '../../types';
|
import { Themeable, VizOrientation } from '../../types';
|
||||||
import { Threshold, TimeSeriesValue, getActiveThreshold } from '@grafana/data';
|
|
||||||
|
|
||||||
const MIN_VALUE_HEIGHT = 18;
|
const MIN_VALUE_HEIGHT = 18;
|
||||||
const MAX_VALUE_HEIGHT = 50;
|
const MAX_VALUE_HEIGHT = 50;
|
||||||
|
@ -2,12 +2,13 @@
|
|||||||
import React, { PureComponent, ReactNode, CSSProperties } from 'react';
|
import React, { PureComponent, ReactNode, CSSProperties } from 'react';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
|
import { DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getColorFromHexRgbOrName } from '../../utils';
|
import { getColorFromHexRgbOrName } from '../../utils';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { Themeable, DisplayValue } from '../../types';
|
import { Themeable } from '../../types';
|
||||||
|
|
||||||
export interface BigValueSparkline {
|
export interface BigValueSparkline {
|
||||||
data: any[][]; // [[number,number]]
|
data: any[][]; // [[number,number]]
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
import { Threshold, DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
import { getColorFromHexRgbOrName } from '../../utils';
|
import { getColorFromHexRgbOrName } from '../../utils';
|
||||||
import { DisplayValue, Themeable } from '../../types';
|
import { Themeable } from '../../types';
|
||||||
import { selectThemeVariant } from '../../themes';
|
import { selectThemeVariant } from '../../themes';
|
||||||
import { Threshold } from '@grafana/data';
|
|
||||||
|
|
||||||
export interface Props extends Themeable {
|
export interface Props extends Themeable {
|
||||||
height: number;
|
height: number;
|
||||||
|
@ -4,8 +4,7 @@ import React, { PureComponent } from 'react';
|
|||||||
import uniqBy from 'lodash/uniqBy';
|
import uniqBy from 'lodash/uniqBy';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { GraphSeriesXY } from '../../types';
|
import { TimeRange, GraphSeriesXY } from '@grafana/data';
|
||||||
import { TimeRange } from '@grafana/data';
|
|
||||||
|
|
||||||
export interface GraphProps {
|
export interface GraphProps {
|
||||||
series: GraphSeriesXY[];
|
series: GraphSeriesXY[];
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
|
import { GraphSeriesValue } from '@grafana/data';
|
||||||
|
|
||||||
import { Graph, GraphProps } from './Graph';
|
import { Graph, GraphProps } from './Graph';
|
||||||
import { LegendRenderOptions, LegendItem, LegendDisplayMode } from '../Legend/Legend';
|
import { LegendRenderOptions, LegendItem, LegendDisplayMode } from '../Legend/Legend';
|
||||||
import { GraphLegend } from './GraphLegend';
|
import { GraphLegend } from './GraphLegend';
|
||||||
import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar';
|
import { CustomScrollbar } from '../CustomScrollbar/CustomScrollbar';
|
||||||
import { GraphSeriesValue } from '../../types/graph';
|
|
||||||
|
|
||||||
export type SeriesOptionChangeHandler<TOption> = (label: string, option: TOption) => void;
|
export type SeriesOptionChangeHandler<TOption> = (label: string, option: TOption) => void;
|
||||||
export type SeriesColorChangeHandler = SeriesOptionChangeHandler<string>;
|
export type SeriesColorChangeHandler = SeriesOptionChangeHandler<string>;
|
||||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { storiesOf } from '@storybook/react';
|
import { storiesOf } from '@storybook/react';
|
||||||
import { LegendList, LegendPlacement, LegendItem, LegendTable } from './Legend';
|
import { LegendList, LegendPlacement, LegendItem, LegendTable } from './Legend';
|
||||||
import tinycolor from 'tinycolor2';
|
import tinycolor from 'tinycolor2';
|
||||||
import { DisplayValue } from '../../types/index';
|
import { DisplayValue } from '@grafana/data';
|
||||||
import { number, select, text } from '@storybook/addon-knobs';
|
import { number, select, text } from '@storybook/addon-knobs';
|
||||||
import { action } from '@storybook/addon-actions';
|
import { action } from '@storybook/addon-actions';
|
||||||
import { GraphLegendListItem, GraphLegendTableRow, GraphLegendItemProps } from '../Graph/GraphLegendItem';
|
import { GraphLegendListItem, GraphLegendTableRow, GraphLegendItemProps } from '../Graph/GraphLegendItem';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { DisplayValue } from '../../types/index';
|
import { DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
import { LegendList } from './LegendList';
|
import { LegendList } from './LegendList';
|
||||||
import { LegendTable } from './LegendTable';
|
import { LegendTable } from './LegendTable';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { InlineList } from '../List/InlineList';
|
import { InlineList } from '../List/InlineList';
|
||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
import { DisplayValue } from '../../types/displayValue';
|
import { DisplayValue } from '@grafana/data';
|
||||||
import capitalize from 'lodash/capitalize';
|
import capitalize from 'lodash/capitalize';
|
||||||
|
|
||||||
const LegendItemStat: React.FunctionComponent<{ stat: DisplayValue }> = ({ stat }) => {
|
const LegendItemStat: React.FunctionComponent<{ stat: DisplayValue }> = ({ stat }) => {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { select, pie, arc, event } from 'd3';
|
import { select, pie, arc, event } from 'd3';
|
||||||
import sum from 'lodash/sum';
|
import sum from 'lodash/sum';
|
||||||
|
import { DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
import { GrafanaThemeType, DisplayValue } from '../../types';
|
import { GrafanaThemeType } from '../../types';
|
||||||
import { Themeable } from '../../index';
|
import { Themeable } from '../../index';
|
||||||
import { colors as grafana_colors } from '../../utils/index';
|
import { colors as grafana_colors } from '../../utils/index';
|
||||||
|
|
||||||
|
@ -3,6 +3,4 @@ export * from './plugin';
|
|||||||
export * from './app';
|
export * from './app';
|
||||||
export * from './datasource';
|
export * from './datasource';
|
||||||
export * from './theme';
|
export * from './theme';
|
||||||
export * from './graph';
|
|
||||||
export * from './input';
|
export * from './input';
|
||||||
export * from './displayValue';
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { MappingType, ValueMapping, DisplayValue } from '@grafana/data';
|
||||||
|
|
||||||
import { getDisplayProcessor, getColorFromThreshold, DisplayProcessor, getDecimalsForValue } from './displayValue';
|
import { getDisplayProcessor, getColorFromThreshold, DisplayProcessor, getDecimalsForValue } from './displayValue';
|
||||||
import { DisplayValue } from '../types';
|
|
||||||
import { MappingType, ValueMapping } from '@grafana/data';
|
|
||||||
|
|
||||||
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
|
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) {
|
||||||
processors.forEach(processor => {
|
processors.forEach(processor => {
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
// Libraries
|
// Libraries
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import {
|
||||||
|
DateTime,
|
||||||
|
dateTime,
|
||||||
|
Threshold,
|
||||||
|
getMappedValue,
|
||||||
|
Field,
|
||||||
|
DecimalInfo,
|
||||||
|
DisplayValue,
|
||||||
|
DecimalCount,
|
||||||
|
} from '@grafana/data';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getValueFormat } from './valueFormats/valueFormats';
|
import { getValueFormat } from './valueFormats/valueFormats';
|
||||||
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
import { getColorFromHexRgbOrName } from './namedColorsPalette';
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { DecimalInfo, DisplayValue, GrafanaTheme, GrafanaThemeType, DecimalCount } from '../types';
|
import { GrafanaTheme, GrafanaThemeType } from '../types';
|
||||||
import { DateTime, dateTime, Threshold, getMappedValue, Field } from '@grafana/data';
|
|
||||||
|
|
||||||
export type DisplayProcessor = (value: any) => DisplayValue;
|
export type DisplayProcessor = (value: any) => DisplayValue;
|
||||||
|
|
||||||
|
@ -1,10 +1,20 @@
|
|||||||
|
import {
|
||||||
|
ReducerID,
|
||||||
|
reduceField,
|
||||||
|
FieldType,
|
||||||
|
NullValueMode,
|
||||||
|
DataFrame,
|
||||||
|
Field,
|
||||||
|
DisplayValue,
|
||||||
|
GraphSeriesValue,
|
||||||
|
} from '@grafana/data';
|
||||||
|
|
||||||
import toNumber from 'lodash/toNumber';
|
import toNumber from 'lodash/toNumber';
|
||||||
import toString from 'lodash/toString';
|
import toString from 'lodash/toString';
|
||||||
|
|
||||||
import { DisplayValue, GrafanaTheme, InterpolateFunction, ScopedVars, GraphSeriesValue } from '../types/index';
|
import { GrafanaTheme, InterpolateFunction, ScopedVars } from '../types/index';
|
||||||
import { getDisplayProcessor } from './displayValue';
|
import { getDisplayProcessor } from './displayValue';
|
||||||
import { getFlotPairs } from './flotPairs';
|
import { getFlotPairs } from './flotPairs';
|
||||||
import { ReducerID, reduceField, FieldType, NullValueMode, DataFrame, Field } from '@grafana/data';
|
|
||||||
|
|
||||||
export interface FieldDisplayOptions {
|
export interface FieldDisplayOptions {
|
||||||
values?: boolean; // If true show each row value
|
values?: boolean; // If true show each row value
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// Types
|
// Types
|
||||||
import { GraphSeriesValue } from '../types/index';
|
import { NullValueMode, DataFrame, GraphSeriesValue } from '@grafana/data';
|
||||||
import { NullValueMode, DataFrame } from '@grafana/data';
|
|
||||||
|
|
||||||
export interface FlotPairsOptions {
|
export interface FlotPairsOptions {
|
||||||
series: DataFrame;
|
series: DataFrame;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import { DecimalCount } from '@grafana/data';
|
||||||
|
|
||||||
import { toFixed } from './valueFormats';
|
import { toFixed } from './valueFormats';
|
||||||
import { DecimalCount } from '../../types';
|
|
||||||
|
|
||||||
export function toPercent(size: number, decimals: DecimalCount) {
|
export function toPercent(size: number, decimals: DecimalCount) {
|
||||||
if (size === null) {
|
if (size === null) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
import { toUtc, toDuration as duration, dateTime, DecimalCount } from '@grafana/data';
|
||||||
|
|
||||||
import { toFixed, toFixedScaled } from './valueFormats';
|
import { toFixed, toFixedScaled } from './valueFormats';
|
||||||
import { DecimalCount } from '../../types';
|
|
||||||
import { toUtc, toDuration as duration, dateTime } from '@grafana/data';
|
|
||||||
|
|
||||||
interface IntervalsInSeconds {
|
interface IntervalsInSeconds {
|
||||||
[interval: string]: number;
|
[interval: string]: number;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import { DecimalCount } from '@grafana/data';
|
||||||
|
|
||||||
import { scaledUnits } from './valueFormats';
|
import { scaledUnits } from './valueFormats';
|
||||||
import { DecimalCount } from '../../types';
|
|
||||||
|
|
||||||
export function currency(symbol: string) {
|
export function currency(symbol: string) {
|
||||||
const units = ['', 'K', 'M', 'B', 'T'];
|
const units = ['', 'K', 'M', 'B', 'T'];
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import { DecimalCount } from '@grafana/data';
|
||||||
|
|
||||||
import { getCategories } from './categories';
|
import { getCategories } from './categories';
|
||||||
import { DecimalCount } from '../../types';
|
|
||||||
|
|
||||||
export type ValueFormatter = (
|
export type ValueFormatter = (
|
||||||
value: number,
|
value: number,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getFlotTickDecimals } from 'app/core/utils/ticks';
|
import { getFlotTickDecimals } from 'app/core/utils/ticks';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { getValueFormat, ValueFormatter, DecimalCount } from '@grafana/ui';
|
import { getValueFormat, ValueFormatter } from '@grafana/ui';
|
||||||
import { stringToJsRegex } from '@grafana/data';
|
import { stringToJsRegex, DecimalCount } from '@grafana/data';
|
||||||
|
|
||||||
function matchSeriesOverride(aliasOrRegex: string, seriesAlias: string) {
|
function matchSeriesOverride(aliasOrRegex: string, seriesAlias: string) {
|
||||||
if (!aliasOrRegex) {
|
if (!aliasOrRegex) {
|
||||||
|
@ -3,7 +3,7 @@ import $ from 'jquery';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import Drop from 'tether-drop';
|
import Drop from 'tether-drop';
|
||||||
import { CreatePlotOverlay } from '@grafana/ui';
|
import { CreatePlotOverlay } from '@grafana/data';
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
const createAnnotationToolip: CreatePlotOverlay = (element, event, plot) => {
|
const createAnnotationToolip: CreatePlotOverlay = (element, event, plot) => {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { GraphSeriesXY, PanelData } from '@grafana/ui';
|
import { PanelData } from '@grafana/ui';
|
||||||
|
import { GraphSeriesXY } from '@grafana/data';
|
||||||
import difference from 'lodash/difference';
|
import difference from 'lodash/difference';
|
||||||
|
|
||||||
import { getGraphSeriesModel } from './getGraphSeriesModel';
|
import { getGraphSeriesModel } from './getGraphSeriesModel';
|
||||||
import { Options, SeriesOptions } from './types';
|
import { Options, SeriesOptions } from './types';
|
||||||
import { SeriesColorChangeHandler, SeriesAxisToggleHandler } from '@grafana/ui/src/components/Graph/GraphWithLegend';
|
import { SeriesColorChangeHandler, SeriesAxisToggleHandler } from '@grafana/ui/src/components/Graph/GraphWithLegend';
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
import {
|
import { colors, getFlotPairs, getColorFromHexRgbOrName, getDisplayProcessor, PanelData } from '@grafana/ui';
|
||||||
GraphSeriesXY,
|
import { NullValueMode, reduceField, FieldCache, FieldType, DisplayValue, GraphSeriesXY } from '@grafana/data';
|
||||||
colors,
|
|
||||||
getFlotPairs,
|
|
||||||
getColorFromHexRgbOrName,
|
|
||||||
getDisplayProcessor,
|
|
||||||
DisplayValue,
|
|
||||||
PanelData,
|
|
||||||
} from '@grafana/ui';
|
|
||||||
import { NullValueMode, reduceField, FieldCache, FieldType } from '@grafana/data';
|
|
||||||
import { SeriesOptions, GraphOptions } from './types';
|
import { SeriesOptions, GraphOptions } from './types';
|
||||||
import { GraphLegendEditorLegendOptions } from './GraphLegendEditor';
|
import { GraphLegendEditorLegendOptions } from './GraphLegendEditor';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user