mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* build(webpack): replace babel-loader with esbuild-loader * build(webpack): add esbuild minifier to production builds * Wip * Removed ngInject and replaced with manual inject params * chore: bump esbuild to 0.15.13 * Fixed angular issues * build(frontend): update esbuild to 0.16.16 * chore(webpack): support browserslist for esbuild * build(esbuild): unify versions of esbuild to 0.16.17 and esbuild-loader to 2.21.0 Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
89 lines
2.1 KiB
TypeScript
89 lines
2.1 KiB
TypeScript
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { GraphCtrl } from './module';
|
|
|
|
export class AxesEditorCtrl {
|
|
panel: any;
|
|
panelCtrl: GraphCtrl;
|
|
logScales: any;
|
|
xAxisModes: any;
|
|
xAxisStatOptions: any;
|
|
xNameSegment: any;
|
|
selectors: typeof selectors.components.Panels.Visualization.Graph.VisualizationTab;
|
|
|
|
static $inject = ['$scope'];
|
|
|
|
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 = selectors.components.Panels.Visualization.Graph.VisualizationTab;
|
|
}
|
|
|
|
setUnitFormat(axis: { format: any }) {
|
|
return (unit: string) => {
|
|
axis.format = unit;
|
|
// if already set via field config we clear that
|
|
if (this.panel.fieldConfig.defaults.unit) {
|
|
this.panel.fieldConfig.defaults.unit = undefined;
|
|
this.panelCtrl.refresh();
|
|
} else {
|
|
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);
|
|
}
|
|
}
|
|
|
|
export function axesEditorComponent() {
|
|
'use strict';
|
|
return {
|
|
restrict: 'E',
|
|
scope: true,
|
|
templateUrl: 'public/app/plugins/panel/graph/axes_editor.html',
|
|
controller: AxesEditorCtrl,
|
|
};
|
|
}
|