Adaptive bar widths for log graph

This commit is contained in:
David Kaltschmidt
2018-11-06 11:07:12 +01:00
parent c1ca1ed35e
commit e39e82949d
6 changed files with 27 additions and 19 deletions

View File

@@ -475,7 +475,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
from: parseDate(range.from, false),
to: parseDate(range.to, true),
};
const { interval } = kbn.calculateInterval(absoluteRange, resolution, datasource.interval);
const { interval, intervalMs } = kbn.calculateInterval(absoluteRange, resolution, datasource.interval);
const targets = [
{
...targetOptions,
@@ -490,6 +490,7 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
return {
interval,
intervalMs,
targets,
range: queryRange,
};

View File

@@ -6,6 +6,7 @@ import { withSize } from 'react-sizeme';
import 'vendor/flot/jquery.flot';
import 'vendor/flot/jquery.flot.time';
import 'vendor/flot/jquery.flot.selection';
import 'vendor/flot/jquery.flot.stack';
import { RawTimeRange } from 'app/types/series';
import * as dateMath from 'app/core/utils/datemath';

View File

@@ -12,7 +12,10 @@ const graphOptions = {
series: {
bars: {
show: true,
lineWidth: 5,
// barWidth: 10,
},
// stack: true,
},
yaxis: {
tickDecimals: 0,

View File

@@ -43,7 +43,7 @@ interface TimePickerState {
isUtc: boolean;
rangeString: string;
refreshInterval?: string;
initialRange: RawTimeRange;
initialRange?: RawTimeRange;
// Input-controlled text, keep these in a shape that is human-editable
fromRaw: string;
@@ -53,24 +53,27 @@ interface TimePickerState {
export default class TimePicker extends PureComponent<TimePickerProps, TimePickerState> {
dropdownEl: any;
state = {
isOpen: false,
isUtc: false,
rangeString: '',
initialRange: DEFAULT_RANGE,
fromRaw: '',
toRaw: '',
refreshInterval: '',
};
constructor(props) {
super(props);
this.state = {
isOpen: props.isOpen,
isUtc: props.isUtc,
rangeString: '',
fromRaw: '',
toRaw: '',
initialRange: DEFAULT_RANGE,
refreshInterval: '',
};
}
static getDerivedStateFromProps(props, state) {
if (state.range && state.range === props.range) {
return null;
if (state.initialRange && state.initialRange === props.range) {
return state;
}
const from = props.range ? props.range.from : DEFAULT_RANGE.from;
const to = props.range ? props.range.to : DEFAULT_RANGE.to;
const initialRange = props.range || DEFAULT_RANGE;
// Ensure internal format
const fromRaw = parseTime(from, props.isUtc);
@@ -81,10 +84,10 @@ export default class TimePicker extends PureComponent<TimePickerProps, TimePicke
};
return {
...state,
fromRaw,
toRaw,
initialRange,
isUtc: props.isUtc,
initialRange: props.range,
rangeString: rangeUtil.describeTimeRange(range),
};
}