mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* added moment timezone package. * added a qnd way of selecting timezone. * added a first draft to display how it can be used. * fixed failing tests. * made moment.local to be in utc when running tests. * added tests to verify that the timeZone support works as expected. * Fixed so we use the formatter in the graph context menu. * changed so we will format d3 according to timeZone. * changed from class base to function based for easier consumption. * fixed so tests got green. * renamed to make it shorter. * fixed formatting in logRow. * removed unused value. * added time formatter to flot. * fixed failing tests. * changed so history will use the formatting with support for timezone. * added todo. * added so we append the correct abbrivation behind time. * added time zone abbrevation in timepicker. * adding timezone in rangeutil tool. * will use timezone when formatting range. * changed so we use new functions to format date so timezone is respected. * wip - dashboard settings. * changed so the time picker settings is in react. * added force update. * wip to get the react graph to work. * fixed formatting and parsing on the timepicker. * updated snap to be correct. * fixed so we format values properly in time picker. * make sure we pass timezone on all the proper places. * fixed so we use correct timeZone in explore. * fixed failing tests. * fixed so we always parse from local to selected timezone. * removed unused variable. * reverted back. * trying to fix issue with directive. * fixed issue. * fixed strict null errors. * fixed so we still can select default. * make sure we reads the time zone from getTimezone
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
// Libraries
|
|
import React, { PureComponent } from 'react';
|
|
|
|
// Services & Utils
|
|
import { config } from 'app/core/config';
|
|
|
|
import { BarGauge, VizRepeater, VizRepeaterRenderValueProps, DataLinksContextMenu } from '@grafana/ui';
|
|
import { BarGaugeOptions } from './types';
|
|
import {
|
|
getFieldDisplayValues,
|
|
FieldDisplay,
|
|
PanelProps,
|
|
getDisplayValueAlignmentFactors,
|
|
DisplayValueAlignmentFactors,
|
|
} from '@grafana/data';
|
|
|
|
export class BarGaugePanel extends PureComponent<PanelProps<BarGaugeOptions>> {
|
|
renderValue = (valueProps: VizRepeaterRenderValueProps<FieldDisplay, DisplayValueAlignmentFactors>): JSX.Element => {
|
|
const { options } = this.props;
|
|
const { value, alignmentFactors, orientation, width, height } = valueProps;
|
|
const { field, display, view, colIndex } = value;
|
|
|
|
return (
|
|
<DataLinksContextMenu links={value.getLinks}>
|
|
{({ openMenu, targetClassName }) => {
|
|
return (
|
|
<BarGauge
|
|
value={display}
|
|
width={width}
|
|
height={height}
|
|
orientation={orientation}
|
|
field={field}
|
|
display={view?.getFieldDisplayProcessor(colIndex)}
|
|
theme={config.theme}
|
|
itemSpacing={this.getItemSpacing()}
|
|
displayMode={options.displayMode}
|
|
onClick={openMenu}
|
|
className={targetClassName}
|
|
alignmentFactors={alignmentFactors}
|
|
showUnfilled={options.showUnfilled}
|
|
/>
|
|
);
|
|
}}
|
|
</DataLinksContextMenu>
|
|
);
|
|
};
|
|
|
|
getValues = (): FieldDisplay[] => {
|
|
const { data, options, replaceVariables, fieldConfig, timeZone } = this.props;
|
|
return getFieldDisplayValues({
|
|
fieldConfig,
|
|
reduceOptions: options.reduceOptions,
|
|
replaceVariables,
|
|
theme: config.theme,
|
|
data: data.series,
|
|
autoMinMax: true,
|
|
timeZone,
|
|
});
|
|
};
|
|
|
|
getItemSpacing(): number {
|
|
if (this.props.options.displayMode === 'lcd') {
|
|
return 2;
|
|
}
|
|
|
|
return 10;
|
|
}
|
|
|
|
render() {
|
|
const { height, width, options, data, renderCounter } = this.props;
|
|
|
|
return (
|
|
<VizRepeater
|
|
source={data}
|
|
getAlignmentFactors={getDisplayValueAlignmentFactors}
|
|
getValues={this.getValues}
|
|
renderValue={this.renderValue}
|
|
renderCounter={renderCounter}
|
|
width={width}
|
|
height={height}
|
|
itemSpacing={this.getItemSpacing()}
|
|
orientation={options.orientation}
|
|
/>
|
|
);
|
|
}
|
|
}
|