graphPlugin.03c5ce2be5546aefa06c.js 64 KB

12
  1. "use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[1260],{21511:(e,t,i)=>{i.d(t,{X:()=>o});var s=i(78837);const n=["percent_diff","percent_diff_abs"];class o{static alertToGraphThresholds(e){if(!e.alert||s.vc.unifiedAlertingEnabled)return!1;for(let i=0;i<e.alert.conditions.length;i++){var t;const s=e.alert.conditions[i];if("query"!==s.type)continue;const o=s.evaluator,a=e.thresholds=[],r=-1===n.indexOf(null===(t=s.reducer)||void 0===t?void 0:t.type);switch(o.type){case"gt":{const e=o.params[0];a.push({value:e,op:"gt",visible:r});break}case"lt":{const e=o.params[0];a.push({value:e,op:"lt",visible:r});break}case"outside_range":{const e=o.params[0],t=o.params[1];e>t?(a.push({value:e,op:"gt",visible:r}),a.push({value:t,op:"lt",visible:r})):(a.push({value:e,op:"lt",visible:r}),a.push({value:t,op:"gt",visible:r}));break}case"within_range":{const e=o.params[0],t=o.params[1];e>t?(a.push({value:e,op:"lt",visible:r}),a.push({value:t,op:"gt",visible:r})):(a.push({value:e,op:"gt",visible:r}),a.push({value:t,op:"lt",visible:r}));break}}break}for(const t of e.thresholds)t.fill=e.options.alertThreshold,t.line=e.options.alertThreshold,t.colorMode="critical";return!0}}},45315:(e,t,i)=>{i.r(t),i.d(t,{GraphCtrl:()=>Ie,plugin:()=>We});i(89377),i(4027),i(59554),i(65103),i(85095),i(28844),i(26189),i(47825);var s=i(98572),n=i.n(s),o=i(82897),a=i(13426),r=i.n(a),l=i(90923);function h(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}v.$inject=["plot"];const d=(e,t,i)=>{const s=(0,l.getLegacyAngularInjector)(),n=document.createElement("div");n.innerHTML='<annotation-tooltip event="event" on-edit="onEdit()"></annotation-tooltip>',s.invoke(["$compile","$rootScope",(s,o)=>{const a=i.getOptions().events.manager,l=o.$new(!0);l.event=t,l.onEdit=()=>{a.editEvent(t)},s(n)(l),l.$digest(),l.$destroy();const h=new(r())({target:e[0],content:n,position:"bottom center",classes:"drop-popover drop-popover--annotation",openOn:"hover",hoverCloseDelay:200,tetherOptions:{constraints:[{to:"window",pin:!0,attachment:"both"}]}});h.open(),h.on("close",(()=>{setTimeout((()=>{h.destroy()}))}))}])};d.$inject=["element","event","plot"];let p=null;const c=(e,t,i)=>{const s=i.getOptions().events.manager;s.editorOpen?p=e:(s.editorOpened(),p=e,setTimeout((()=>{const e=(0,l.getLegacyAngularInjector)(),i=document.createElement("div");i.innerHTML='<event-editor panel-ctrl="panelCtrl" event="event" close="close()"></event-editor>',e.invoke(["$compile","$rootScope",(e,n)=>{const o=n.$new(!0);let a;o.event=t,o.panelCtrl=s.panelCtrl,o.close=()=>{a.close()},e(i)(o),o.$digest(),a=new(r())({target:p[0],content:i,position:"bottom center",classes:"drop-popover drop-popover--form",openOn:"click",tetherOptions:{constraints:[{to:"window",pin:!0,attachment:"both"}]}}),a.open(),s.editorOpened(),a.on("close",(()=>{setTimeout((()=>{s.editorClosed(),o.$destroy(),a.destroy()}))}))}])}),100))};c.$inject=["element","event","plot"];class m{constructor(e,t,i,s,n,o,a,r){h(this,"_object",void 0),h(this,"_drawFunc",void 0),h(this,"_clearFunc",void 0),h(this,"_moveFunc",void 0),h(this,"_position",void 0),h(this,"_width",void 0),h(this,"_height",void 0),this._object=e,this._drawFunc=t,this._clearFunc=i,this._moveFunc=s,this._position={left:n,top:o},this._width=a,this._height=r}width(){return this._width}height(){return this._height}position(){return this._position}draw(){this._drawFunc(this._object)}clear(){this._clearFunc(this._object)}getObject(){return this._object}moveTo(e){this._position=e,this._moveFunc(this._object,this._position)}}m.$inject=["object","drawFunc","clearFunc","moveFunc","left","top","width","height"];class u{constructor(e,t){h(this,"_parent",void 0),h(this,"_options",void 0),h(this,"_drawableEvent",void 0),h(this,"_hidden",void 0),this._options=e,this._drawableEvent=t,this._hidden=!1}visual(){return this._drawableEvent}getOptions(){return this._options}getParent(){return this._parent}isHidden(){return this._hidden}hide(){this._hidden=!0}unhide(){this._hidden=!1}}u.$inject=["options","drawableEvent"];class g{constructor(e){h(this,"_events",void 0),h(this,"_types",void 0),h(this,"_plot",void 0),h(this,"eventsEnabled",void 0),this._events=[],this._types=[],this._plot=e,this.eventsEnabled=!1}getEvents(){return this._events}setTypes(e){return this._types=e}setupEvents(e){const t=(0,o.partition)(e,"isRegion"),i=t[0];e=t[1],n().each(e,((e,t)=>{const i=new u(t,this._buildDiv(t));this._events.push(i)})),n().each(i,((e,t)=>{const i=new u(t,this._buildRegDiv(t));this._events.push(i)})),this._events.sort(((e,t)=>{const i=e.getOptions(),s=t.getOptions();return i.min>s.min?1:i.min<s.min?-1:0}))}drawEvents(){n().each(this._events,((e,t)=>{const i=t.getOptions(),s=this._insidePlot(i.min)||this._insidePlot(i.timeEnd),n=this._overlapPlot(i.min,i.timeEnd);!s&&!n||t.isHidden()?t.visual().getObject().hide():t.visual().draw()}))}updateEvents(){const e=this._plot.getPlotOffset();let t,i;const s=this._plot.getXAxes()[this._plot.getOptions().events.xaxis-1];n().each(this._events,((n,o)=>{i=e.top+this._plot.height()-o.visual().height(),t=s.p2c(o.getOptions().min)+e.left-o.visual().width()/2,o.visual().moveTo({top:i,left:t})}))}_clearEvents(){n().each(this._events,((e,t)=>{t.visual().clear()})),this._events=[]}_buildDiv(e){var t,i;const s=this,o=this._plot.getPlaceholder(),a=this._plot.getPlotOffset(),r=this._plot.getXAxes()[this._plot.getOptions().events.xaxis-1];let l,h,p,u,g,v,f,x;const b=e.eventType;p=null!==this._types&&this._types[b]&&this._types[b].color?this._types[b].color:"#666",u=null!==this._types&&this._types[b]&&this._types[b].markerSize?this._types[b].markerSize:8,g=null===this._types||!this._types[b]||void 0===this._types[b].markerShow||this._types[b].markerShow,x=null===this._types||!this._types[b]||void 0===this._types[b].markerTooltip||this._types[b].markerTooltip,v=null!=this._types&&this._types[b]&&this._types[b].lineStyle?this._types[b].lineStyle.toLowerCase():"dashed",f=null!=this._types&&this._types[b]&&void 0!==this._types[b].lineWidth?this._types[b].lineWidth:1;let y=r.options.eventSectionHeight||0;y/=3,l=a.top+this._plot.height()+y,h=r.p2c(e.min)+a.left;const C=n()('<div class="events_line flot-temp-elem"></div>').css({position:"absolute",opacity:.8,left:h+"px",top:8,width:f+"px",height:this._plot.height()+.8*y,"border-left-width":f+"px","border-left-style":v,"border-left-color":p,color:p}).appendTo(o);if(g){const t=n()('<div class="events_marker"></div>').css({position:"absolute",left:-u-Math.round(f/2)+"px","font-size":0,"line-height":0,width:0,height:0,"border-left":u+"px solid transparent","border-right":u+"px solid transparent"});t.appendTo(C),this._types[b]&&this._types[b].position&&"BOTTOM"===this._types[b].position.toUpperCase()?t.css({top:l-u-8+"px","border-top":"none","border-bottom":u+"px solid "+p}):t.css({top:"0px","border-top":u+"px solid "+p,"border-bottom":"none"}),t.data({event:e});const i=function(){d(t,n()(this).data("event"),s._plot)};e.editModel&&c(t,e.editModel,s._plot);const o=()=>{s._plot.clearSelection()};x&&(t.css({cursor:"help"}),t.hover(i,o))}return new m(C,(function(e){e.show()}),(e=>{e.remove()}),((e,t)=>{e.css({top:t.top,left:t.left})}),h,l,null!==(t=C.width())&&void 0!==t?t:1,null!==(i=C.height())&&void 0!==i?i:1)}_buildRegDiv(e){var t,i;const s=this,a=this._plot.getPlaceholder(),r=this._plot.getPlotOffset(),l=this._plot.getXAxes()[this._plot.getOptions().events.xaxis-1];let h,p,u,g,v,f,x;const b=e.eventType;f=null!==this._types&&this._types[b]&&this._types[b].color?this._types[b].color:"#666",x=null===this._types||!this._types[b]||void 0===this._types[b].markerTooltip||this._types[b].markerTooltip,u=null!=this._types&&this._types[b]&&void 0!==this._types[b].lineWidth?this._types[b].lineWidth:1,v=null!=this._types&&this._types[b]&&this._types[b].lineStyle?this._types[b].lineStyle.toLowerCase():"dashed";h=r.top+this._plot.height()+2;const y=Math.min(e.min,e.timeEnd),C=Math.max(e.min,e.timeEnd);p=l.p2c(y)+r.left;const _=l.p2c(C)+r.left,[T,O]=[r.left,r.left+this._plot.width()],k=Math.max(p,T);g=Math.min(_,O)-k+(_>O?0:u),(0,o.each)([p,_],(e=>{if(T<=e&&e<O){n()('<div class="events_line flot-temp-elem"></div>').css({position:"absolute",opacity:.8,left:e+"px",top:8,width:u+"px",height:this._plot.height()+2,"border-left-width":u+"px","border-left-style":v,"border-left-color":f,color:f}).appendTo(a)}}));const S=n()('<div class="events_marker region_marker flot-temp-elem"></div>').css({position:"absolute",opacity:.5,left:k+"px",top:h,width:g+"px",height:"0.5rem","border-left-color":f,color:f,"background-color":f});S.appendTo(a),S.data({event:e});const w=function(){d(S,n()(this).data("event"),s._plot)};e.editModel&&c(S,e.editModel,s._plot);const M=()=>{s._plot.clearSelection()};x&&(S.css({cursor:"help"}),S.hover(w,M));return new m(S,(function(e){e.show()}),(e=>{e.remove()}),((e,t)=>{e.css({top:t.top,left:t.left})}),p,h,null!==(t=S.width())&&void 0!==t?t:1,null!==(i=S.height())&&void 0!==i?i:1)}_insidePlot(e){const t=this._plot.getXAxes()[this._plot.getOptions().events.xaxis-1],i=t.p2c(e);return i>0&&i<t.p2c(t.max)}_overlapPlot(e,t){const i=this._plot.getXAxes()[this._plot.getOptions().events.xaxis-1],[s,n]=[i.p2c(e),i.p2c(t)],[o,a]=[0,i.p2c(i.max)];return o<s&&n<a}}function v(e){const t=this,i=new g(e);e.getEvents=()=>i._events,e.hideEvents=()=>{n().each(i._events,((e,t)=>{t.visual().getObject().hide()}))},e.showEvents=()=>{e.hideEvents(),n().each(i._events,((e,t)=>{t.hide()})),t.eventMarkers.drawEvents()},e.setEvents=e=>{i.eventsEnabled&&i.setupEvents(e)},e.hooks.processOptions.push(((e,t)=>{null!=t.events.data&&(i.eventsEnabled=!0)})),e.hooks.draw.push((e=>{const t=e.getOptions();i.eventsEnabled&&(i.getEvents().length<1?(i.setTypes(t.events.types),i.setupEvents(t.events.data)):i.updateEvents()),i.drawEvents()}))}g.$inject=["plot"];n().plot.plugins.push({init:v,options:{events:{data:null,types:null,xaxis:1,position:"BOTTOM"}},name:"events",version:"0.2.5"});var f=i(68404),x=i(87524),b=i(43215),y=i(69783),C=i(20469),_=i(78837),T=i(98163),O=i(11622),k=i(63796),S=i(63619),w=i(23019),M=i.n(w),E=i(16695),A=i(45916);function L(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const D=["min","max","avg","current","total"];class P extends f.PureComponent{constructor(e){super(e),L(this,"onLabelClick",(e=>this.props.onLabelClick(this.props.series,e))),L(this,"onToggleAxis",(()=>{const e=2===this.state.yaxis?1:2,t={alias:this.props.series.alias,yaxis:e};this.setState({yaxis:e}),this.props.onToggleAxis(t)})),L(this,"onColorChange",(e=>{this.props.onColorChange(this.props.series,e),this.forceUpdate()})),this.state={yaxis:this.props.series.yaxis}}renderLegendValues(){const{series:e,asTable:t}=this.props,i=[];for(const s of D)if(this.props[s]){const n=e.formatValue(e.stats[s]);i.push((0,A.jsx)(F,{valueName:s,value:n,asTable:t,onValueClick:this.onLabelClick},s))}return i}render(){const{series:e,values:t,asTable:i,hidden:s}=this.props,n=M()({"graph-legend-series-hidden":s,"graph-legend-series--right-y":2===e.yaxis}),o=t?this.renderLegendValues():[],a=(0,A.jsx)(N,{label:e.alias,color:e.color,yaxis:this.state.yaxis,onLabelClick:this.onLabelClick,onColorChange:this.onColorChange,onToggleAxis:this.onToggleAxis});return i?(0,A.jsxs)("tr",{className:`graph-legend-series ${n}`,children:[(0,A.jsx)("td",{children:(0,A.jsx)("div",{className:"graph-legend-series__table-name",children:a})}),o]}):(0,A.jsxs)("div",{className:`graph-legend-series ${n}`,children:[a,o]})}}L(P,"defaultProps",{asTable:!1,hidden:!1,onLabelClick:()=>{},onColorChange:()=>{},onToggleAxis:()=>{}});class N extends f.PureComponent{render(){const{label:e,color:t,yaxis:i}=this.props,{onColorChange:s,onToggleAxis:n}=this.props,o=this.props.onLabelClick?this.props.onLabelClick:()=>{};return[(0,A.jsx)($,{color:t,yaxis:i,onColorChange:s,onToggleAxis:n},"icon"),(0,A.jsx)("a",{className:"graph-legend-alias pointer",title:e,onClick:o,"aria-label":E.wl.components.Panels.Visualization.Graph.Legend.legendItemAlias(e),children:e},"label")]}}L(N,"defaultProps",{yaxis:void 0,onLabelClick:()=>{}});class $ extends f.PureComponent{constructor(){super(...arguments),L(this,"onColorChange",(e=>{const{onColorChange:t}=this.props;t&&t(e)}))}render(){return(0,A.jsx)(y.SeriesColorPicker,{yaxis:this.props.yaxis,color:this.props.color,onChange:this.onColorChange,onToggleAxis:this.props.onToggleAxis,enableNamedColors:!0,children:e=>{let{ref:t,showColorPicker:i,hideColorPicker:s}=e;return(0,A.jsx)(y.SeriesIcon,{color:this.props.color,ref:t,onClick:i,onMouseLeave:s,className:"graph-legend-icon"})}})}}function F(e){let{value:t,valueName:i,asTable:s,onValueClick:n}=e;return s?(0,A.jsx)("td",{className:`graph-legend-value ${i}`,onClick:n,children:t}):(0,A.jsx)("div",{className:`graph-legend-value ${i}`,onClick:n,children:t})}function j(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}L($,"defaultProps",{yaxis:void 0,onColorChange:()=>{},onToggleAxis:()=>{}});class R extends f.PureComponent{constructor(e){super(e),j(this,"onToggleSeries",((e,t)=>{if(!this.props.onToggleSeries)return;let i=Object.assign({},this.state.hiddenSeries);t.ctrlKey||t.metaKey||t.shiftKey?i[e.alias]?delete i[e.alias]:i[e.alias]=!0:i=this.toggleSeriesExclusiveMode(e),this.setState({hiddenSeries:i}),this.props.onToggleSeries(i)})),this.state={hiddenSeries:this.props.hiddenSeries}}sortLegend(){let e=[...this.props.seriesList]||[];const t=this.props.sort;return t&&this.props[t]&&this.props.alignAsTable&&(e=(0,o.sortBy)(e,(e=>{let i=e.stats[t];return null===i&&(i=-1/0),i})),this.props.sortDesc&&(e=e.reverse())),e}toggleSeriesExclusiveMode(e){const t=Object.assign({},this.state.hiddenSeries);t[e.alias]&&delete t[e.alias];return this.props.seriesList.every((i=>i.alias===e.alias||t[i.alias]))?this.props.seriesList.forEach((e=>{delete t[e.alias]})):this.props.seriesList.forEach((i=>{i.alias!==e.alias&&(t[i.alias]=!0)})),t}render(){const{optionalClass:e,rightSide:t,sideWidth:i,sort:s,sortDesc:n,hideEmpty:o,hideZero:a,values:r,min:l,max:h,avg:d,current:p,total:c}=this.props,m={values:r,min:l,max:h,avg:d,current:p,total:c},u=this.state.hiddenSeries,g={hideEmpty:o,hideZero:a},v={sort:s,sortDesc:n},f=this.sortLegend().filter((e=>!e.hideFromLegend(g))),x=`${this.props.alignAsTable?"graph-legend-table":""} ${e}`,b={minWidth:t&&i?i:void 0,width:t&&i?i-1:void 0},y=Object.assign({seriesList:f,hiddenSeries:u,onToggleSeries:this.onToggleSeries,onToggleAxis:this.props.onToggleAxis,onToggleSort:this.props.onToggleSort,onColorChange:this.props.onColorChange},m,v);return(0,A.jsx)("div",{className:`graph-legend-content ${x}`,style:b,children:this.props.alignAsTable?(0,A.jsx)(W,Object.assign({},y)):(0,A.jsx)(I,Object.assign({},y))})}}j(R,"defaultProps",{values:!1,min:!1,max:!1,avg:!1,current:!1,total:!1,alignAsTable:!1,rightSide:!1,sort:void 0,sortDesc:!1,optionalClass:"",onToggleSeries:()=>{},onToggleSort:()=>{},onToggleAxis:()=>{},onColorChange:()=>{}});class I extends f.PureComponent{render(){const{seriesList:e,hiddenSeries:t,values:i,min:s,max:n,avg:o,current:a,total:r}=this.props,l={values:i,min:s,max:n,avg:o,current:a,total:r};return e.map(((e,i)=>(0,A.jsx)(P,Object.assign({series:e,hidden:t[e.alias]},l,{onLabelClick:this.props.onToggleSeries,onColorChange:this.props.onColorChange,onToggleAxis:this.props.onToggleAxis}),`${e.id}-${i}`)))}}class W extends f.PureComponent{constructor(){super(...arguments),j(this,"onToggleSort",(e=>{if(!this.props.onToggleSort)return;let t=this.props.sortDesc,i=this.props.sort;e!==i&&(t=void 0),!1===t?(i=void 0,t=void 0):(t=!t,i=e),this.props.onToggleSort(i,t)}))}render(){const e=this.props.seriesList,{values:t,min:i,max:s,avg:n,current:o,total:a,sort:r,sortDesc:l,hiddenSeries:h}=this.props,d={values:t,min:i,max:s,avg:n,current:o,total:a};return e?(0,A.jsxs)("table",{children:[(0,A.jsx)("colgroup",{children:(0,A.jsx)("col",{style:{width:"100%"}})}),(0,A.jsx)("thead",{children:(0,A.jsxs)("tr",{children:[(0,A.jsx)("th",{style:{textAlign:"left"}}),D.map((e=>d[e]&&(0,A.jsx)(H,{statName:e,sort:r,sortDesc:l,onClick:this.onToggleSort},e)))]})}),(0,A.jsx)("tbody",{children:e&&e.map(((e,t)=>(0,A.jsx)(P,Object.assign({asTable:!0,series:e,hidden:h[e.alias],onLabelClick:this.props.onToggleSeries,onColorChange:this.props.onColorChange,onToggleAxis:this.props.onToggleAxis},d),`${e.id}-${t}`)))})]}):null}}class H extends f.PureComponent{constructor(){super(...arguments),j(this,"onClick",(()=>{this.props.onClick&&this.props.onClick(this.props.statName)}))}render(){const{statName:e,sort:t,sortDesc:i}=this.props;return(0,A.jsxs)("th",{className:"pointer",onClick:this.onClick,children:[e,t===e&&(0,A.jsx)(y.Icon,{name:i?"angle-down":"angle-up"})]})}}class z extends f.PureComponent{render(){return(0,A.jsx)(y.CustomScrollbar,{hideHorizontalTrack:!0,children:(0,A.jsx)(R,Object.assign({},this.props))})}}function B(e,t){if(isNaN(t)||(2!==(i=e).length||!V(i[0])||!V(i[1])))return;var i;const[s,n]=e;!function(e,t,i){0!==i&&(e.min-=i,e.max-=i,t.min-=i,t.max-=i)}(s,n,t),function(e,t){const i=.25;e.max===e.min&&(e.min-=i,e.max+=i);t.max===t.min&&(t.min-=i,t.max+=i)}(s,n);const o=0===s.min||0===n.min||0===s.max||0===n.max,a=U(s,n);if(o&&a)s.min=s.max>0?0:s.min,s.max=s.max>0?s.max:0,n.min=n.max>0?0:n.min,n.max=n.max>0?n.max:0;else if(function(e,t){return e.min>=0&&t.max<=0||e.max<=0&&t.min>=0}(s,n))s.min>=0?(s.min=-s.max,n.max=-n.min):(s.max=-s.min,n.min=-n.max);else{const e=function(e,t){if(G(e,t)){const i=t.min?e.min/t.min:0,s=t.max?e.max/t.max:0;return i>s?i:s}if(U(e,t)){const i=Math.abs(e.min),s=Math.abs(e.max),n=Math.abs(t.min),o=Math.abs(t.max),a=Math.max(i,s),r=Math.min(i,s),l=Math.max(n,o),h=Math.min(n,o),d=0!==r?a/r:a,p=0!==h?l/h:l;return d>p?d:p}return e.min>0||t.min>0?e.max/t.max:e.min/t.min}(s,n);a?s.min>0?(s.min=s.max/e,n.min=n.max/e):(s.max=s.min/e,n.max=n.min/e):G(s,n)?(s.min=n.min?n.min*e:s.min,n.min=s.min?s.min/e:n.min,s.max=n.max?n.max*e:s.max,n.max=s.max?s.max/e:n.max):(s.min=s.min>0?n.min*e:s.min,n.min=n.min>0?s.min/e:n.min,s.max=s.max<0?n.max*e:s.max,n.max=n.max<0?s.max/e:n.max)}!function(e,t,i){0!==i&&(e.min+=i,e.max+=i,t.min+=i,t.max+=i)}(s,n,t)}function V(e){return"min"in e&&"max"in e}function U(e,t){return e.min>=0&&t.min>=0||e.max<=0&&t.max<=0}function G(e,t){return e.min<=0&&e.max>=0&&t.min<=0&&t.max>=0}var Y=i(35008),Z=i.n(Y);function X(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class K{constructor(e){X(this,"event",null),X(this,"editorOpen",!1),this.panelCtrl=e}editorClosed(){this.event=null,this.editorOpen=!1,this.panelCtrl.render()}editorOpened(){this.editorOpen=!0}updateTime(e){this.event||(this.event={},this.event.dashboardId=this.panelCtrl.dashboard.id,this.event.panelId=this.panelCtrl.panel.id),this.event.time=e.from,this.event.isRegion=!1,e.to&&(this.event.timeEnd=e.to,this.event.isRegion=!0),this.panelCtrl.render()}editEvent(e,t){this.event=e,this.panelCtrl.render()}addFlotEvents(e,t){if(!this.event&&0===e.length)return;const i={$__alerting:{color:y.ALERTING_COLOR,position:"BOTTOM",markerSize:5},$__ok:{color:y.OK_COLOR,position:"BOTTOM",markerSize:5},$__no_data:{color:y.NO_DATA_COLOR,position:"BOTTOM",markerSize:5},$__pending:{color:y.PENDING_COLOR,position:"BOTTOM",markerSize:5},$__editing:{color:y.DEFAULT_ANNOTATION_COLOR,position:"BOTTOM",markerSize:5}};if(this.event)e=this.event.isRegion?[{isRegion:!0,min:this.event.time,timeEnd:this.event.timeEnd,text:this.event.text,eventType:"$__editing",editModel:this.event}]:[{min:this.event.time,text:this.event.text,editModel:this.event,eventType:"$__editing"}];else for(let t=0;t<e.length;t++){const s=e[t];s.min=s.time,s.max=s.time,s.eventType=s.type,s.newState?s.eventType="$__"+s.newState:i[s.type]||(i[s.type]={color:s.color,position:"BOTTOM",markerSize:5})}const s=function(e){return(0,o.filter)(e,"isRegion")}(e);!function(e,t){const i=t.grid.markings,s=y.DEFAULT_ANNOTATION_COLOR;let n;(0,o.each)(e,(e=>{n=e.source&&e.color||s,n=function(e,t){const i=Z()(e);return i.isValid()?(i.setAlpha(t),i.toRgbString()):e}(n,y.REGION_FILL_ALPHA),i.push({xaxis:{from:e.min,to:e.timeEnd},color:n})}))}(s,t);t.grid.eventSectionHeight=7,t.xaxis.eventSectionHeight=20,t.events={levels:(0,o.keys)(i).length+1,data:e,types:i,manager:this}}}var q=i(58170);function J(e,t,i,s){const o=this,a=i.ctrl.panel,r=new b.LegacyGraphHoverEvent({pos:{},point:{},panel:this.panel}),l=n()('<div class="graph-tooltip">');this.destroy=()=>{l.remove()},this.findHoverIndexFromDataPoints=(e,t,i)=>{const s=t.datapoints.pointsize,n=i*s,o=t.datapoints.points.length;let a;for(a=n;a<o;a+=s)if(!t.lines.steps&&null!=t.datapoints.points[n]&&null==t.datapoints.points[a]||t.datapoints.points[a]>e)return Math.max(a-s,0)/s;return a/s-1},this.findHoverIndexFromData=(e,t)=>{let i,s=0,n=t.data.length-1;for(;;){if(s>n)return Math.max(n,0);if(i=Math.floor((s+n)/2),t.data[i][0]===e)return i;t.data[i][0]<e?s=i+1:n=i-1}},this.renderAndShow=(e,t,i,s)=>{"time"===s&&(t='<div class="graph-tooltip-time">'+e+"</div>"+t),l.html(t).place_tt(i.pageX,i.pageY,{offset:10})},this.getMultiSeriesPlotHoverInfo=function(e,t){let i,s,n,o,r,l,h,d,p,c=[[],[],[]],m=0;for(s=0;s<e.length;s++)n=e[s],!n.data.length||a.legend.hideEmpty&&n.allIsNull||!n.data.length||a.legend.hideZero&&n.allIsZero||n.hideTooltip?c[0].push({hidden:!0,value:0}):(o=this.findHoverIndexFromData(t.x,n),r=t.x-n.data[o][0],l=n.data[o][0],(!d||r>=0&&(r<d||d<0)||r<0&&r>d)&&(d=r,p=l),i=n.data[o][1],n.stack&&null!==i&&"individual"!==a.tooltip.value_type&&(m+=i,i=m),(n.lines.steps||n.stack)&&(o=this.findHoverIndexFromDataPoints(t.x,n,o)),h=0,n.yaxis&&(h=n.yaxis.n),c[h].push({value:i,hoverIndex:o,color:n.color,label:n.aliasEscaped,time:l,distance:r,index:s}));return c=c[0].concat(c[1],c[2]),c.time=p,c},e.mouseleave((()=>{var i;if(null!==(i=a.tooltip)&&void 0!==i&&i.shared){const t=e.data().plot;t&&(l.detach(),t.unhighlight())}t.events.publish(new b.LegacyGraphHoverClearEvent),t.events.publish(new b.DataHoverClearEvent)})),e.bind("plothover",((i,s,n)=>{o.show(s,n),t.panelInEdit||(s.panelRelY=(s.pageY-e.offset().top)/e.height(),r.payload.pos=s,r.payload.panel=a,r.payload.point.time=s.x,t.events.publish(r))})),e.bind("plotclick",((e,t,i)=>{T.h$.emit(q.RW.xt,{pos:t,panel:a,item:i})})),e.bind("plotleave",(()=>{if(!a.tooltip.shared)return;const t=e.data().plot;t&&(l.detach(),t.unhighlight())})),this.clear=e=>{l.detach(),e.clearCrosshair(),e.unhighlight()},this.show=(i,r)=>{const h=e.data().plot,d=h.getData(),p=h.getXAxes()[0].options.mode,c=s();let m,u,g,v,f,x,y,C,_=a.tooltip.shared;if(i.panelRelY){var T;const s=h.pointOffset({x:i.x});if(Number.isNaN(s.left)||s.left<0||s.left>e.width())return void o.clear(h);i.pageX=e.offset().left+s.left,i.pageY=e.offset().top+e.height()*i.panelRelY;const a=null!==(T=n()(window).scrollTop())&&void 0!==T?T:0;if(!(i.pageY>=a&&i.pageY<=n()(window).innerHeight()+a))return void o.clear(h);if(h.setCrosshair(i),_=!0,t.sharedCrosshairModeOnly())return}if(0!==c.length)if(C=c[0].hasMsResolution?b.systemDateFormats.fullDateMS:b.systemDateFormats.fullDate,_){h.unhighlight();const e=o.getMultiSeriesPlotHoverInfo(d,i);for(y="",g=t.formatDate(e.time,C),2===a.tooltip.sort?e.sort(((e,t)=>t.value-e.value)):1===a.tooltip.sort&&e.sort(((e,t)=>e.value-t.value)),f=0;f<e.length;f++){if(v=e[f],v.hidden)continue;let t="";r&&v.index===r.seriesIndex&&(t="graph-tooltip-list-item--highlight"),x=c[v.index],u=b.textUtil.sanitize(x.formatValue(v.value));y+='<div class="graph-tooltip-list-item '+t+'"><div class="graph-tooltip-series-name">',y+='<i class="fa fa-minus" style="color:'+b.textUtil.sanitize(v.color)+';"></i> '+b.textUtil.sanitize(v.label)+":</div>",y+='<div class="graph-tooltip-value">'+u+"</div></div>",h.highlight(v.index,v.hoverIndex)}o.renderAndShow(g,y,i,p)}else if(r){const e=b.textUtil.sanitize(r.series.color);x=c[r.seriesIndex],m='<div class="graph-tooltip-list-item"><div class="graph-tooltip-series-name">',m+='<i class="fa fa-minus" style="color:'+e+';"></i> '+x.aliasEscaped+":</div>",u=a.stack&&"individual"===a.tooltip.value_type?r.datapoint[1]-r.datapoint[2]:r.datapoint[1],u=b.textUtil.sanitize(x.formatValue(u)),g=t.formatDate(r.datapoint[0],C),m+='<div class="graph-tooltip-value">'+u+"</div>",o.renderAndShow(g,m,i,p)}else l.detach()}}var Q=i(24314);function ee(e,t,i,s,n){return e.map((e=>{const o=function(e){const t=[];for(let i=0;i<e.length;i++){const s=e[i].datapoints;for(let e=0;e<s.length;e++)null!==s[e][0]&&t.push(s[e][0])}return t}([e]);if(e.histogram=!0,i[e.alias])e.data=[];else{const i=function(e,t,i,s){const n=te(i,t),o=te(s,t);return(0,Q.histogram)().domain([n,o]).thresholds(Math.round(s-i)/t)(e).map((e=>[e.x0,e.length]))}(o,t,s,n);e.data=i}return e}))}function te(e,t){return Math.floor(e/t)*t}function ie(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class se{constructor(e){ie(this,"plot",void 0),ie(this,"placeholder",void 0),ie(this,"height",void 0),ie(this,"thresholds",void 0),ie(this,"needsCleanup",!1),ie(this,"hasSecondYAxis",void 0),this.panelCtrl=e}getHandleHtml(e,t,i){let s=t.colorMode;return"custom"===t.colorMode&&(s="critical"),`\n <div class="alert-handle-wrapper alert-handle-wrapper--T${e}">\n <div class="alert-handle-line alert-handle-line--${s}">\n </div>\n <div class="alert-handle" data-handle-index="${e}">\n <i class="icon-gf icon-gf-${s} alert-state-${s}"></i>\n <span class="alert-handle-value">${i}<i class="alert-handle-grip"></i></span>\n </div>\n </div>`}initDragging(e){const t=n()(e.currentTarget).parents(".alert-handle-wrapper"),i=n()(e.currentTarget).data("handleIndex");let s,o=null;const a=this.plot,r=this.panelCtrl,l=this.thresholds[i];function h(e){if(null===o)o=e.clientY;else{const i=e.clientY-o;s+=i,o=e.clientY,t.css({top:s+i})}}o=null,s=t.position().top,t.on("mousemove",h),document.addEventListener("mouseup",(function e(){let n=a.c2p({left:0,top:s}).y;n=parseInt(n.toFixed(0),10),l.value=n,t.off("mousemove",h),document.removeEventListener("mouseup",e),r.$scope.$apply((()=>{r.render(),r.events.emit(q.RW.GL,{threshold:l,handleIndex:i})}))}))}cleanUp(){this.placeholder.find(".alert-handle-wrapper").remove(),this.needsCleanup=!1}renderHandle(e,t){const i=this.thresholds[e];if(!i.visible&&this.panelCtrl.alert)return;const s=i.value;let a=s,r=0;if((0,o.isNumber)(s)){const e=this.plot.p2c({x:0,y:s});r=Math.round(Math.min(Math.max(e.top,0),this.height)-6)}else a="",r=t;const l=n()(this.getHandleHtml(e,i,a));this.placeholder.append(l),l.toggleClass("alert-handle-wrapper--no-value",""===a),l.css({top:r})}shouldDrawHandles(){return!this.hasSecondYAxis&&this.panelCtrl.editingThresholds&&this.panelCtrl.panel.thresholds.length>0}prepare(e,t){this.hasSecondYAxis=!1;for(let e=0;e<t.length;e++)if(t[e].yaxis>1){this.hasSecondYAxis=!0;break}if(this.shouldDrawHandles()){const t=this.panelCtrl.panel.thresholds.length>1?"220px":"110px";e.css("margin-right",t)}else this.needsCleanup&&e.css("margin-right","0")}draw(e){this.thresholds=this.panelCtrl.panel.thresholds,this.plot=e,this.placeholder=e.getPlaceholder(),this.needsCleanup&&this.cleanUp(),this.shouldDrawHandles()&&(this.height=e.height(),this.thresholds.length>0&&this.renderHandle(0,10),this.thresholds.length>1&&this.renderHandle(1,this.height-30),this.placeholder.off("mousedown",".alert-handle"),this.placeholder.on("mousedown",".alert-handle",this.initDragging.bind(this)),this.needsCleanup=!0)}addFlotOptions(e,t){if(!t.thresholds||0===t.thresholds.length)return;let i,s,n,a=1/0,r=-1/0;for(i=0;i<t.thresholds.length;i++){if(s=t.thresholds[i],!(0,o.isNumber)(s.value))continue;let l,h,d;switch(s.op){case"gt":l=a,t.thresholds.length>i+1&&(n=t.thresholds[i+1],n.value>s.value&&(l=n.value,r=l));break;case"lt":l=r,t.thresholds.length>i+1&&(n=t.thresholds[i+1],n.value<s.value&&(l=n.value,a=l))}switch(s.colorMode){case"critical":h="rgba(234, 112, 112, 0.12)",d="rgba(237, 46, 24, 0.60)";break;case"warning":h="rgba(235, 138, 14, 0.12)",d="rgba(247, 149, 32, 0.60)";break;case"ok":h="rgba(11, 237, 50, 0.090)",d="rgba(6,163,69, 0.60)";break;case"custom":h=s.fillColor,d=s.lineColor}s.fill&&("right"===s.yaxis&&this.hasSecondYAxis?e.grid.markings.push({y2axis:{from:s.value,to:l},color:_.vc.theme.visualization.getColorByName(h)}):e.grid.markings.push({yaxis:{from:s.value,to:l},color:_.vc.theme.visualization.getColorByName(h)})),s.line&&("right"===s.yaxis&&this.hasSecondYAxis?e.grid.markings.push({y2axis:{from:s.value,to:s.value},color:_.vc.theme.visualization.getColorByName(d)}):e.grid.markings.push({yaxis:{from:s.value,to:s.value},color:_.vc.theme.visualization.getColorByName(d)}))}}}function ne(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const oe={gray:{themeDependent:!0,title:"Gray",darkColor:{fill:"rgba(255, 255, 255, 0.09)",line:"rgba(255, 255, 255, 0.2)"},lightColor:{fill:"rgba(0, 0, 0, 0.09)",line:"rgba(0, 0, 0, 0.2)"}},red:{title:"Red",color:{fill:"rgba(234, 112, 112, 0.12)",line:"rgba(237, 46, 24, 0.60)"}},green:{title:"Green",color:{fill:"rgba(11, 237, 50, 0.090)",line:"rgba(6,163,69, 0.60)"}},blue:{title:"Blue",color:{fill:"rgba(11, 125, 238, 0.12)",line:"rgba(11, 125, 238, 0.60)"}},yellow:{title:"Yellow",color:{fill:"rgba(235, 138, 14, 0.12)",line:"rgba(247, 149, 32, 0.60)"}},custom:{title:"Custom"}};function ae(e,t){if(-1===Object.keys(oe).indexOf(e.colorMode)&&(e.colorMode="red"),"custom"===e.colorMode)return{fill:e.fill&&e.fillColor?t.visualization.getColorByName(e.fillColor):null,line:e.line&&e.lineColor?t.visualization.getColorByName(e.lineColor):null};const i=oe[e.colorMode];return!0===i.themeDependent?t.isLight?i.lightColor:i.darkColor:{fill:e.fill?t.visualization.getColorByName(i.color.fill):null,line:e.fill?t.visualization.getColorByName(i.color.line):null}}class re{constructor(e){ne(this,"plot",void 0),ne(this,"timeRegions",void 0),this.panelCtrl=e}draw(e){this.timeRegions=this.panelCtrl.panel.timeRegions,this.plot=e}addFlotOptions(e,t){if(!t.timeRegions||0===t.timeRegions.length)return;const i={from:(0,b.dateTime)(this.panelCtrl.range.from).utc(),to:(0,b.dateTime)(this.panelCtrl.range.to).utc()};let s,n,o,a,r,l,h;const d=t.timeRegions.map((e=>Object.assign({},e)));for(s=0;s<d.length;s++)if(o=d[s],(o.fromDayOfWeek||o.from||o.toDayOfWeek||o.to)&&(o.from&&!o.to&&(o.to=o.from),!o.from&&o.to&&(o.from=o.to),n={from:this.parseTimeRange(o.from),to:this.parseTimeRange(o.to)},!o.fromDayOfWeek&&o.toDayOfWeek&&(o.fromDayOfWeek=o.toDayOfWeek),!o.toDayOfWeek&&o.fromDayOfWeek&&(o.toDayOfWeek=o.fromDayOfWeek),o.fromDayOfWeek&&(n.from.dayOfWeek=Number(o.fromDayOfWeek)),o.toDayOfWeek&&(n.to.dayOfWeek=Number(o.toDayOfWeek)),n.from.dayOfWeek&&null===n.from.h&&null===n.from.m&&(n.from.h=0,n.from.m=0,n.from.s=0),n.to.dayOfWeek&&null===n.to.h&&null===n.to.m&&(n.to.h=23,n.to.m=59,n.to.s=59),n.from&&n.to)){for(a=[],r=(0,b.dateTime)(i.from),r.set("hour",0),r.set("minute",0),r.set("second",0),r.add(n.from.h,"hours"),r.add(n.from.m,"minutes"),r.add(n.from.s,"seconds");r.unix()<=i.to.unix();){for(;n.from.dayOfWeek&&n.from.dayOfWeek!==r.isoWeekday();)r.add(24,"hours");if(r.unix()>i.to.unix())break;if(l=(0,b.dateTime)(r),l.hour)if(n.from.h<=n.to.h)l.add(n.to.h-n.from.h,"hours");else if(n.from.h>n.to.h)for(;l.hour()!==n.to.h;)l.add(1,"hours");else for(l.add(24-n.from.h,"hours");l.hour()!==n.to.h;)l.add(1,"hours");for(l.set("minute",n.to.m),l.set("second",n.to.s);n.to.dayOfWeek&&n.to.dayOfWeek!==l.isoWeekday();)l.add(24,"hours");r.unix()<i.from.unix()&&l.unix()<i.from.unix()||r.unix()>i.to.unix()&&l.unix()>i.to.unix()||a.push({from:r.valueOf(),to:l.valueOf()}),r.add(24,"hours")}h=ae(o,_.vc.theme);for(let t=0;t<a.length;t++){const i=a[t];o.fill&&e.grid.markings.push({xaxis:{from:i.from,to:i.to},color:h.fill}),o.line&&(e.grid.markings.push({xaxis:{from:i.from,to:i.from},color:h.line}),e.grid.markings.push({xaxis:{from:i.to,to:i.to},color:h.line}))}}}parseTimeRange(e){const t={h:null,m:null},i=/^([\d]+):?(\d{2})?/.exec(e);return i?(i.length>1&&(t.h=Number(i[1]),t.m=0,i.length>2&&void 0!==i[2]&&(t.m=Number(i[2])),t.h>23&&(t.h=23),t.m>59&&(t.m=59)),t):t}}function le(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}pe.$inject=["timeSrv","popoverSrv","contextSrv"];const he=(0,O.ER)(z);class de{constructor(e,t,i){le(this,"ctrl",void 0),le(this,"contextMenu",void 0),le(this,"tooltip",void 0),le(this,"dashboard",void 0),le(this,"annotations",void 0),le(this,"panel",void 0),le(this,"plot",void 0),le(this,"sortedSeries",void 0),le(this,"data",[]),le(this,"panelWidth",void 0),le(this,"eventManager",void 0),le(this,"thresholdManager",void 0),le(this,"timeRegionManager",void 0),le(this,"getContextMenuItemsSupplier",((e,t)=>()=>{const i=this.dashboard.canAddAnnotations()?[{items:[{label:"Add annotation",ariaLabel:"Add annotation",icon:"comment-alt",onClick:()=>this.eventManager.updateTime({from:e.x,to:null})}]}]:[];if(!t)return i;const s=[{items:t.getLinks(this.panel.replaceVariables).map((e=>({label:e.title,ariaLabel:e.title,url:e.href,target:e.target,icon:""+("_self"===e.target?"link":"external-link-alt"),onClick:e.onClick})))}];return[...i,...s]})),this.scope=e,this.elem=t,this.timeSrv=i,this.ctrl=e.ctrl,this.contextMenu=e.ctrl.contextMenuCtrl,this.dashboard=this.ctrl.dashboard,this.panel=this.ctrl.panel,this.annotations=[],this.panelWidth=0,this.eventManager=new K(this.ctrl),this.thresholdManager=new se(this.ctrl),this.timeRegionManager=new re(this.ctrl),this.tooltip=new J(this.elem,this.ctrl.dashboard,this.scope,(()=>this.sortedSeries)),this.ctrl.events.on(b.PanelEvents.panelTeardown,this.onPanelTeardown.bind(this)),this.ctrl.events.on(b.PanelEvents.render,this.onRender.bind(this)),this.ctrl.dashboard.events.on(b.LegacyGraphHoverEvent.type,this.onGraphHover.bind(this),this.scope),this.ctrl.dashboard.events.on(b.LegacyGraphHoverClearEvent.type,this.onGraphHoverClear.bind(this),this.scope),this.ctrl.dashboard.events.on(b.DataHoverEvent.type,this.onGraphHover.bind(this),this.scope),this.ctrl.dashboard.events.on(b.DataHoverClearEvent.type,this.onGraphHoverClear.bind(this),this.scope),this.elem.bind("plotselected",this.onPlotSelected.bind(this)),this.elem.bind("plotclick",this.onPlotClick.bind(this)),this.elem&&this.elem.parent&&(this.legendElem=this.elem.parent().find(".graph-legend")[0])}onRender(e){if(this.data=e||this.data,!this.data)return;this.annotations=this.ctrl.annotations||[],this.buildFlotPairs(this.data);const t=this.ctrl.height;if((0,T.Wz)(this.data,this.panel,t),!this.panel.legend.show)return this.legendElem.hasChildNodes()&&x.unmountComponentAtNode(this.legendElem),void this.renderPanel();const{values:i,min:s,max:n,avg:o,current:a,total:r}=this.panel.legend,{alignAsTable:l,rightSide:h,sideWidth:d,sort:p,sortDesc:c,hideEmpty:m,hideZero:u}=this.panel.legend,g={alignAsTable:l,rightSide:h,sideWidth:d,sort:p,sortDesc:c,hideEmpty:m,hideZero:u},v={values:i,min:s,max:n,avg:o,current:a,total:r},b=Object.assign({seriesList:this.data,hiddenSeries:this.ctrl.hiddenSeries},g,v,{onToggleSeries:this.ctrl.onToggleSeries,onToggleSort:this.ctrl.onToggleSort,onColorChange:this.ctrl.onColorChange,onToggleAxis:this.ctrl.onToggleAxis}),y=f.createElement(he,b);x.render(y,this.legendElem,(()=>this.renderPanel()))}onGraphHover(e){var t,i;if(this.dashboard.sharedTooltipModeEnabled()){if(e.hasOwnProperty("pos")){var s;if(!this.plot||(null===(s=e.panel)||void 0===s?void 0:s.id)===this.panel.id||this.ctrl.otherPanelInFullscreenMode())return;this.tooltip.show(e.pos)}null!==(t=e.point)&&void 0!==t&&t.time&&this.tooltip.show({x:e.point.time,panelRelY:null!==(i=e.point.panelRelY)&&void 0!==i?i:1})}}onPanelTeardown(){this.plot&&(this.plot.destroy(),this.plot=null),this.tooltip.destroy(),this.elem.off(),this.elem.remove(),x.unmountComponentAtNode(this.legendElem)}onGraphHoverClear(e){this.plot&&this.tooltip.clear(this.plot)}onPlotSelected(e,t){"time"===this.panel.xaxis.mode?(t.ctrlKey||t.metaKey)&&this.dashboard.canAddAnnotations()?setTimeout((()=>{this.eventManager.updateTime(t.xaxis)}),100):this.scope.$apply((()=>{this.timeSrv.setTime({from:(0,b.toUtc)(t.xaxis.from),to:(0,b.toUtc)(t.xaxis.to)})})):this.plot.clearSelection()}onPlotClick(e,t,i){const s=this.elem.closest(".view")?this.elem.closest(".view").get()[0]:null,n=i;if("time"===this.panel.xaxis.mode)if(t.ctrlKey||t.metaKey){if(t.x!==t.x1)return;if(!this.dashboard.id||!this.dashboard.canAddAnnotations())return;setTimeout((()=>{this.eventManager.updateTime({from:t.x,to:null})}),100)}else{let e;if(this.tooltip.clear(this.plot),i){const t=this.panel.yaxes[2===i.series.yaxis.n?1:0],s=this.ctrl.dataList[i.series.dataFrameIndex],n=s.fields[i.series.fieldIndex],o=this.getDataIndexWithNullValuesCorrection(i,s);let a=this.panel.options.dataLinks||[];const r=(0,b.hasLinks)(n);r&&(a=[...a,...n.config.links]);const l={decimals:t.decimals,links:a},h=(0,b.getDisplayProcessor)({field:{config:l,type:b.FieldType.number},theme:_.ZP.theme2,timeZone:this.dashboard.getTimezone()})(n.values.get(o));e=a.length?(0,S.n)({display:h,name:n.name,view:new b.DataFrameView(s),rowIndex:o,colIndex:i.series.fieldIndex,field:l,hasLinks:r}):void 0}this.scope.$apply((()=>{this.contextMenu.setScrollContextElement(s),this.contextMenu.setSource(n),this.contextMenu.setMenuItemsSupplier(this.getContextMenuItemsSupplier(t,e)),this.contextMenu.toggleMenu(t)}))}}getDataIndexWithNullValuesCorrection(e,t){const{datapoint:i,dataIndex:s}=e;if(!Array.isArray(i)||0===i.length)return s;const n=i[0],{timeField:o}=(0,b.getTimeField)(t);if(!o||!o.values)return s;if(o.values.get(s)===n)return s;const a=o.values.toArray().findIndex((e=>e===n));return a>-1?a:s}shouldAbortRender(){return!this.data||0===this.panelWidth}drawHook(e){this.panel.yaxes[0].label&&this.panel.yaxes[0].show&&n()("<div class='axisLabel left-yaxis-label flot-temp-elem'></div>").text(this.panel.yaxes[0].label).appendTo(this.elem),this.panel.yaxes[1].label&&this.panel.yaxes[1].show&&n()("<div class='axisLabel right-yaxis-label flot-temp-elem'></div>").text(this.panel.yaxes[1].label).appendTo(this.elem);const{dataWarning:t}=this.ctrl;if(t){const e=n()(`<div class="datapoints-warning flot-temp-elem">${t.title}</div>`);t.action&&n()(`<button class="btn btn-secondary">${t.actionText}</button>`).click(t.action).appendTo(e),e.appendTo(this.elem)}this.thresholdManager.draw(e),this.timeRegionManager.draw(e)}processOffsetHook(e,t){const i=this.panel.yaxes[0],s=this.panel.yaxes[1];i.show&&i.label&&(t.left=20),s.show&&s.label&&(t.right=20);const n=e.getYAxes();for(let e=0;e<n.length;e++){const t=n[e],i=this.panel.yaxes[e];t.options.max=null!==t.options.max?t.options.max:i.max,t.options.min=null!==t.options.min?t.options.min:i.min}}processRangeHook(e){const t=e.getYAxes(),i=this.panel.yaxis.align||!1;if(t.length>1&&!0===i){const e=this.panel.yaxis.alignLevel||0;B(t,parseFloat(e))}}getMinTimeStepOfSeries(e){let t=Number.MAX_VALUE;for(let i=0;i<e.length;i++)if(e[i].stats.timeStep){if(this.panel.bars){if(e[i].bars&&!1===e[i].bars.show)continue}else if(void 0===e[i].bars||void 0===e[i].bars.show||!e[i].bars.show)continue;e[i].stats.timeStep<t&&(t=e[i].stats.timeStep)}return t}renderPanel(){var e;if(this.panelWidth=null!==(e=this.elem.width())&&void 0!==e?e:0,this.shouldAbortRender())return;this.thresholdManager.prepare(this.elem,this.data),this.panel.dashes=!!this.panel.lines&&this.panel.dashes;const t=this.buildFlotOptions(this.panel);this.prepareXAxis(t,this.panel),this.configureYAxisOptions(this.data,t),this.thresholdManager.addFlotOptions(t,this.panel),this.timeRegionManager.addFlotOptions(t,this.panel),this.eventManager.addFlotEvents(this.annotations,t),this.sortedSeries=this.sortSeries(this.data,this.panel),this.callPlot(t,!0)}buildFlotPairs(e){for(let t=0;t<e.length;t++){const i=e[t];i.data=i.getFlotPairs(i.nullPointMode||this.panel.nullPointMode),"constant"===i.transform&&(i.data=(0,b.getFlotPairsConstant)(i.data,this.ctrl.range)),this.ctrl.hiddenSeries[i.alias]&&(i.data=[],i.stack=!1)}}prepareXAxis(e,t){switch(t.xaxis.mode){case"series":e.series.bars.barWidth=.7,e.series.bars.align="center";for(let e=0;e<this.data.length;e++){const i=this.data[e];i.data=[[e+1,i.stats[t.xaxis.values[0]]]]}this.addXSeriesAxis(e);break;case"histogram":{let i;if(this.data.length){let s=(0,o.min)((0,o.map)(this.data,(e=>e.stats.min))),n=(0,o.max)((0,o.map)(this.data,(e=>e.stats.max)));const a=t.xaxis.buckets||this.panelWidth/50;if(null!=t.xaxis.min){s=(0,k.tickStep)(t.xaxis.min,n,a)<=0?s:t.xaxis.min}if(null!=t.xaxis.max){n=(0,k.tickStep)(s,t.xaxis.max,a)<=0?n:t.xaxis.max}i=(0,k.tickStep)(s,n,a),e.series.bars.barWidth=.8*i,this.data=ee(this.data,i,this.ctrl.hiddenSeries,s,n)}else i=0;this.addXHistogramAxis(e,i);break}case"table":e.series.bars.barWidth=.7,e.series.bars.align="center",this.addXTableAxis(e);break;default:e.series.bars.barWidth=this.getMinTimeStepOfSeries(this.data)/1.5,this.addTimeAxis(e)}}callPlot(e,t){try{this.plot=n().plot(this.elem,this.sortedSeries,e),this.ctrl.renderError&&delete this.ctrl.error}catch(e){console.error("flotcharts error",e),this.ctrl.error=e.message||"Render Error",this.ctrl.renderError=!0}t&&this.ctrl.renderingCompleted()}buildFlotOptions(e){let t="#c8c8c8";!0===_.ZP.bootData.user.lightTheme&&(t="#a1a1a1");const i=!!e.stack||null;return{hooks:{draw:[this.drawHook.bind(this)],processOffset:[this.processOffsetHook.bind(this)],processRange:[this.processRangeHook.bind(this)]},legend:{show:!1},series:{stackpercent:!!e.stack&&e.percentage,stack:e.percentage?null:i,lines:{show:e.lines,zero:!1,fill:this.translateFillOption(e.fill),fillColor:this.getFillGradient(e.fillGradient),lineWidth:e.dashes?0:e.linewidth,steps:e.steppedLine},dashes:{show:e.dashes,lineWidth:e.linewidth,dashLength:[e.dashLength,e.spaceLength]},bars:{show:e.bars,fill:1,barWidth:1,zero:!1,lineWidth:0},points:{show:e.points,fill:1,fillColor:!1,radius:e.points?e.pointradius:2},shadowSize:0},yaxes:[],xaxis:{},grid:{minBorderMargin:0,markings:[],backgroundColor:null,borderWidth:0,hoverable:!0,clickable:!0,color:t,margin:{left:0,right:0},labelMarginX:0,mouseActiveRadius:30},selection:{mode:"x",color:"#666"},crosshair:{mode:"x"}}}sortSeries(e,t){const i=t.legend.sort,s=t.legend.sortDesc,n=null!=i&&t.legend[i],a=null!=s,r=t.stack&&n&&a&&t.legend.alignAsTable,l=!0===t.legend.sortDesc?-1:1;return r?(0,o.sortBy)(e,(e=>e.stats[i]*l)):(0,o.sortBy)(e,(e=>e.zindex))}getFillGradient(e){return e?{colors:[{opacity:0},{opacity:e/10}]}:null}translateFillOption(e){return this.panel.percentage&&this.panel.stack&&0===e?.001:e/10}addTimeAxis(e){const t=this.panelWidth/100,i=(0,o.isUndefined)(this.ctrl.range.from)?null:this.ctrl.range.from.valueOf(),s=(0,o.isUndefined)(this.ctrl.range.to)?null:this.ctrl.range.to.valueOf();e.xaxis={timezone:this.dashboard.getTimezone(),show:this.panel.xaxis.show,mode:"time",min:i,max:s,label:"Datetime",ticks:t,timeformat:(0,y.graphTimeFormat)(t,i,s),tickFormatter:y.graphTickFormatter}}addXSeriesAxis(e){const t=(0,o.map)(this.data,((e,t)=>[t+1,e.alias]));e.xaxis={timezone:this.dashboard.getTimezone(),show:this.panel.xaxis.show,mode:null,min:0,max:t.length+1,label:"Datetime",ticks:t}}addXHistogramAxis(e,t){let i,s,n;const a=this.panelWidth/50;if(this.data.length&&t){const e=[];for(const t of this.data)for(const i of t.data)e[i[0]]=!0;i=Object.keys(e).map((e=>Number(e))),s=(0,o.min)(i),n=(0,o.max)(i);let r=t,l=Math.floor((n-s)/r);for(;l>a;)r*=2,l=Math.ceil((n-s)/r);s=Math.floor(s/r)*r,n=Math.ceil(1.01*n/r)*r,i=[];for(let e=s;e<=n;e+=r)i.push(e)}else i=a/2,s=0,n=1;e.xaxis={timezone:this.dashboard.getTimezone(),show:this.panel.xaxis.show,mode:null,min:s,max:n,label:"Histogram",ticks:i},this.configureAxisMode(e.xaxis,"short",null)}addXTableAxis(e){let t=(0,o.map)(this.data,((e,t)=>(0,o.map)(e.datapoints,((i,s)=>[t*e.datapoints.length+s+1,i[1]]))));t=(0,o.flatten)(t,!0),e.xaxis={timezone:this.dashboard.getTimezone(),show:this.panel.xaxis.show,mode:null,min:0,max:t.length+1,label:"Datetime",ticks:t}}configureYAxisOptions(e,t){const i={position:"left",show:this.panel.yaxes[0].show,index:1,logBase:this.panel.yaxes[0].logBase||1,min:this.parseNumber(this.panel.yaxes[0].min),max:this.parseNumber(this.panel.yaxes[0].max),tickDecimals:this.panel.yaxes[0].decimals};if(t.yaxes.push(i),(0,o.find)(e,{yaxis:2})){const s=(0,o.clone)(i);s.index=2,s.show=this.panel.yaxes[1].show,s.logBase=this.panel.yaxes[1].logBase||1,s.position="right",s.min=this.parseNumber(this.panel.yaxes[1].min),s.max=this.parseNumber(this.panel.yaxes[1].max),s.tickDecimals=this.panel.yaxes[1].decimals,t.yaxes.push(s),this.applyLogScale(t.yaxes[1],e),this.configureAxisMode(t.yaxes[1],this.panel.percentage&&this.panel.stack?"percent":this.panel.yaxes[1].format,this.panel.yaxes[1].decimals)}this.applyLogScale(t.yaxes[0],e),this.configureAxisMode(t.yaxes[0],this.panel.percentage&&this.panel.stack?"percent":this.panel.yaxes[0].format,this.panel.yaxes[0].decimals)}parseNumber(e){return null==e?null:(0,o.toNumber)(e)}applyLogScale(e,t){if(1===e.logBase)return;const i=0===e.min;let s,n;e.min<Number.MIN_VALUE&&(e.min=null),e.max<Number.MIN_VALUE&&(e.max=null);let o=e.max,a=e.min;for(n=0;n<t.length;n++)s=t[n],s.yaxis===e.index&&((!o||o<s.stats.max)&&(o=s.stats.max),(!a||a>s.stats.logmin)&&(a=s.stats.logmin));e.transform=t=>t<Number.MIN_VALUE?null:Math.log(t)/Math.log(e.logBase),e.inverseTransform=t=>Math.pow(e.logBase,t),o||a?o?a||(a=o*e.inverseTransform(-4)):o=a*e.inverseTransform(4):(o=e.inverseTransform(2),a=e.inverseTransform(-2)),a=e.min?e.inverseTransform(Math.ceil(e.transform(e.min))):e.min=e.inverseTransform(Math.floor(e.transform(a))),o=e.max?e.inverseTransform(Math.floor(e.transform(e.max))):e.max=e.inverseTransform(Math.ceil(e.transform(o))),!a||a<Number.MIN_VALUE||!o||o<Number.MIN_VALUE||(Number.isFinite(a)&&Number.isFinite(o)?(i&&(e.min=.1,a=1),e.ticks=this.generateTicksForLogScaleYAxis(a,o,e.logBase),i&&e.ticks.unshift(.1),e.ticks[e.ticks.length-1]>e.max&&(e.max=e.ticks[e.ticks.length-1])):(e.ticks=[1,2],delete e.min,delete e.max))}generateTicksForLogScaleYAxis(e,t,i){let s,n=[];for(s=e;s<=t;s*=i)n.push(s);const o=Math.ceil(this.ctrl.height/25),a=n.length;if(a>o){const r=Math.ceil(a/o)*i;for(n=[],s=e;s<=t*r;s*=r)n.push(s)}return n}configureAxisMode(e,t,i){e.tickFormatter=(e,s)=>{const n=(0,b.getValueFormat)(t);if(!n)throw new Error(`Unit '${t}' is not supported`);return(0,b.formattedValueToString)(n(e,i))}}}function pe(e,t,i){return{restrict:"A",template:"",link:(t,i)=>new de(t,i,e)}}function ce(e,t,i){e.overrideMenu=[],e.currentOverrides=[],e.override=e.override||{},e.colorPickerModel={},e.addOverrideOption=(t,i,s)=>{const n={text:t,propertyName:i,index:e.overrideMenu.length,values:s,submenu:(0,o.map)(s,(e=>({text:String(e),value:e})))};e.overrideMenu.push(n)},e.setOverride=(t,i)=>{"color"!==t.propertyName?(e.override[t.propertyName]=i.value,"fillBelowTo"===t.propertyName&&(e.override.lines=!1,e.ctrl.addSeriesOverride({alias:i.value,lines:!1})),e.updateCurrentOverrides(),e.ctrl.render()):e.openColorSelector(e.override.color)},e.colorSelected=t=>{e.override.color=t,e.updateCurrentOverrides(),e.ctrl.render(),e.colorPickerModel.series.color=t},e.openColorSelector=s=>{e.colorPickerModel={autoClose:!0,colorSelected:e.colorSelected,series:{color:s}},i.show({element:t.find(".dropdown")[0],position:"top center",openOn:"click",template:'<series-color-picker-popover color="series.color" onColorChange="colorSelected" />',classNames:"drop-popover drop-popover--transparent",model:e.colorPickerModel,onClose:()=>{e.ctrl.render()}})},e.removeOverride=t=>{delete e.override[t.propertyName],e.updateCurrentOverrides(),e.ctrl.refresh()},e.getSeriesNames=()=>(0,o.map)(e.ctrl.seriesList,(e=>b.textUtil.escapeHtml(e.alias))),e.updateCurrentOverrides=()=>{e.currentOverrides=[],(0,o.each)(e.overrideMenu,(t=>{const i=e.override[t.propertyName];(0,o.isUndefined)(i)||e.currentOverrides.push({name:t.text,propertyName:t.propertyName,value:String(i)})}))},e.addOverrideOption("Bars","bars",[!0,!1]),e.addOverrideOption("Lines","lines",[!0,!1]),e.addOverrideOption("Line fill","fill",[0,1,2,3,4,5,6,7,8,9,10]),e.addOverrideOption("Fill gradient","fillGradient",[0,1,2,3,4,5,6,7,8,9,10]),e.addOverrideOption("Line width","linewidth",[0,1,2,3,4,5,6,7,8,9,10]),e.addOverrideOption("Null point mode","nullPointMode",["connected","null","null as zero"]),e.addOverrideOption("Fill below to","fillBelowTo",e.getSeriesNames()),e.addOverrideOption("Staircase line","steppedLine",[!0,!1]),e.addOverrideOption("Dashes","dashes",[!0,!1]),e.addOverrideOption("Hidden Series","hiddenSeries",[!0,!1]),e.addOverrideOption("Dash Length","dashLength",[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),e.addOverrideOption("Dash Space","spaceLength",[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]),e.addOverrideOption("Points","points",[!0,!1]),e.addOverrideOption("Points Radius","pointradius",[1,2,3,4,5]),e.addOverrideOption("Stack","stack",[!0,!1,"A","B","C","D"]),e.addOverrideOption("Color","color",["change"]),e.addOverrideOption("Y-axis","yaxis",[1,2]),e.addOverrideOption("Z-index","zindex",[-3,-2,-1,0,1,2,3]),e.addOverrideOption("Transform","transform",["constant","negative-Y"]),e.addOverrideOption("Legend","legend",[!0,!1]),e.addOverrideOption("Hide in tooltip","hideTooltip",[!0,!1]),e.updateCurrentOverrides()}function me(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}C.hF.directive("grafanaGraph",pe),ce.$inject=["$scope","$element","popoverSrv"],C.ZP.controller("SeriesOverridesCtrl",ce);class ue{constructor(e){me(this,"panelCtrl",void 0),me(this,"panel",void 0),me(this,"disabled",!1),this.$scope=e}$onInit(){this.panel=this.panelCtrl.panel,this.panel.alert&&!_.ZP.unifiedAlertingEnabled&&(this.disabled=!0);const e=this.$scope.$on("$destroy",(()=>{this.panelCtrl.editingThresholds=!1,this.panelCtrl.render(),e()}));this.panelCtrl.editingThresholds=!0}addThreshold(){this.panel.thresholds.push({value:void 0,colorMode:"critical",op:"gt",fill:!0,line:!0,yaxis:"left"}),this.panelCtrl.render()}removeThreshold(e){this.panel.thresholds.splice(e,1),this.panelCtrl.render()}render(){this.panelCtrl.render()}onFillColorChange(e){return t=>{this.panel.thresholds[e].fillColor=t,this.render()}}onLineColorChange(e){return t=>{this.panel.thresholds[e].lineColor=t,this.render()}}onThresholdTypeChange(e){"custom"===this.panel.thresholds[e].colorMode&&(this.panel.thresholds[e].fillColor=Z()(_.ZP.theme.palette.blue85).setAlpha(.2).toRgbString(),this.panel.thresholds[e].lineColor=Z()(_.ZP.theme.palette.blue77).setAlpha(.6).toRgbString()),this.panelCtrl.render()}}function ge(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}ue.$inject=["$scope"],C.ZP.directive("graphThresholdForm",(()=>({restrict:"E",templateUrl:"public/app/plugins/panel/graph/thresholds_form.html",controller:ue,bindToController:!0,controllerAs:"ctrl",scope:{panelCtrl:"="}})));class ve{constructor(e){ge(this,"panelCtrl",void 0),ge(this,"panel",void 0),ge(this,"disabled",!1),ge(this,"colorModes",void 0),this.$scope=e}$onInit(){this.panel=this.panelCtrl.panel;const e=this.$scope.$on("$destroy",(()=>{this.panelCtrl.editingTimeRegions=!1,this.panelCtrl.render(),e()}));this.colorModes=(0,o.map)(Object.keys(oe),(e=>({key:e,value:oe[e].title}))),this.panelCtrl.editingTimeRegions=!0}render(){this.panelCtrl.render()}addTimeRegion(){this.panel.timeRegions.push({op:"time",fromDayOfWeek:void 0,from:void 0,toDayOfWeek:void 0,to:void 0,colorMode:"background6",fill:!0,line:!1,fillColor:"rgba(234, 112, 112, 0.12)",lineColor:"rgba(237, 46, 24, 0.60)"}),this.panelCtrl.render()}removeTimeRegion(e){this.panel.timeRegions.splice(e,1),this.panelCtrl.render()}onFillColorChange(e){return t=>{this.panel.timeRegions[e].fillColor=t,this.render()}}onLineColorChange(e){return t=>{this.panel.timeRegions[e].lineColor=t,this.render()}}}ve.$inject=["$scope"],C.ZP.directive("graphTimeRegionForm",(()=>({restrict:"E",templateUrl:"public/app/plugins/panel/graph/time_regions_form.html",controller:ve,bindToController:!0,controllerAs:"ctrl",scope:{panelCtrl:"="}})));var fe=i(45243);function xe(e,t,i,s){function a(t){try{return e(t)}catch(e){return console.log("Could not sanitize annotation string, html escaping instead"),(0,o.escape)(t)}}return{restrict:"E",scope:{event:"=",onEdit:"&"},link:(e,i)=>{const r=e.event;let l=r.title,h=r.text;const d=t.getCurrent();let p='<div class="graph-annotation">',c="";if(void 0!==r.alertId&&r.newState){const e=fe.Z.getStateDisplayModel(r.newState);c=e.stateClass,l=`<i class="${e.iconClass}"></i> ${e.text}`,h=fe.Z.getAlertAnnotationInfo(r),r.text&&(h=h+"<br />"+r.text)}else l&&(h=l+"<br />"+((0,o.isString)(h)?h:""),l="");let m='<div class="graph-annotation__header">';r.login&&r.avatarUrl&&(m+=`<div class="graph-annotation__user" bs-tooltip="'Created by ${r.login}'"><img src="${r.avatarUrl}" /></div>`),m+=`\n <span class="graph-annotation__title ${c}">${a(l)}</span>\n <span class="graph-annotation__time">${null==d?void 0:d.formatDate(r.min)}</span>\n `,r.id&&null!=d&&d.canEditAnnotations(r.dashboardId)&&(m+='\n <span class="pointer graph-annotation__edit-icon" ng-click="onEdit()">\n <i class="fa fa-pencil-square"></i>\n </span>\n '),m+="</div>",p+=m,p+='<div class="graph-annotation__body">',h&&(p+="<div ng-non-bindable>"+a(h.replace(/\n/g,"<br>"))+"</div>");const u=r.tags;u&&u.length&&(e.tags=u,p+='<span class="label label-tag small" ng-repeat="tag in tags" tag-color-from-name="tag">{{tag}}</span><br/>'),p+="</div>",p+="</div>";n()(p).appendTo(i),s(i.contents())(e)}}}xe.$inject=["$sanitize","dashboardSrv","contextSrv","$compile"],C.ZP.directive("annotationTooltip",xe);var be=i(61959),ye=i(54361),Ce=i(70930);function _e(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Te{constructor(){_e(this,"panelCtrl",void 0),_e(this,"event",void 0),_e(this,"timeRange",void 0),_e(this,"form",void 0),_e(this,"close",void 0),_e(this,"timeFormated",void 0)}$onInit(){this.event.panelId=this.panelCtrl.panel.id,this.event.dashboardId=this.panelCtrl.dashboard.id,this.event.time=Oe(this.event.time),this.event.isRegion&&(this.event.timeEnd=Oe(this.event.timeEnd)),this.timeFormated=this.panelCtrl.dashboard.formatDate(this.event.time)}canDelete(){var e,t;return!be.Vt.accessControlEnabled()||("dashboard"===this.event.source.type?!(null===(t=this.panelCtrl.dashboard.meta.annotationsPermissions)||void 0===t||!t.dashboard.canDelete):!(null===(e=this.panelCtrl.dashboard.meta.annotationsPermissions)||void 0===e||!e.organization.canDelete))}async save(){if(!this.form.$valid)return;const e=(0,o.cloneDeep)(this.event);if(e.time=e.time.valueOf(),e.timeEnd=0,e.isRegion&&(e.timeEnd=this.event.timeEnd.valueOf(),e.timeEnd<e.time))return void console.log("invalid time");let t=ye.xD;e.id&&(t=ye._E);try{await t(e)}catch(e){console.log(e)}finally{this.close(),(0,Ce.kt)().run({dashboard:this.panelCtrl.dashboard,range:this.panelCtrl.range})}}async delete(){try{await(0,ye.Dl)(this.event)}catch(e){console.log(e)}finally{this.close(),(0,Ce.kt)().run({dashboard:this.panelCtrl.dashboard,range:this.panelCtrl.range})}}}function Oe(e){if(e&&(0,o.isNumber)(e)){const t=Number(e);return(0,b.dateTime)(t)}return e}Te.$inject=[],C.hF.directive("eventEditor",(function(){return{restrict:"E",controller:Te,bindToController:!0,controllerAs:"ctrl",templateUrl:"public/app/features/annotations/partials/event_editor.html",scope:{panelCtrl:"=",event:"=",close:"&"}}}));var ke=i(15866),Se=i(21511),we=i(68897),Me=i(56340),Ee=i(65160),Ae=i(70686),Le=i(21169);function De(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Pe{constructor(e){De(this,"source",void 0),De(this,"scope",void 0),De(this,"menuItemsSupplier",void 0),De(this,"scrollContextElement",null),De(this,"position",{x:0,y:0}),De(this,"isVisible",void 0),De(this,"onClose",(()=>{this.scrollContextElement&&this.scrollContextElement.removeEventListener("scroll",this.onClose),this.scope.$apply((()=>{this.isVisible=!1}))})),De(this,"toggleMenu",(e=>{this.isVisible=!this.isVisible,this.isVisible&&this.scrollContextElement&&this.scrollContextElement.addEventListener("scroll",this.onClose),this.source?this.position={x:this.source.pageX,y:this.source.pageY}:this.position={x:e?e.pageX:0,y:e?e.pageY:0}})),De(this,"setScrollContextElement",(e=>{this.scrollContextElement=e})),De(this,"setSource",(e=>{this.source=e})),De(this,"getSource",(()=>this.source)),De(this,"setMenuItemsSupplier",(e=>{this.menuItemsSupplier=e})),this.isVisible=!1,this.scope=e}}function Ne(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class $e{constructor(e){Ne(this,"panel",void 0),Ne(this,"panelCtrl",void 0),Ne(this,"logScales",void 0),Ne(this,"xAxisModes",void 0),Ne(this,"xAxisStatOptions",void 0),Ne(this,"xNameSegment",void 0),Ne(this,"selectors",void 0),this.$scope=e,this.panelCtrl=e.ctrl,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"},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"}],"custom"===this.panel.xaxis.mode&&(this.panel.xaxis.name||(this.panel.xaxis.name="specify field")),this.selectors=E.wl.components.Panels.Visualization.Graph.VisualizationTab}setUnitFormat(e){return t=>{e.format=t,this.panel.fieldConfig.defaults.unit?(this.panel.fieldConfig.defaults.unit=void 0,this.panelCtrl.refresh()):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)}}function Fe(){return{restrict:"E",scope:!0,templateUrl:"public/app/plugins/panel/graph/axes_editor.html",controller:$e}}$e.$inject=["$scope"];var je=i(76261);function Re(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class Ie extends ke.k{constructor(e,t){super(e,t),Re(this,"renderError",!1),Re(this,"hiddenSeries",{}),Re(this,"hiddenSeriesTainted",!1),Re(this,"seriesList",[]),Re(this,"dataList",[]),Re(this,"annotations",[]),Re(this,"alertState",void 0),Re(this,"dataWarning",void 0),Re(this,"colors",[]),Re(this,"subTabIndex",0),Re(this,"processor",void 0),Re(this,"contextMenuCtrl",void 0),Re(this,"panelDefaults",{datasource:null,renderer:"flot",yaxes:[{label:null,show:!0,logBase:1,min:null,max:null,format:"short"},{label:null,show:!0,logBase:1,min:null,max:null,format:"short"}],xaxis:{show:!0,mode:"time",name:null,values:[],buckets:null},yaxis:{align:!1,alignLevel:null},lines:!0,fill:1,fillGradient:0,linewidth:1,dashes:!1,hiddenSeries:!1,dashLength:10,spaceLength:10,points:!1,pointradius:2,bars:!1,stack:!1,percentage:!1,legend:{show:!0,values:!1,min:!1,max:!1,current:!1,total:!1,avg:!1},nullPointMode:"null",steppedLine:!1,tooltip:{value_type:"individual",shared:!0,sort:0},timeFrom:null,timeShift:null,targets:[{}],aliasColors:{},seriesOverrides:[],thresholds:[],timeRegions:[],options:{alertThreshold:!0}}),Re(this,"onColorChange",((e,t)=>{e.setColor(_.ZP.theme.visualization.getColorByName(t)),this.panel.aliasColors[e.alias]=t,this.render()})),Re(this,"onToggleSeries",(e=>{this.hiddenSeriesTainted=!0,this.hiddenSeries=e,this.render()})),Re(this,"onToggleSort",((e,t)=>{this.panel.legend.sort=e,this.panel.legend.sortDesc=t,this.render()})),Re(this,"onToggleAxis",(e=>{let t=(0,o.find)(this.panel.seriesOverrides,{alias:e.alias});t||(t={alias:e.alias},this.panel.seriesOverrides.push(t)),t.yaxis=e.yaxis,this.render()})),Re(this,"onContextMenuClose",(()=>{this.contextMenuCtrl.toggleMenu()})),Re(this,"getTimeZone",(()=>this.dashboard.getTimezone())),Re(this,"getDataFrameByRefId",(e=>this.dataList.filter((t=>t.refId===e))[0])),(0,o.defaults)(this.panel,this.panelDefaults),(0,o.defaults)(this.panel.tooltip,this.panelDefaults.tooltip),(0,o.defaults)(this.panel.legend,this.panelDefaults.legend),(0,o.defaults)(this.panel.xaxis,this.panelDefaults.xaxis),(0,o.defaults)(this.panel.options,this.panelDefaults.options),this.useDataFrames=!0,this.processor=new je.$(this.panel),this.contextMenuCtrl=new Pe(e),this.events.on(b.PanelEvents.render,this.onRender.bind(this)),this.events.on(b.PanelEvents.dataFramesReceived,this.onDataFramesReceived.bind(this)),this.events.on(b.PanelEvents.dataSnapshotLoad,this.onDataSnapshotLoad.bind(this)),this.events.on(b.PanelEvents.editModeInitialized,this.onInitEditMode.bind(this)),this.events.on(b.PanelEvents.initPanelActions,this.onInitPanelActions.bind(this));const i=this.panel.fieldConfig.defaults.unit;i&&(this.panel.yaxes[0].format=i)}onInitEditMode(){this.addEditorTab("Display","public/app/plugins/panel/graph/tab_display.html"),this.addEditorTab("Series overrides","public/app/plugins/panel/graph/tab_series_overrides.html"),this.addEditorTab("Axes",Fe),this.addEditorTab("Legend","public/app/plugins/panel/graph/tab_legend.html"),this.addEditorTab("Thresholds","public/app/plugins/panel/graph/tab_thresholds.html"),this.addEditorTab("Time regions","public/app/plugins/panel/graph/tab_time_regions.html"),this.subTabIndex=0,this.hiddenSeriesTainted=!1}onInitPanelActions(e){e.push({text:"Toggle legend",click:"ctrl.toggleLegend()",shortcut:"p l"})}zoomOut(e){T.h$.publish(new Le.p8({scale:2}))}onDataSnapshotLoad(e){const{series:t,annotations:i}=(0,Ee.y)(this.panel,this.dashboard);this.panelData.annotations=i,this.onDataFramesReceived(t)}onDataFramesReceived(e){var t;this.dataList=e,this.seriesList=this.processor.getSeriesList({dataList:this.dataList,range:this.range}),this.dataWarning=this.getDataWarning(),this.alertState=void 0,this.seriesList.alertState=void 0,this.panelData.alertState&&(this.alertState=this.panelData.alertState,this.seriesList.alertState=this.alertState.state),this.annotations=[],null!==(t=this.panelData.annotations)&&void 0!==t&&t.length&&(this.annotations=(0,Ae.em)(this.panelData.annotations)),this.loading=!1,this.render(this.seriesList)}getDataWarning(){if(0===this.seriesList.reduce(((e,t)=>e+t.datapoints.length),0)){if(this.dataList)for(const t of this.dataList){var e;if(t.length&&null!==(e=t.fields)&&void 0!==e&&e.length)return{title:"Unable to graph data",tip:"Data exists, but is not timeseries",actionText:"Switch to table view",action:()=>{(0,Me.WI)((0,we.Kc)({panel:this.panel,pluginId:"table"}))}}}return{title:"No data",tip:"No data returned from query"}}for(const e of this.seriesList)if(!e.isOutsideRange)return;const t={title:"Data outside time range",tip:"Can be caused by timezone mismatch or missing time filter in query"},i=function(e){const t={from:Number.MAX_SAFE_INTEGER,to:Number.MIN_SAFE_INTEGER};let i=!1;const s=[b.ReducerID.min,b.ReducerID.max];for(const n of e)for(const e of n.fields)if(e.type===b.FieldType.time){const n=(0,b.reduceField)({field:e,reducers:s});t.from=Math.min(t.from,n[b.ReducerID.min]),t.to=Math.max(t.to,n[b.ReducerID.max]),i=!0}return i?t:void 0}(this.dataList);return i&&(t.actionText="Zoom to data",t.action=()=>{l.locationService.partial({from:i.from,to:i.to})}),t}onRender(){if(this.seriesList){Se.X.alertToGraphThresholds(this.panel);for(const e of this.seriesList)e.applySeriesOverrides(this.panel.seriesOverrides),e.unit&&(this.panel.yaxes[e.yaxis-1].format=e.unit),!1===this.hiddenSeriesTainted&&!0===e.hiddenSeries&&(this.hiddenSeries[e.alias]=!0)}}addSeriesOverride(e){this.panel.seriesOverrides.push(e||{})}removeSeriesOverride(e){this.panel.seriesOverrides=(0,o.without)(this.panel.seriesOverrides,e),this.render()}toggleLegend(){this.panel.legend.show=!this.panel.legend.show,this.render()}legendValuesOptionChanged(){const e=this.panel.legend;e.values=e.min||e.max||e.avg||e.current||e.total,this.render()}migrateToReact(){this.onPluginTypeChange(_.ZP.panels.timeseries)}}Ie.$inject=["$scope","$injector"],Re(Ie,"template",'\n<div class="graph-panel" ng-class="{\'graph-panel--legend-right\': ctrl.panel.legend.rightSide}">\n <div class="graph-panel__chart" grafana-graph ng-dblclick="ctrl.zoomOut()">\n </div>\n\n <div class="graph-legend">\n <div class="graph-legend-content" graph-legend></div>\n </div>\n <div ng-if="ctrl.contextMenuCtrl.isVisible">\n <graph-context-menu\n itemsGroup="ctrl.contextMenuCtrl.menuItemsSupplier()"\n on-close="ctrl.onContextMenuClose"\n getContextMenuSource="ctrl.contextMenuCtrl.getSource"\n timeZone="ctrl.getTimeZone()"\n x="ctrl.contextMenuCtrl.position.x"\n y="ctrl.contextMenuCtrl.position.y"\n ></graph-context-menu>\n </div>\n</div>\n');const We=new b.PanelPlugin(null).useFieldConfig({disableStandardOptions:[b.FieldConfigProperty.NoValue,b.FieldConfigProperty.Thresholds,b.FieldConfigProperty.Max,b.FieldConfigProperty.Min,b.FieldConfigProperty.Decimals,b.FieldConfigProperty.Color,b.FieldConfigProperty.Mappings]}).setDataSupport({annotations:!0,alertStates:!0}).setMigrationHandler((e=>{var t;const i=null!==(t=e.fieldConfig)&&void 0!==t?t:{defaults:{},overrides:[]},s=e.options||{};return s.dataLinks&&(i.defaults.links=s.dataLinks,delete s.dataLinks),e.options=s,e.fieldConfig=i,s}));We.angularPanelCtrl=Ie}}]);
  2. //# sourceMappingURL=graphPlugin.03c5ce2be5546aefa06c.js.map