"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[2666],{32930(R,c,e){e.d(c,{O:()=>a});var C=e(87228);const a=(y,o,f,v,F)=>{const x=[];if(o.state?.scopedVars){const m=new Set;(0,C.ko)(y,o,o.state.scopedVars,f,o.config.actions??[],{valueRowIndex:v},F).forEach(g=>{const h=`${g.title}`;m.has(h)||(x.push(g),m.add(h))})}return x}},14474(R,c,e){e.r(c),e.d(c,{plugin:()=>J});var C=e(45468),a=e(17727),y=e(15283),o=e(52358),f=e(28520),v=e(6980),F=e(8538),x=e(50467),m=e(87452),r=e(74848),g=e(96540),h=e(60642),U=e(69192),p=e(35831),I=e(47018),D=e(14707),G=e(96887),T=e(53151),L=e(37555),V=e(47172),W=e(23817),B=e(51342),X=e(26746),Z=e(63075),H=e(47468),$=e(97521);function A(n,i){if(n.length>1)return{warning:"Only one frame is supported, consider adding a join transformation",frames:n};let t;if(i){if(t=(0,H.gG)(i,n[0]),t==null)return{warning:"Unable to find field: "+i,frames:n}}else if(t=n[0]?n[0].fields.findIndex(l=>l.type===a.PU.number):-1,t===-1)return{warning:"No numeric fields found for X axis",frames:n};if(t!=null){const l=n[0].fields[t];if(l.type===a.PU.number&&!(0,X.g2)(l.values))return{warning:"Values must be in ascending order",frames:n}}return{frames:(0,$.B_)(n,Z.Ay.theme2,void 0,t)}}const K=({data:n,timeRange:i,timeZone:t,width:l,height:Q,options:s,fieldConfig:z,replaceVariables:M,id:N,title:Y})=>{const{dataLinkPostProcessor:w}=(0,h.Cq)(),{canExecuteActions:O}=(0,D.d2)(),b=(0,g.useMemo)(()=>O?.()??!1,[O]),k=s.xField??n.series[0]?.fields.find(d=>d.type===a.PU.number)?.name,q=(d,u,S)=>(u={...u,x:U.sJ.get(p.Ct.byName).get(k)},(0,V.m)(d,u)),P=(0,g.useMemo)(()=>A(n.series,s.xField),[n.series,s.xField]);if(P.warning||!P.frames)return(0,r.jsx)(I.a,{panelId:N,fieldConfig:z,data:n,message:P.warning,needsNumberField:!0});const E=P.frames;return(0,r.jsx)(W.Z,{frames:E,structureRev:n.structureRev,timeRange:i,timeZone:t,width:l,height:Q,legend:s.legend,options:s,preparePlotFrame:q,replaceVariables:M,dataLinkPostProcessor:w,children:(d,u)=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(G.Z,{config:d}),s.tooltip.mode!==f.$N.None&&(0,r.jsx)(T.xl,{config:d,hoverMode:s.tooltip.mode===f.$N.Single?T.b3.xOne:T.b3.xAll,getDataLinks:(S,j)=>u.fields[S].getLinks?.({valueRowIndex:j})??[],render:(S,j,_,ee=!1,te,se,ie,ne)=>(0,r.jsx)(B.k,{series:u,dataIdxs:j,seriesIdx:_,mode:s.tooltip.mode,sortOrder:s.tooltip.sort,isPinned:ee,maxHeight:s.tooltip.maxHeight,replaceVariables:M,dataLinks:ne,hideZeros:s.tooltip.hideZeros,canExecuteActions:b,assistantContext:(0,L.R)({id:N,title:Y,timeRange:i,data:n},E)}),maxWidth:s.tooltip.maxWidth})]})})},J=new C.m(K).useFieldConfig((0,m.V)(m.S,!1)).setPanelOptions(n=>{const i=[(0,o.t)("trend.category-x-axis","X axis")];n.addFieldNamePicker({path:"xField",name:(0,o.t)("trend.name-x-field","X field"),description:(0,o.t)("trend.description-x-field","An increasing numeric value"),category:i,defaultValue:void 0,settings:{isClearable:!0,placeholderText:(0,o.t)("trend.placeholder-x-field","First numeric value"),filter:t=>t.type===a.PU.number}}),v.D(n,!1,!0,v.U),F.H(n,!0,!0)}).setSuggestionsSupplier(n=>{if(!n.rawFrames||n.fieldCountByType(a.PU.number)<2||n.rowCountTotal<2||n.rowCountTotal<2||n.frameCount>1)return;const i=A(n.rawFrames);if(!(i.warning||!i.frames))return[{score:y.nQ.Good,fieldConfig:{defaults:{custom:{}},overrides:[]},cardOptions:{previewModifier:t=>{t.options.legend=x.PI,t.fieldConfig?.defaults.custom?.drawStyle!==f.GR.Bars&&(t.fieldConfig.defaults.custom.lineWidth=Math.max(t.fieldConfig.defaults.custom.lineWidth??1,2))}}}]})}}]);

//# sourceMappingURL=trendPanel.5f6a1b6b09eec784b86a.js.map