| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  | ///<reference path="../../../headers/common.d.ts" />
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import kbn from 'app/core/utils/kbn'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class AxesEditorCtrl { | 
					
						
							|  |  |  |   panel: any; | 
					
						
							|  |  |  |   panelCtrl: any; | 
					
						
							|  |  |  |   unitFormats: any; | 
					
						
							|  |  |  |   logScales: any; | 
					
						
							|  |  |  |   xAxisModes: any; | 
					
						
							|  |  |  |   xAxisStatOptions: any; | 
					
						
							|  |  |  |   xNameSegment: any; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /** @ngInject **/ | 
					
						
							|  |  |  |   constructor(private $scope, private $q) { | 
					
						
							|  |  |  |     this.panelCtrl = $scope.ctrl; | 
					
						
							|  |  |  |     this.panel = this.panelCtrl.panel; | 
					
						
							| 
									
										
										
										
											2017-09-21 16:40:18 +02:00
										 |  |  |     this.$scope.ctrl = this; | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     this.unitFormats = kbn.getUnitFormats(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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', | 
					
						
							| 
									
										
										
										
											2017-04-07 12:07:30 +04:00
										 |  |  |       'Histogram': 'histogram' | 
					
						
							| 
									
										
										
										
											2016-09-26 14:04:13 +02:00
										 |  |  |       // 'Data field': 'field',
 | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     this.xAxisStatOptions =  [ | 
					
						
							|  |  |  |       {text: 'Avg', value: 'avg'}, | 
					
						
							|  |  |  |       {text: 'Min', value: 'min'}, | 
					
						
							| 
									
										
										
										
											2016-12-12 14:36:49 +01:00
										 |  |  |       {text: 'Max', value: 'max'}, | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |       {text: 'Total', value: 'total'}, | 
					
						
							|  |  |  |       {text: 'Count', value: 'count'}, | 
					
						
							| 
									
										
										
										
											2016-10-20 20:48:37 +02:00
										 |  |  |       {text: 'Current', value: 'current'}, | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |     ]; | 
					
						
							| 
									
										
										
										
											2016-09-23 17:12:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (this.panel.xaxis.mode === 'custom') { | 
					
						
							|  |  |  |       if (!this.panel.xaxis.name) { | 
					
						
							|  |  |  |         this.panel.xaxis.name = 'specify field'; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   setUnitFormat(axis, subItem) { | 
					
						
							|  |  |  |     axis.format = subItem.value; | 
					
						
							|  |  |  |     this.panelCtrl.render(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   render() { | 
					
						
							|  |  |  |     this.panelCtrl.render(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-13 14:38:22 +02:00
										 |  |  |   xAxisModeChanged()  { | 
					
						
							|  |  |  |     this.panelCtrl.processor.setPanelDefaultsForNewXAxisMode(); | 
					
						
							|  |  |  |     this.panelCtrl.onDataReceived(this.panelCtrl.dataList); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   xAxisValueChanged() { | 
					
						
							| 
									
										
										
										
											2016-09-24 13:08:58 +02:00
										 |  |  |     this.panelCtrl.onDataReceived(this.panelCtrl.dataList); | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-24 13:08:58 +02:00
										 |  |  |   getDataFieldNames(onlyNumbers) { | 
					
						
							|  |  |  |     var props = this.panelCtrl.processor.getDataFieldNames(this.panelCtrl.dataList, onlyNumbers); | 
					
						
							| 
									
										
										
										
											2016-09-23 17:12:10 +02:00
										 |  |  |     var items = props.map(prop => { | 
					
						
							| 
									
										
										
										
											2016-09-24 13:08:58 +02:00
										 |  |  |       return {text: prop, value: prop}; | 
					
						
							| 
									
										
										
										
											2016-09-23 17:12:10 +02:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-23 17:12:10 +02:00
										 |  |  |     return this.$q.when(items); | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** @ngInject **/ | 
					
						
							|  |  |  | export function axesEditorComponent() { | 
					
						
							|  |  |  |   'use strict'; | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     restrict: 'E', | 
					
						
							|  |  |  |     scope: true, | 
					
						
							| 
									
										
										
										
											2016-09-23 17:12:10 +02:00
										 |  |  |     templateUrl: 'public/app/plugins/panel/graph/axes_editor.html', | 
					
						
							| 
									
										
										
										
											2016-09-22 16:19:44 +02:00
										 |  |  |     controller: AxesEditorCtrl, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |