Build 545032stable
Module 229659
1,440 characters · in 5b2050d9eb8d4248.jsDependencies
Source Raw
function(e,t,n){n.d(t,{A:()=>o});var i=n(627968),l=n(64700),s=n(205459),r=n(661531),a=n(602853);function o(e){let t=(0,l.useRef)(null),[n,o]=(0,l.useState)(null),[u]=(0,l.useState)(()=>new s.TimelineDataSeries),d=(0,a.r)(r.A.colors.BACKGROUND_BASE_LOW).hsl(),c=(0,a.r)(r.A.colors.TEXT_DEFAULT).hsl(),h=(0,a.r)(r.A.colors.BACKGROUND_MOD_MUTED).hsl(),g=(0,a.r)(r.A.unsafe_rawColors.BRAND_500).hsl(),f=e.windowMs;(0,l.useEffect)(()=>{let e=t.current;if(null==e)return;let n=new s.TimelineGraphView(e,window.devicePixelRatio??1);n.backgroundColor=d,n.textColor=c,n.gridColor=h,n.timeOptions={timeStyle:"short"},n.fontFamily="gg sans",n.fontSize=11,null!=f&&n.setScale(f/e.width),u.setColor(g),n.addDataSeries(u),n.updateEndDate(),o(n)},[t,d,g,h,c,u,f,e.width]);let A=e.converter,E=null!=A?e.dataPoints.map(e=>({...e,value:A(e.value)})):e.dataPoints;u.setPoints(E),n?.updateEndDate(),n?.repaint(),(0,l.useLayoutEffect)(()=>{if(null==e.markers||0===e.markers.length||null==e.windowMs||null==t.current)return;let n=t.current,i=n.getContext("2d");if(null==i)return;let l=Date.now();for(let t of(i.lineWidth=window.devicePixelRatio??1,e.markers)){let s=l-t.time;if(s<0||s>e.windowMs)continue;let r=n.width*(1-s/e.windowMs);i.save(),i.strokeStyle=t.color,i.beginPath(),i.moveTo(r,0),i.lineTo(r,n.height),i.stroke(),i.restore()}});let I={width:e.width,height:e.height};return(0,i.jsx)("canvas",{style:I,width:e.width,height:e.height,ref:t},"canvas")}}