grafana/public/app/plugins/panel/graph/axes_editor.ts
Hugo Häggmark 841cffbe9a
e2e: Migrates query variable CRUD tests to new framework (#21146)
* Refactor: Adds params to visit

* Refactor: Restructures exported Pages somewhat

* Refactor: Moves more into new framework but holdup because of bugs in digest

* Refactor: Finish migrating templating e2e tests to new framework

* Refactor: Changes after merge with master

* Refactor: Removes weird change

* Refactor: Adds duplication test

* Refactor: Adds move down and move up variable asserts

* Refactor: Adds some test to value select dropdown
2019-12-18 06:13:58 +01:00

82 lines
1.9 KiB
TypeScript

import { e2e } from '@grafana/e2e';
import { GraphCtrl } from './module';
export class AxesEditorCtrl {
panel: any;
panelCtrl: GraphCtrl;
logScales: any;
xAxisModes: any;
xAxisStatOptions: any;
xNameSegment: any;
selectors: typeof e2e.pages.Dashboard.Panels.Visualization.Graph.VisualizationTab.selectors;
/** @ngInject */
constructor(private $scope: any) {
this.panelCtrl = $scope.ctrl as GraphCtrl;
this.panel = this.panelCtrl.panel;
this.$scope.ctrl = this;
this.logScales = {
linear: 1,
'log (base 2)': 2,
'log (base 10)': 10,
'log (base 32)': 32,
'log (base 1024)': 1024,
};
this.xAxisModes = {
Time: 'time',
Series: 'series',
Histogram: 'histogram',
// 'Data field': 'field',
};
this.xAxisStatOptions = [
{ text: 'Avg', value: 'avg' },
{ text: 'Min', value: 'min' },
{ text: 'Max', value: 'max' },
{ text: 'Total', value: 'total' },
{ text: 'Count', value: 'count' },
{ text: 'Current', value: 'current' },
];
if (this.panel.xaxis.mode === 'custom') {
if (!this.panel.xaxis.name) {
this.panel.xaxis.name = 'specify field';
}
}
this.selectors = e2e.pages.Dashboard.Panels.Visualization.Graph.VisualizationTab.selectors;
}
setUnitFormat(axis: { format: any }) {
return (unit: string) => {
axis.format = unit;
this.panelCtrl.render();
};
}
render() {
this.panelCtrl.render();
}
xAxisModeChanged() {
this.panelCtrl.processor.setPanelDefaultsForNewXAxisMode();
this.panelCtrl.onDataFramesReceived(this.panelCtrl.dataList);
}
xAxisValueChanged() {
this.panelCtrl.onDataFramesReceived(this.panelCtrl.dataList);
}
}
/** @ngInject */
export function axesEditorComponent() {
'use strict';
return {
restrict: 'E',
scope: true,
templateUrl: 'public/app/plugins/panel/graph/axes_editor.html',
controller: AxesEditorCtrl,
};
}