mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fixed options
This commit is contained in:
@@ -45,15 +45,15 @@ export class Graph2 extends PureComponent<Props> {
|
||||
|
||||
export class GraphOptions extends PureComponent<PanelOptionsProps<Options>> {
|
||||
onToggleLines = () => {
|
||||
this.props.onChange({ showLines: !this.props.options.showLines, ...this.props.options });
|
||||
this.props.onChange({ ...this.props.options, showLines: !this.props.options.showLines });
|
||||
};
|
||||
|
||||
onToggleBars = () => {
|
||||
this.props.onChange({ showBars: !this.props.options.showBars, ...this.props.options });
|
||||
this.props.onChange({ ...this.props.options, showBars: !this.props.options.showBars });
|
||||
};
|
||||
|
||||
onTogglePoints = () => {
|
||||
this.props.onChange({ showPoints: !this.props.options.showPoints, ...this.props.options });
|
||||
this.props.onChange({ ...this.props.options, showPoints: !this.props.options.showPoints });
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -8,32 +8,6 @@ import 'vendor/flot/jquery.flot.time';
|
||||
// Types
|
||||
import { TimeRange, TimeSeriesVMs } from 'app/types';
|
||||
|
||||
// Copied from graph.ts
|
||||
function time_format(ticks, min, max) {
|
||||
if (min && max && ticks) {
|
||||
const range = max - min;
|
||||
const secPerTick = range / ticks / 1000;
|
||||
const oneDay = 86400000;
|
||||
const oneYear = 31536000000;
|
||||
|
||||
if (secPerTick <= 45) {
|
||||
return '%H:%M:%S';
|
||||
}
|
||||
if (secPerTick <= 7200 || range <= oneDay) {
|
||||
return '%H:%M';
|
||||
}
|
||||
if (secPerTick <= 80000) {
|
||||
return '%m/%d %H:%M';
|
||||
}
|
||||
if (secPerTick <= 2419200 || range <= oneYear) {
|
||||
return '%m/%d';
|
||||
}
|
||||
return '%Y-%m';
|
||||
}
|
||||
|
||||
return '%H:%M';
|
||||
}
|
||||
|
||||
interface GraphProps {
|
||||
timeSeries: TimeSeriesVMs;
|
||||
timeRange: TimeRange;
|
||||
@@ -139,4 +113,30 @@ export class Graph extends PureComponent<GraphProps> {
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from graph.ts
|
||||
function time_format(ticks, min, max) {
|
||||
if (min && max && ticks) {
|
||||
const range = max - min;
|
||||
const secPerTick = range / ticks / 1000;
|
||||
const oneDay = 86400000;
|
||||
const oneYear = 31536000000;
|
||||
|
||||
if (secPerTick <= 45) {
|
||||
return '%H:%M:%S';
|
||||
}
|
||||
if (secPerTick <= 7200 || range <= oneDay) {
|
||||
return '%H:%M';
|
||||
}
|
||||
if (secPerTick <= 80000) {
|
||||
return '%m/%d %H:%M';
|
||||
}
|
||||
if (secPerTick <= 2419200 || range <= oneYear) {
|
||||
return '%m/%d';
|
||||
}
|
||||
return '%Y-%m';
|
||||
}
|
||||
|
||||
return '%H:%M';
|
||||
}
|
||||
|
||||
export default withSize()(Graph);
|
||||
|
||||
Reference in New Issue
Block a user