@deephaven/embed-chart 0.40.2 → 0.40.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/{App-16a94935.js → App-40b9035e.js} +2 -2
- package/build/assets/{App-16a94935.js.map → App-40b9035e.js.map} +1 -1
- package/build/assets/{index-0168b447.js → index-0b100882.js} +2 -2
- package/build/assets/{index-0168b447.js.map → index-0b100882.js.map} +1 -1
- package/build/assets/{index-1f2bffd7.js → index-38fe94c0.js} +2 -2
- package/build/assets/{index-1f2bffd7.js.map → index-38fe94c0.js.map} +1 -1
- package/build/assets/{useConnection-e2008d76.js → useConnection-2baa8601.js} +2 -2
- package/build/assets/useConnection-2baa8601.js.map +1 -0
- package/build/index.html +2 -2
- package/package.json +5 -5
- package/build/assets/useConnection-e2008d76.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var de=Object.defineProperty;var pe=(f,s,e)=>s in f?de(f,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[s]=e;var u=(f,s,e)=>(pe(f,typeof s!="symbol"?s+"":s,e),e);import{H as ue,r as $,G as ne,I as ge,J as z,C as W,K as me,L as Z}from"./vendor-f479e584.js";import{L as ee,d as fe,v as Ee,a as ye,b as Se}from"./index-0168b447.js";import{a as G,T as te,D as Te,F as se,b as Ae,u as De,c as Fe,C as be}from"./useConnection-e2008d76.js";import{P as he,b as xe,h as Ne,p as Pe,o as we,s as Le,t as Ie,c as Oe}from"./plotly-c5c6b912.js";import"./helpers-042e6b4d.js";he.register([xe,Ne,Pe,we,Le,Ie]);const L=class{constructor(s){u(this,"dh");u(this,"listeners");u(this,"formatter");u(this,"rect");u(this,"isDownsamplingDisabled");u(this,"title");this.dh=s,this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(L.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(L.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(L.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(L.EVENT_LOADFINISHED))}};let P=L;u(P,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(P,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(P,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(P,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(P,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(P,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(P,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(P,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const M=P,Me="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Re="#403e41",Ce="#5b5a5c",ve="#c0bfbf",ke="#4878ea",_e="rgba(91, 90, 92, 0.7)",A={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Me,gridcolor:Re,linecolor:Ce,zerolinecolor:ve,activecolor:ke,rangebgcolor:_e,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},I=Object.freeze({paper_bgcolor:A["paper-bgcolor"],plot_bgcolor:A["plot-bgcolor"],title_color:A["title-color"],colorway:A.colorway,gridcolor:A.gridcolor,linecolor:A.linecolor,zerolinecolor:A.zerolinecolor,activecolor:A.activecolor,rangebgcolor:A.rangebgcolor,area_color:A["area-color"],trend_color:A["trend-color"],line_color:A["line-color"],error_band_line_color:A["error-band-line-color"],error_band_fill_color:A["error-band-fill-color"],ohlc_increasing:A["ohlc-increasing"],ohlc_decreasing:A["ohlc-decreasing"]}),j=ee.module("ChartUtils"),ae="io.deephaven.time.DateTime",Ve=36e5,He=1e6;function Ue(f){return f.asDate!==void 0}function $e(f){return f.asNumber!==void 0}function le(f){return f.dhTimeZone!==void 0}function We(f){return f!=null&&f.range!=null&&(f.autorange===!1||f.autorange===void 0)}const d=class{constructor(s){u(this,"dh");u(this,"daysOfWeek");this.dh=s,this.daysOfWeek=Object.freeze(s.calendar.DayOfWeek.values())}static getPlotlyErrorBars(s,e,t){const i=t.map((n,r)=>n-s[r]),o=e.map((n,r)=>s[r]-n);return{type:"data",symmetric:!1,array:i,arrayminus:o}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const o=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);G(o);const[,n,r,a,,c,l,h,p,g]=o,m=a.replace(",","").length,T=r.indexOf(",")>=0||a.indexOf(",")>=0?",":"",b=h!=null&&h!==""?"e":"f",E=p!==""?p:b,N=c.length+l.length,x=`0${m}${T}.${N}${E}`,V=d.convertNumberPrefix(n),R=d.convertNumberPrefix(g);return{tickformat:x,tickprefix:V,ticksuffix:R,automargin:!0}}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const o=s||{};let n=i;return t&&(n=i/He),e.log&&(n=Math.log(n)),o.tickmode="linear",o.dtick=n,o}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let o=0;o<i.sources.length;o+=1){const n=i.sources[o];if(n.axis===e)return n}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,o=d.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:o,showlegend:i??void 0}}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const o=t[i];for(let n=0;n<o.series.length;n+=1)if(e===o.series[n])return o}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const o=t[i],n=s[o];We(n)&&(e[o]=[...n.range])}return e}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static groupArray(s,e){return s.reduce((t,i)=>{const o=i[e],n=t.get(o)??[];return n.push(i),t.set(o,n),t},new Map)}static getColorwayFromTheme(s=I){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):j.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},o=d.getAllAxes(s),n=d.groupArray(o,"type"),{charts:r}=s;for(let a=0;a<r.length;a+=1){const c=r[a];for(let l=0;l<c.series.length;l+=1){const h=c.series[l],{sources:p}=h,g=p.filter(m=>m.axis);for(let m=0;m<g.length;m+=1){const y=g[m],{axis:T}=y,{type:b}=T,E=n.get(b);G(E);const N=E.indexOf(T),w=this.getAxisPropertyName(b);if(w!=null){const x=d.getAxisLayoutProperty(w,N);if(t.has(x))j.debug(`${x} already added.`);else{j.debug(`Adding ${x} to axisFormats.`);const V=this.getPlotlyAxisFormat(y,e);if(V===null)t.set(x,i);else{t.set(x,V);const{businessCalendar:R}=T;if(R!=null){const O=[],{businessPeriods:v,businessDays:q,holidays:H,timeZone:U}=R,X=e==null?void 0:e.getColumnTypeFormatter(ae);let k;le(X)&&(k=X.dhTimeZone);const K=k?(U.standardOffset-k.standardOffset)/60:0;H.length>0&&O.push(...this.createRangeBreakValuesFromHolidays(H,U,k)),v.forEach(_=>O.push({pattern:"hour",bounds:[d.periodToDecimal(_.close)+K,d.periodToDecimal(_.open)+K]})),q.length<this.daysOfWeek.length&&this.createBoundsFromDays(q).forEach(_=>O.push({pattern:"day of week",bounds:_})),V.rangebreaks=O}if(t.size===c.axes.length)return t}}}}}}return t}getPlotlyChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case t.plot.SeriesPlotStyle.LINE:return"scatter";case t.plot.SeriesPlotStyle.BAR:case t.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case t.plot.SeriesPlotStyle.PIE:return"pie";case t.plot.SeriesPlotStyle.TREEMAP:return"treemap";case t.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case t.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(s,e,t){const{dh:i}=this,o=new Set;switch(s){case i.plot.SeriesPlotStyle.SCATTER:(e??!1)&&o.add(d.MODE_LINES),(t??!0)&&o.add(d.MODE_MARKERS);break;case i.plot.SeriesPlotStyle.LINE:(e??!0)&&o.add(d.MODE_LINES),(t??!1)&&o.add(d.MODE_MARKERS);break}return o.size>0?[...o].join("+"):void 0}getPlotlyProperty(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.PIE:switch(e){case t.plot.SourceType.X:return"labels";case t.plot.SourceType.Y:return"values"}break;case t.plot.SeriesPlotStyle.OHLC:switch(e){case t.plot.SourceType.TIME:return"x"}break;case t.plot.SeriesPlotStyle.TREEMAP:switch(e){case t.plot.SourceType.X:return"ids";case t.plot.SourceType.Y:return"values";case t.plot.SourceType.LABEL:return"labels";case t.plot.SourceType.PARENT:return"parents";case t.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case t.plot.SourceType.X:return"x";case t.plot.SourceType.Y:return"y";case t.plot.SourceType.Z:return"z";case t.plot.SourceType.X_LOW:return"xLow";case t.plot.SourceType.X_HIGH:return"xHigh";case t.plot.SourceType.Y_LOW:return"yLow";case t.plot.SourceType.Y_HIGH:return"yHigh";case t.plot.SourceType.TIME:return"time";case t.plot.SourceType.OPEN:return"open";case t.plot.SourceType.HIGH:return"high";case t.plot.SourceType.LOW:return"low";case t.plot.SourceType.CLOSE:return"close";case t.plot.SourceType.SHAPE:return"shape";case t.plot.SourceType.SIZE:return"size";case t.plot.SourceType.LABEL:return"label";case t.plot.SourceType.COLOR:return"color";case t.plot.SourceType.PARENT:return"parent";case t.plot.SourceType.HOVER_TEXT:return"hovertext";case t.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}getPlotlySeriesOrientation(s){var i,o;const{dh:e}=this,{sources:t}=s;return t.length===2&&((o=(i=t[0])==null?void 0:i.axis)==null?void 0:o.type)===e.plot.AxisType.Y?d.ORIENTATION.HORIZONTAL:d.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(s,e,t,i=null,o=I){const{name:n,isLinesVisible:r,isShapesVisible:a,plotStyle:c,lineColor:l,shapeColor:h,sources:p,shape:g,shapeSize:m}=s,y=p.some(w=>{var x;return(x=w.axis)==null?void 0:x.businessCalendar}),T=this.getChartType(c,y),b=this.getPlotlyChartMode(c,r??void 0,a??void 0),E=this.getPlotlySeriesOrientation(s),N=d.makeSeriesData(T,b,n,i,E);return this.addSourcesToSeriesData(N,c,p,e),this.addStylingToSeriesData(N,c,o,l,h,g,m,t),N}addSourcesToSeriesData(s,e,t,i){const o=s;for(let n=0;n<t.length;n+=1){const r=t[n],{axis:a,type:c}=r,l=this.getPlotlyProperty(e,c);ue(o,l,[]);const h=a!=null?this.getAxisPropertyName(a.type):null;if(h!=null){const p=i.get(a.type);if(p){const g=p.indexOf(a),m=g>0?`${g+1}`:"";o[`${h}axis`]=`${h}${m}`}}}}addStylingToSeriesData(s,e,t=I,i=null,o=null,n=null,r=null,a=null){const{dh:c}=this,l=s;if(l.marker={line:{}},l.line={width:1},e===c.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===c.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),o!=null&&(l.marker.color=o),n!=null&&n.length>0)try{l.marker.symbol=d.getMarkerSymbol(n)}catch(h){j.warn("Unable to handle shape",n,":",h)}r!=null&&(l.marker.size=r*d.DEFAULT_MARKER_SIZE),a!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(l.visible=a)}getChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(s,e)}}getAxisPropertyName(s){const{dh:e}=this;switch(s){case e.plot.AxisType.X:return"x";case e.plot.AxisType.Y:return"y";default:return null}}getAxisSide(s){const{dh:e}=this;switch(s){case e.plot.AxisPosition.BOTTOM:return"bottom";case e.plot.AxisPosition.TOP:return"top";case e.plot.AxisPosition.LEFT:return"left";case e.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(s,e,t,i=0,o=0,n=I){const r=s,a=d.getAllAxes(e);for(let c=0;c<e.charts.length;c+=1){const l=e.charts[c],h=t==null?void 0:t(l),p=this.getChartBounds(e,l,i,o);this.updateLayoutAxes(r,l.axes,a,i,o,p,h,n)}this.removeStaleAxes(r,a)}getChartBounds(s,e,t,i){const{dh:o}=this,{cols:n,rows:r}=s,{column:a,colspan:c,row:l,rowspan:h}=e,p=a+c,g=l+h,m=1/n,y=1/r,T=d.AXIS_SIZE_PX/t,b=d.AXIS_SIZE_PX/i,E={bottom:(r-g)*y+(g<r?b/2:0),top:(r-l)*y-(l>0?b/2:0),left:a*m+(a>0?T/2:0),right:p*m-(p<n?T/2:0)};return(d.groupArray(e.axes,"position").get(o.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(d.LEGEND_WIDTH_PX/t,d.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*d.DEFAULT_AXIS_SIZE),E}getPlotlyDateFormat(s,e,t){const{dh:i}=this,o=t==null?void 0:t.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let n;const r=s==null?void 0:s.getColumnTypeFormatter(e);return r!=null&&le(r)&&r.dhTimeZone!=null&&r.showTimeZone&&(n=i.i18n.DateTimeFormat.format(" z",new Date,r.dhTimeZone)),{tickformat:o,ticksuffix:n,automargin:!0}}getPlotlyAxisFormat(s,e=null){const{dh:t}=this,{axis:i,columnType:o}=s,{formatPattern:n}=i;let r=null;return te.isDateType(o)?(r=this.getPlotlyDateFormat(e,o,n),r=d.addTickSpacing(r,i,!0)):te.isNumberType(o)&&(r=d.getPlotlyNumberFormat(e,o,n),r=d.addTickSpacing(r,i,!1)),i.formatType===t.plot.AxisFormatType.CATEGORY&&(r?r.type="category":r={type:"category",tickformat:void 0,ticksuffix:void 0}),r}updateLayoutAxes(s,e,t,i=0,o=0,n={left:0,top:0,right:1,bottom:1},r,a=I){const{dh:c}=this,l=i>0?Math.max(d.MIN_AXIS_SIZE,Math.min(d.AXIS_SIZE_PX/o,d.MAX_AXIS_SIZE)):d.DEFAULT_AXIS_SIZE,h=o>0?Math.max(d.MIN_AXIS_SIZE,Math.min(d.AXIS_SIZE_PX/i,d.MAX_AXIS_SIZE)):d.DEFAULT_AXIS_SIZE,p=s,g=d.groupArray(e,"position"),m=d.groupArray(e,"type"),y=[...m.keys()],T=d.groupArray(t,"type");for(let b=0;b<y.length;b+=1){const E=y[b],N=this.getAxisPropertyName(E);if(N!=null){const w=m.get(E),x=T.get(E),R=E===c.plot.AxisType.Y?o:i;G(w),G(x);for(let O=0;O<w.length;O+=1){const v=w[O],q=x.indexOf(v),H=d.getAxisLayoutProperty(N,q);p[H]==null&&(p[H]=this.makeLayoutAxis(E,a));const U=p[H];if(U!=null){this.updateLayoutAxis(U,v,O,g,l,h,n);const{range:X,autorange:k}=U;if(r!=null&&X!==void 0&&(k===void 0||k===!1)){const K=r(v),[_,re]=K(X);j.debug("Setting downsample range",R,_,re),v.range(R,_,re)}else v.range(R)}}}}}removeStaleAxes(s,e){const t=s,i=d.groupArray(e,"type"),o=[...i.keys()];for(let n=0;n<o.length;n+=1){const r=o[n],a=i.get(r);G(a);let c=a.length;const l=this.getAxisPropertyName(r);if(l!=null){let h=d.getAxisLayoutProperty(l,c);for(;t[h]!=null;)delete t[h],c+=1,h=d.getAxisLayoutProperty(l,c)}}}updateLayoutAxis(s,e,t,i,o,n,r){const{dh:a}=this,l=e.type===a.plot.AxisType.Y?n:o,h=s,p=e.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=p:h.title={text:p},e.log&&(h.type="log"),h.side=this.getAxisSide(e.position),t>0){h.overlaying=this.getAxisPropertyName(e.type)??void 0;const g=i.get(e.position)??[],m=g.indexOf(e);m>0&&(h.anchor="free",e.position===a.plot.AxisPosition.RIGHT?h.position=r.right+(m-g.length+1)*l:e.position===a.plot.AxisPosition.TOP?h.position=r.top+(m-g.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?h.position=r.bottom+(g.length-m+1)*l:e.position===a.plot.AxisPosition.LEFT&&(h.position=r.left+(g.length-m+1)*l))}else if(e.type===a.plot.AxisType.X){const g=i.get(a.plot.AxisPosition.LEFT)||[],m=i.get(a.plot.AxisPosition.RIGHT)||[],y=Math.max(r.left,r.left+(g.length-1)*n),T=Math.min(r.right-(m.length-1)*n,r.right);h.domain=[y,T]}else if(e.type===a.plot.AxisType.Y){const g=i.get(a.plot.AxisPosition.BOTTOM)||[],m=i.get(a.plot.AxisPosition.TOP)||[],y=Math.max(r.bottom,r.bottom+(g.length-1)*o),T=Math.min(r.top-(m.length-1)*o,r.top);h.domain=[y,T]}}createBoundsFromDays(s){const e=s.map(n=>this.daysOfWeek.indexOf(n)),t=this.daysOfWeek.filter(n=>!s.includes(n)).map(n=>this.daysOfWeek.indexOf(n)),i=new Set;t.forEach(n=>{for(let r=n+1;r<n+this.daysOfWeek.length;r+=1){const a=r%this.daysOfWeek.length;if(e.includes(a)){i.add(a);break}}});const o=[];return i.forEach(n=>{for(let r=n-1;r>n-this.daysOfWeek.length;r-=1){const a=r<0?r+this.daysOfWeek.length:r;if(e.includes(a)){const c=(a+1)%7;o.push([c,n]);break}}}),o}createRangeBreakValuesFromHolidays(s,e,t){const i=[],o=[];return s.forEach(n=>{n.businessPeriods.length>0?o.push(...this.createPartialHoliday(n,e,t)):i.push(this.createFullHoliday(n,e,t))}),[{values:i},...o]}createFullHoliday(s,e,t){return this.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}createPartialHoliday(s,e,t){const i=s.date.toString(),o=["00:00"];s.businessPeriods.forEach(r=>{o.push(r.open),o.push(r.close)}),o.push("24:00");const n=[];for(let r=0;r<o.length;r+=2){const a=o[r],c=o[r+1];if(a!==c){const l=[this.adjustDateForTimeZone(`${i} ${a}:00.000000`,e,t)],h=Ve*(d.periodToDecimal(c)-d.periodToDecimal(a));n.push({values:l,dvalue:h})}}return n}adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?this.unwrapValue(this.wrapValue(s,ae,e),t):s}makeFigureSettings(s,e){const{dh:t}=this,{series:i,xAxis:o,type:n}=s,r=d.titleFromSettings(s),a={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.X}`,position:`${t.plot.AxisPosition.BOTTOM}`},c={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.Y}`,position:`${t.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${t.plot.ChartType.XY}`,axes:[a,c],series:(i??[]).map(l=>({plotStyle:`${n}`,name:l,dataSources:[{type:`${t.plot.SourceType.X}`,columnName:o??"",axis:a,table:e},{type:`${t.plot.SourceType.Y}`,columnName:l,axis:c,table:e}]}))}],title:r}}unwrapValue(s,e){const{dh:t}=this;if(s!=null){if(Ue(s))return t.i18n.DateTimeFormat.format(d.DATE_FORMAT,s,e);if($e(s))return s.asNumber()}return s}wrapValue(s,e,t=null){const{dh:i}=this;if(te.isDateType(e)&&typeof s=="string"){const o=s,n=d.DATE_FORMAT.substr(0,s.length),r=i.i18n.DateTimeFormat.parse(n,o);if(!t)return r;const a=`${n} Z`,c=i.i18n.DateTimeFormat.format("Z",r,t),l=i.i18n.DateTimeFormat.parse(a,`${o} ${c}`),h=i.i18n.DateTimeFormat.format("Z",l,t);return i.i18n.DateTimeFormat.parse(a,`${o} ${h}`)}return s}makeLayoutAxis(s,e=I){const{dh:t}=this,i={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===t.plot.AxisType.X?Object.assign(i,{showgrid:!0}):s===t.plot.AxisType.Y&&Object.assign(i,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),i}makeDefaultLayout(s=I){const{dh:e}=this,t={...s,autosize:!0,colorway:d.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif",color:s.title_color},title:{font:{color:s.title_color},yanchor:"top",pad:{...d.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...d.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s),polar:{angularaxis:this.makeLayoutAxis(e.plot.AxisType.SHAPE,s),radialaxis:this.makeLayoutAxis(e.plot.AxisType.SHAPE,s),bgcolor:s.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s),zaxis:this.makeLayoutAxis(e.plot.AxisType.Z,s)}};return t.datarevision=0,t}hydrateSettings(s){const{dh:e}=this;return{...s,type:s.type!=null?e.plot.SeriesPlotStyle[s.type]:void 0}}};let S=d;u(S,"DEFAULT_AXIS_SIZE",.15),u(S,"MIN_AXIS_SIZE",.025),u(S,"MAX_AXIS_SIZE",.2),u(S,"AXIS_SIZE_PX",75),u(S,"LEGEND_WIDTH_PX",50),u(S,"MAX_LEGEND_SIZE",.25),u(S,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(S,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(S,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(S,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(S,"SUBTITLE_LINE_HEIGHT",25),u(S,"DEFAULT_MARKER_SIZE",6),u(S,"MODE_MARKERS","markers"),u(S,"MODE_LINES","lines");const F=S;const C=ee.module("Chart"),B=class extends $.Component{constructor(e){super(e);u(this,"currentSeries");u(this,"PlotComponent");u(this,"plot");u(this,"plotWrapper");u(this,"columnFormats");u(this,"dateTimeFormatterOptions");u(this,"decimalFormatOptions");u(this,"integerFormatOptions");u(this,"rect");u(this,"ranges");u(this,"isSubscribed");u(this,"isLoadedFired");u(this,"getCachedConfig",ge((e,t,i,o,n)=>{const r=[],a=!!e;if(a&&r.push({name:`Downsampling failed: ${e}`,title:"Downsampling failed",click:()=>{},icon:B.convertIcon(fe),attr:"fill-warning"}),t||i||o||a){const g=B.downsampleButtonTitle(i,o),m=B.downsampleButtonAttr(i,o),y=i?Ee:ye;r.push({name:g,title:"Downsampling status",icon:B.convertIcon(y),click:this.handleDownsampleClick,attr:m})}const c=n.some(({type:g})=>g!=null&&!g.includes("3d")),l=n.some(({type:g})=>g!=null&&g.includes("3d")),h=["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"],p=["orbitRotation","tableRotation","resetCameraDefault3d"];return{displaylogo:!1,displayModeBar:i||a?!0:"hover",modeBarButtons:[r,["toImage"],["zoom2d","pan2d"],[...c?h:[],...l?p:[]]]}}));this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.PlotComponent=Oe(e.Plotly),this.plot=ne.createRef(),this.plotWrapper=ne.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,i]=e.icon,o=`${i}`;return{width:t,path:o,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){C.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:i}=e;switch(C.debug2("Received data update",t,i),t){case M.EVENT_UPDATED:{this.currentSeries+=1,this.setState(n=>{const{layout:r,revision:a}=n;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:i,layout:r,revision:a+1}});const{onUpdate:o}=this.props;o({isLoading:!this.isLoadedFired});break}case M.EVENT_LOADFINISHED:{const{onUpdate:o}=this.props;this.isLoadedFired=!0,o({isLoading:!1});break}case M.EVENT_DISCONNECT:{const{onDisconnect:o}=this.props;o();break}case M.EVENT_RECONNECT:{const{onReconnect:o}=this.props;o();break}case M.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case M.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case M.EVENT_DOWNSAMPLENEEDED:case M.EVENT_DOWNSAMPLEFAILED:{const o=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:o});const{onError:n}=this.props;n(new Error(o));break}default:C.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=F.getLayoutRanges(t);!z(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(C.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(C.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:o}=this.props;if(i!=null){const n=i.reduce((r,{name:a,visible:c})=>a!=null&&c==="legendonly"?[...r,a]:r,[]);o({hiddenSeries:n})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){C.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:o,model:n}=this.props;n.setDimensions(t),o&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=se.getColumnFormats(e),i=se.getDateTimeFormatterOptions(e),{decimalFormatOptions:o={},integerFormatOptions:n={}}=e;(!z(this.columnFormats,t)||!z(this.dateTimeFormatterOptions,i)||!z(this.decimalFormatOptions,o)||!z(this.integerFormatOptions,n))&&(this.columnFormats=se.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=o,this.integerFormatOptions=n,this.updateFormatter())}updateFormatter(){const{model:e}=this.props,t=new Ae(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){const e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(i=>{C.debug("Unable to resize, promise rejected",i)})}render(){const{PlotComponent:e}=this,{data:t,downsamplingError:i,isDownsampleFinished:o,isDownsampleInProgress:n,isDownsamplingDisabled:r,layout:a,revision:c}=this.state,l=this.getCachedConfig(i,o,n,r,t??[]),h=t!=null;return W.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:h&&W.jsx(e,{ref:this.plot,data:t,layout:a,revision:c,config:l,onAfterPlot:this.handleAfterPlot,onError:C.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let Q=B;u(Q,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Te.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:he,onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Be=Q,D=ee.module("FigureChartModel"),oe=class extends M{constructor(e,t,i={},o=I){super(e);u(this,"chartUtils");u(this,"dh");u(this,"figure");u(this,"settings");u(this,"theme");u(this,"data");u(this,"layout");u(this,"seriesDataMap");u(this,"pendingSeries");u(this,"oneClicks");u(this,"filterColumnMap");u(this,"lastFilter");u(this,"isConnected");u(this,"seriesToProcess");u(this,"addPendingSeries",me(()=>{const e=F.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const o=t[i],n=this.figure.charts.find(r=>r.series.includes(o));this.addSeries(o,e,(n==null?void 0:n.showLegend)??null),o.subscribe()}this.pendingSeries=[]},oe.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",Z((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));u(this,"getValueTranslator",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.unwrapValue(o,i)}));u(this,"getValueParser",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.wrapValue(o,e,i)}));u(this,"getRangeParser",Z((e,t)=>i=>{let[o,n]=i;const r=this.getValueParser(e,t);return o=r(o),n=r(n),[o,n]}));u(this,"getAxisRangeParser",Z((e,t)=>i=>{const o=F.getSourceForAxis(e,i);return o!=null?this.getRangeParser(o.columnType,t):n=>n}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.dh=e,this.chartUtils=new F(e),this.figure=t,this.settings=i,this.theme=o,this.data=[];const n={data:{},layout:this.chartUtils.makeDefaultLayout(o)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:n},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=F.getAllAxes(this.figure),i=[];for(let r=0;r<e.length;r+=1){const a=e[r];for(let c=0;c<a.series.length;c+=1){const l=a.series[c];i.push(l.name),this.addSeries(l,t,a.showLegend)}}const n=[...this.seriesDataMap.keys()].filter(r=>i.indexOf(r)<0);for(let r=0;r<n.length;r+=1){const a=n[r];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const{dh:o}=this,n=F.groupArray(t,"type"),r=this.chartUtils.makeSeriesDataFromSeries(e,n,F.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,r),this.data=[...this.seriesDataMap.values()],e.plotStyle===o.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===o.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=F.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===o.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:c}=a;for(let l=0;l<c.length;l+=1)this.filterColumnMap.set(c[l].name,c[l]);this.oneClicks.push(a)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){D.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;this.figure.addEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){const{dh:e}=this;this.figure.removeEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){D.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){D.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){D.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){D.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;D.debug2("handleFigureUpdated",i);for(let n=0;n<i.length;n+=1){const r=i[n];D.debug2("handleFigureUpdated updating series",r.name);const{sources:a}=r;for(let c=0;c<a.length;c+=1){const l=a[c],{columnType:h,type:p}=l,g=this.getValueTranslator(h,this.formatter),m=t.getArray(r,p,g);this.setDataArrayForSeries(r,p,m)}this.seriesToProcess.delete(r.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(r)}const{data:o}=this;this.fireUpdate(o)}handleRequestFailed(e){D.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){D.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){D.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;D.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var o;super.setTitle(e);const t=((o=(e??"").match(/<br>/g))==null?void 0:o.length)??0,i=F.DEFAULT_MARGIN.t+t*F.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=F.DEFAULT_TITLE_PADDING.t+t*F.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{D.debug(`Assigning ${i}`,this.layout[i],t);const o=this.layout[i];o!=null?Object.assign(o,t):D.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:o,plotStyle:n}=e,r=this.seriesDataMap.get(o),a=this.chartUtils.getPlotlyProperty(n,t);r&&ue(r,a,i)}cleanSeries(e){const{dh:t}=this,{name:i,plotStyle:o}=e,n=this.seriesDataMap.get(i);if(n!=null){if(o===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:r,xHigh:a}=n;if(r&&a&&r.length===a.length){const c=[];for(let l=0;l<r.length;l+=1)c.push(a[l]-r[l]);n.width=c}}else if(o===t.plot.SeriesPlotStyle.LINE){const{x:r,xLow:a,xHigh:c,y:l,yLow:h,yHigh:p}=n;a&&c&&a!==r&&(n.error_x=F.getPlotlyErrorBars(r,a,c)),h&&p&&h!==l&&(n.error_y=F.getPlotlyErrorBars(l,h,p))}else if(o===t.plot.SeriesPlotStyle.TREEMAP){const{ids:r,labels:a}=n;r!==void 0&&a===void 0&&(n.labels=r)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){D.warn("Trying to set a filter, but no one click!");return}D.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:o}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(r=>{const a=e.get(r);this.lastFilter.get(r)!==a&&o.find(c=>c.name===r)!=null&&i.setValueForColumn(r,a)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let J=oe;u(J,"ADD_SERIES_DEBOUNCE",50);const ce=J;class ie{static async makeModelFromSettings(s,e,t,i=I){const o=await ie.makeFigureFromSettings(s,e,t);return new ce(s,o,e,i)}static async makeFigureFromSettings(s,e,t){const i=await t.copy();return i.applyCustomColumns(t.customColumns),i.applyFilter(t.filter),i.applySort(t.sort),s.plot.Figure.create(new F(s).makeFigureSettings(e,i))}static async makeModel(s,e,t,i=I){return new ce(s,t,e,i)}}const Xe=ie;const Y=ee.module("EmbedChart.App");async function ze(f,s,e){Y.info(`Fetching figure ${e}...`);const t={name:e,type:f.VariableType.FIGURE};return s.getObject(t)}function Qe(){const[f,s]=$.useState(),[e,t]=$.useState(),[i,o]=$.useState(!0),n=$.useMemo(()=>new URLSearchParams(window.location.search),[]),r=De(),a=Fe();$.useEffect(function(){async function h(){try{const p=n.get("name");if(p==null)throw new Error("No name param provided");Y.debug("Loading figure",p,"...");const g=await ze(a,r,p);Y.debug("Creating model...");const m=await Xe.makeModel(a,void 0,g);s(m),Y.debug("Figure successfully loaded!")}catch(p){Y.error("Unable to load figure",p),t(`${p}`)}o(!1)}h()},[a,r,n]);const c=f!=null;return W.jsxs("div",{className:"App",children:[c&&W.jsx(Be,{model:f}),!c&&W.jsx(Se,{isLoaded:c,isLoading:i,errorMessage:e??null}),W.jsx(be,{})]})}export{Qe as default};
|
|
2
|
-
//# sourceMappingURL=App-
|
|
1
|
+
var de=Object.defineProperty;var pe=(f,s,e)=>s in f?de(f,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[s]=e;var u=(f,s,e)=>(pe(f,typeof s!="symbol"?s+"":s,e),e);import{H as ue,r as $,G as ne,I as ge,J as z,C as W,K as me,L as Z}from"./vendor-f479e584.js";import{L as ee,d as fe,v as Ee,a as ye,b as Se}from"./index-0b100882.js";import{a as G,T as te,D as Te,F as se,b as Ae,u as De,c as Fe,C as be}from"./useConnection-2baa8601.js";import{P as he,b as xe,h as Ne,p as Pe,o as we,s as Le,t as Ie,c as Oe}from"./plotly-c5c6b912.js";import"./helpers-042e6b4d.js";he.register([xe,Ne,Pe,we,Le,Ie]);const L=class{constructor(s){u(this,"dh");u(this,"listeners");u(this,"formatter");u(this,"rect");u(this,"isDownsamplingDisabled");u(this,"title");this.dh=s,this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(L.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(L.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(L.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(L.EVENT_LOADFINISHED))}};let P=L;u(P,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(P,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(P,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(P,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(P,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(P,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(P,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(P,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const M=P,Me="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Re="#403e41",Ce="#5b5a5c",ve="#c0bfbf",ke="#4878ea",_e="rgba(91, 90, 92, 0.7)",A={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Me,gridcolor:Re,linecolor:Ce,zerolinecolor:ve,activecolor:ke,rangebgcolor:_e,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},I=Object.freeze({paper_bgcolor:A["paper-bgcolor"],plot_bgcolor:A["plot-bgcolor"],title_color:A["title-color"],colorway:A.colorway,gridcolor:A.gridcolor,linecolor:A.linecolor,zerolinecolor:A.zerolinecolor,activecolor:A.activecolor,rangebgcolor:A.rangebgcolor,area_color:A["area-color"],trend_color:A["trend-color"],line_color:A["line-color"],error_band_line_color:A["error-band-line-color"],error_band_fill_color:A["error-band-fill-color"],ohlc_increasing:A["ohlc-increasing"],ohlc_decreasing:A["ohlc-decreasing"]}),j=ee.module("ChartUtils"),ae="io.deephaven.time.DateTime",Ve=36e5,He=1e6;function Ue(f){return f.asDate!==void 0}function $e(f){return f.asNumber!==void 0}function le(f){return f.dhTimeZone!==void 0}function We(f){return f!=null&&f.range!=null&&(f.autorange===!1||f.autorange===void 0)}const d=class{constructor(s){u(this,"dh");u(this,"daysOfWeek");this.dh=s,this.daysOfWeek=Object.freeze(s.calendar.DayOfWeek.values())}static getPlotlyErrorBars(s,e,t){const i=t.map((n,r)=>n-s[r]),o=e.map((n,r)=>s[r]-n);return{type:"data",symmetric:!1,array:i,arrayminus:o}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const o=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);G(o);const[,n,r,a,,c,l,h,p,g]=o,m=a.replace(",","").length,T=r.indexOf(",")>=0||a.indexOf(",")>=0?",":"",b=h!=null&&h!==""?"e":"f",E=p!==""?p:b,N=c.length+l.length,x=`0${m}${T}.${N}${E}`,V=d.convertNumberPrefix(n),R=d.convertNumberPrefix(g);return{tickformat:x,tickprefix:V,ticksuffix:R,automargin:!0}}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const o=s||{};let n=i;return t&&(n=i/He),e.log&&(n=Math.log(n)),o.tickmode="linear",o.dtick=n,o}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let o=0;o<i.sources.length;o+=1){const n=i.sources[o];if(n.axis===e)return n}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,o=d.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:o,showlegend:i??void 0}}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const o=t[i];for(let n=0;n<o.series.length;n+=1)if(e===o.series[n])return o}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const o=t[i],n=s[o];We(n)&&(e[o]=[...n.range])}return e}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static groupArray(s,e){return s.reduce((t,i)=>{const o=i[e],n=t.get(o)??[];return n.push(i),t.set(o,n),t},new Map)}static getColorwayFromTheme(s=I){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):j.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},o=d.getAllAxes(s),n=d.groupArray(o,"type"),{charts:r}=s;for(let a=0;a<r.length;a+=1){const c=r[a];for(let l=0;l<c.series.length;l+=1){const h=c.series[l],{sources:p}=h,g=p.filter(m=>m.axis);for(let m=0;m<g.length;m+=1){const y=g[m],{axis:T}=y,{type:b}=T,E=n.get(b);G(E);const N=E.indexOf(T),w=this.getAxisPropertyName(b);if(w!=null){const x=d.getAxisLayoutProperty(w,N);if(t.has(x))j.debug(`${x} already added.`);else{j.debug(`Adding ${x} to axisFormats.`);const V=this.getPlotlyAxisFormat(y,e);if(V===null)t.set(x,i);else{t.set(x,V);const{businessCalendar:R}=T;if(R!=null){const O=[],{businessPeriods:v,businessDays:q,holidays:H,timeZone:U}=R,X=e==null?void 0:e.getColumnTypeFormatter(ae);let k;le(X)&&(k=X.dhTimeZone);const K=k?(U.standardOffset-k.standardOffset)/60:0;H.length>0&&O.push(...this.createRangeBreakValuesFromHolidays(H,U,k)),v.forEach(_=>O.push({pattern:"hour",bounds:[d.periodToDecimal(_.close)+K,d.periodToDecimal(_.open)+K]})),q.length<this.daysOfWeek.length&&this.createBoundsFromDays(q).forEach(_=>O.push({pattern:"day of week",bounds:_})),V.rangebreaks=O}if(t.size===c.axes.length)return t}}}}}}return t}getPlotlyChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case t.plot.SeriesPlotStyle.LINE:return"scatter";case t.plot.SeriesPlotStyle.BAR:case t.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case t.plot.SeriesPlotStyle.PIE:return"pie";case t.plot.SeriesPlotStyle.TREEMAP:return"treemap";case t.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case t.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(s,e,t){const{dh:i}=this,o=new Set;switch(s){case i.plot.SeriesPlotStyle.SCATTER:(e??!1)&&o.add(d.MODE_LINES),(t??!0)&&o.add(d.MODE_MARKERS);break;case i.plot.SeriesPlotStyle.LINE:(e??!0)&&o.add(d.MODE_LINES),(t??!1)&&o.add(d.MODE_MARKERS);break}return o.size>0?[...o].join("+"):void 0}getPlotlyProperty(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.PIE:switch(e){case t.plot.SourceType.X:return"labels";case t.plot.SourceType.Y:return"values"}break;case t.plot.SeriesPlotStyle.OHLC:switch(e){case t.plot.SourceType.TIME:return"x"}break;case t.plot.SeriesPlotStyle.TREEMAP:switch(e){case t.plot.SourceType.X:return"ids";case t.plot.SourceType.Y:return"values";case t.plot.SourceType.LABEL:return"labels";case t.plot.SourceType.PARENT:return"parents";case t.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case t.plot.SourceType.X:return"x";case t.plot.SourceType.Y:return"y";case t.plot.SourceType.Z:return"z";case t.plot.SourceType.X_LOW:return"xLow";case t.plot.SourceType.X_HIGH:return"xHigh";case t.plot.SourceType.Y_LOW:return"yLow";case t.plot.SourceType.Y_HIGH:return"yHigh";case t.plot.SourceType.TIME:return"time";case t.plot.SourceType.OPEN:return"open";case t.plot.SourceType.HIGH:return"high";case t.plot.SourceType.LOW:return"low";case t.plot.SourceType.CLOSE:return"close";case t.plot.SourceType.SHAPE:return"shape";case t.plot.SourceType.SIZE:return"size";case t.plot.SourceType.LABEL:return"label";case t.plot.SourceType.COLOR:return"color";case t.plot.SourceType.PARENT:return"parent";case t.plot.SourceType.HOVER_TEXT:return"hovertext";case t.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}getPlotlySeriesOrientation(s){var i,o;const{dh:e}=this,{sources:t}=s;return t.length===2&&((o=(i=t[0])==null?void 0:i.axis)==null?void 0:o.type)===e.plot.AxisType.Y?d.ORIENTATION.HORIZONTAL:d.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(s,e,t,i=null,o=I){const{name:n,isLinesVisible:r,isShapesVisible:a,plotStyle:c,lineColor:l,shapeColor:h,sources:p,shape:g,shapeSize:m}=s,y=p.some(w=>{var x;return(x=w.axis)==null?void 0:x.businessCalendar}),T=this.getChartType(c,y),b=this.getPlotlyChartMode(c,r??void 0,a??void 0),E=this.getPlotlySeriesOrientation(s),N=d.makeSeriesData(T,b,n,i,E);return this.addSourcesToSeriesData(N,c,p,e),this.addStylingToSeriesData(N,c,o,l,h,g,m,t),N}addSourcesToSeriesData(s,e,t,i){const o=s;for(let n=0;n<t.length;n+=1){const r=t[n],{axis:a,type:c}=r,l=this.getPlotlyProperty(e,c);ue(o,l,[]);const h=a!=null?this.getAxisPropertyName(a.type):null;if(h!=null){const p=i.get(a.type);if(p){const g=p.indexOf(a),m=g>0?`${g+1}`:"";o[`${h}axis`]=`${h}${m}`}}}}addStylingToSeriesData(s,e,t=I,i=null,o=null,n=null,r=null,a=null){const{dh:c}=this,l=s;if(l.marker={line:{}},l.line={width:1},e===c.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===c.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),o!=null&&(l.marker.color=o),n!=null&&n.length>0)try{l.marker.symbol=d.getMarkerSymbol(n)}catch(h){j.warn("Unable to handle shape",n,":",h)}r!=null&&(l.marker.size=r*d.DEFAULT_MARKER_SIZE),a!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(l.visible=a)}getChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(s,e)}}getAxisPropertyName(s){const{dh:e}=this;switch(s){case e.plot.AxisType.X:return"x";case e.plot.AxisType.Y:return"y";default:return null}}getAxisSide(s){const{dh:e}=this;switch(s){case e.plot.AxisPosition.BOTTOM:return"bottom";case e.plot.AxisPosition.TOP:return"top";case e.plot.AxisPosition.LEFT:return"left";case e.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(s,e,t,i=0,o=0,n=I){const r=s,a=d.getAllAxes(e);for(let c=0;c<e.charts.length;c+=1){const l=e.charts[c],h=t==null?void 0:t(l),p=this.getChartBounds(e,l,i,o);this.updateLayoutAxes(r,l.axes,a,i,o,p,h,n)}this.removeStaleAxes(r,a)}getChartBounds(s,e,t,i){const{dh:o}=this,{cols:n,rows:r}=s,{column:a,colspan:c,row:l,rowspan:h}=e,p=a+c,g=l+h,m=1/n,y=1/r,T=d.AXIS_SIZE_PX/t,b=d.AXIS_SIZE_PX/i,E={bottom:(r-g)*y+(g<r?b/2:0),top:(r-l)*y-(l>0?b/2:0),left:a*m+(a>0?T/2:0),right:p*m-(p<n?T/2:0)};return(d.groupArray(e.axes,"position").get(o.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(d.LEGEND_WIDTH_PX/t,d.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*d.DEFAULT_AXIS_SIZE),E}getPlotlyDateFormat(s,e,t){const{dh:i}=this,o=t==null?void 0:t.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let n;const r=s==null?void 0:s.getColumnTypeFormatter(e);return r!=null&&le(r)&&r.dhTimeZone!=null&&r.showTimeZone&&(n=i.i18n.DateTimeFormat.format(" z",new Date,r.dhTimeZone)),{tickformat:o,ticksuffix:n,automargin:!0}}getPlotlyAxisFormat(s,e=null){const{dh:t}=this,{axis:i,columnType:o}=s,{formatPattern:n}=i;let r=null;return te.isDateType(o)?(r=this.getPlotlyDateFormat(e,o,n),r=d.addTickSpacing(r,i,!0)):te.isNumberType(o)&&(r=d.getPlotlyNumberFormat(e,o,n),r=d.addTickSpacing(r,i,!1)),i.formatType===t.plot.AxisFormatType.CATEGORY&&(r?r.type="category":r={type:"category",tickformat:void 0,ticksuffix:void 0}),r}updateLayoutAxes(s,e,t,i=0,o=0,n={left:0,top:0,right:1,bottom:1},r,a=I){const{dh:c}=this,l=i>0?Math.max(d.MIN_AXIS_SIZE,Math.min(d.AXIS_SIZE_PX/o,d.MAX_AXIS_SIZE)):d.DEFAULT_AXIS_SIZE,h=o>0?Math.max(d.MIN_AXIS_SIZE,Math.min(d.AXIS_SIZE_PX/i,d.MAX_AXIS_SIZE)):d.DEFAULT_AXIS_SIZE,p=s,g=d.groupArray(e,"position"),m=d.groupArray(e,"type"),y=[...m.keys()],T=d.groupArray(t,"type");for(let b=0;b<y.length;b+=1){const E=y[b],N=this.getAxisPropertyName(E);if(N!=null){const w=m.get(E),x=T.get(E),R=E===c.plot.AxisType.Y?o:i;G(w),G(x);for(let O=0;O<w.length;O+=1){const v=w[O],q=x.indexOf(v),H=d.getAxisLayoutProperty(N,q);p[H]==null&&(p[H]=this.makeLayoutAxis(E,a));const U=p[H];if(U!=null){this.updateLayoutAxis(U,v,O,g,l,h,n);const{range:X,autorange:k}=U;if(r!=null&&X!==void 0&&(k===void 0||k===!1)){const K=r(v),[_,re]=K(X);j.debug("Setting downsample range",R,_,re),v.range(R,_,re)}else v.range(R)}}}}}removeStaleAxes(s,e){const t=s,i=d.groupArray(e,"type"),o=[...i.keys()];for(let n=0;n<o.length;n+=1){const r=o[n],a=i.get(r);G(a);let c=a.length;const l=this.getAxisPropertyName(r);if(l!=null){let h=d.getAxisLayoutProperty(l,c);for(;t[h]!=null;)delete t[h],c+=1,h=d.getAxisLayoutProperty(l,c)}}}updateLayoutAxis(s,e,t,i,o,n,r){const{dh:a}=this,l=e.type===a.plot.AxisType.Y?n:o,h=s,p=e.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=p:h.title={text:p},e.log&&(h.type="log"),h.side=this.getAxisSide(e.position),t>0){h.overlaying=this.getAxisPropertyName(e.type)??void 0;const g=i.get(e.position)??[],m=g.indexOf(e);m>0&&(h.anchor="free",e.position===a.plot.AxisPosition.RIGHT?h.position=r.right+(m-g.length+1)*l:e.position===a.plot.AxisPosition.TOP?h.position=r.top+(m-g.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?h.position=r.bottom+(g.length-m+1)*l:e.position===a.plot.AxisPosition.LEFT&&(h.position=r.left+(g.length-m+1)*l))}else if(e.type===a.plot.AxisType.X){const g=i.get(a.plot.AxisPosition.LEFT)||[],m=i.get(a.plot.AxisPosition.RIGHT)||[],y=Math.max(r.left,r.left+(g.length-1)*n),T=Math.min(r.right-(m.length-1)*n,r.right);h.domain=[y,T]}else if(e.type===a.plot.AxisType.Y){const g=i.get(a.plot.AxisPosition.BOTTOM)||[],m=i.get(a.plot.AxisPosition.TOP)||[],y=Math.max(r.bottom,r.bottom+(g.length-1)*o),T=Math.min(r.top-(m.length-1)*o,r.top);h.domain=[y,T]}}createBoundsFromDays(s){const e=s.map(n=>this.daysOfWeek.indexOf(n)),t=this.daysOfWeek.filter(n=>!s.includes(n)).map(n=>this.daysOfWeek.indexOf(n)),i=new Set;t.forEach(n=>{for(let r=n+1;r<n+this.daysOfWeek.length;r+=1){const a=r%this.daysOfWeek.length;if(e.includes(a)){i.add(a);break}}});const o=[];return i.forEach(n=>{for(let r=n-1;r>n-this.daysOfWeek.length;r-=1){const a=r<0?r+this.daysOfWeek.length:r;if(e.includes(a)){const c=(a+1)%7;o.push([c,n]);break}}}),o}createRangeBreakValuesFromHolidays(s,e,t){const i=[],o=[];return s.forEach(n=>{n.businessPeriods.length>0?o.push(...this.createPartialHoliday(n,e,t)):i.push(this.createFullHoliday(n,e,t))}),[{values:i},...o]}createFullHoliday(s,e,t){return this.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}createPartialHoliday(s,e,t){const i=s.date.toString(),o=["00:00"];s.businessPeriods.forEach(r=>{o.push(r.open),o.push(r.close)}),o.push("24:00");const n=[];for(let r=0;r<o.length;r+=2){const a=o[r],c=o[r+1];if(a!==c){const l=[this.adjustDateForTimeZone(`${i} ${a}:00.000000`,e,t)],h=Ve*(d.periodToDecimal(c)-d.periodToDecimal(a));n.push({values:l,dvalue:h})}}return n}adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?this.unwrapValue(this.wrapValue(s,ae,e),t):s}makeFigureSettings(s,e){const{dh:t}=this,{series:i,xAxis:o,type:n}=s,r=d.titleFromSettings(s),a={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.X}`,position:`${t.plot.AxisPosition.BOTTOM}`},c={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.Y}`,position:`${t.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${t.plot.ChartType.XY}`,axes:[a,c],series:(i??[]).map(l=>({plotStyle:`${n}`,name:l,dataSources:[{type:`${t.plot.SourceType.X}`,columnName:o??"",axis:a,table:e},{type:`${t.plot.SourceType.Y}`,columnName:l,axis:c,table:e}]}))}],title:r}}unwrapValue(s,e){const{dh:t}=this;if(s!=null){if(Ue(s))return t.i18n.DateTimeFormat.format(d.DATE_FORMAT,s,e);if($e(s))return s.asNumber()}return s}wrapValue(s,e,t=null){const{dh:i}=this;if(te.isDateType(e)&&typeof s=="string"){const o=s,n=d.DATE_FORMAT.substr(0,s.length),r=i.i18n.DateTimeFormat.parse(n,o);if(!t)return r;const a=`${n} Z`,c=i.i18n.DateTimeFormat.format("Z",r,t),l=i.i18n.DateTimeFormat.parse(a,`${o} ${c}`),h=i.i18n.DateTimeFormat.format("Z",l,t);return i.i18n.DateTimeFormat.parse(a,`${o} ${h}`)}return s}makeLayoutAxis(s,e=I){const{dh:t}=this,i={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===t.plot.AxisType.X?Object.assign(i,{showgrid:!0}):s===t.plot.AxisType.Y&&Object.assign(i,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),i}makeDefaultLayout(s=I){const{dh:e}=this,t={...s,autosize:!0,colorway:d.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif",color:s.title_color},title:{font:{color:s.title_color},yanchor:"top",pad:{...d.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...d.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s),polar:{angularaxis:this.makeLayoutAxis(e.plot.AxisType.SHAPE,s),radialaxis:this.makeLayoutAxis(e.plot.AxisType.SHAPE,s),bgcolor:s.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s),zaxis:this.makeLayoutAxis(e.plot.AxisType.Z,s)}};return t.datarevision=0,t}hydrateSettings(s){const{dh:e}=this;return{...s,type:s.type!=null?e.plot.SeriesPlotStyle[s.type]:void 0}}};let S=d;u(S,"DEFAULT_AXIS_SIZE",.15),u(S,"MIN_AXIS_SIZE",.025),u(S,"MAX_AXIS_SIZE",.2),u(S,"AXIS_SIZE_PX",75),u(S,"LEGEND_WIDTH_PX",50),u(S,"MAX_LEGEND_SIZE",.25),u(S,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(S,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(S,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(S,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(S,"SUBTITLE_LINE_HEIGHT",25),u(S,"DEFAULT_MARKER_SIZE",6),u(S,"MODE_MARKERS","markers"),u(S,"MODE_LINES","lines");const F=S;const C=ee.module("Chart"),B=class extends $.Component{constructor(e){super(e);u(this,"currentSeries");u(this,"PlotComponent");u(this,"plot");u(this,"plotWrapper");u(this,"columnFormats");u(this,"dateTimeFormatterOptions");u(this,"decimalFormatOptions");u(this,"integerFormatOptions");u(this,"rect");u(this,"ranges");u(this,"isSubscribed");u(this,"isLoadedFired");u(this,"getCachedConfig",ge((e,t,i,o,n)=>{const r=[],a=!!e;if(a&&r.push({name:`Downsampling failed: ${e}`,title:"Downsampling failed",click:()=>{},icon:B.convertIcon(fe),attr:"fill-warning"}),t||i||o||a){const g=B.downsampleButtonTitle(i,o),m=B.downsampleButtonAttr(i,o),y=i?Ee:ye;r.push({name:g,title:"Downsampling status",icon:B.convertIcon(y),click:this.handleDownsampleClick,attr:m})}const c=n.some(({type:g})=>g!=null&&!g.includes("3d")),l=n.some(({type:g})=>g!=null&&g.includes("3d")),h=["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"],p=["orbitRotation","tableRotation","resetCameraDefault3d"];return{displaylogo:!1,displayModeBar:i||a?!0:"hover",modeBarButtons:[r,["toImage"],["zoom2d","pan2d"],[...c?h:[],...l?p:[]]]}}));this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.PlotComponent=Oe(e.Plotly),this.plot=ne.createRef(),this.plotWrapper=ne.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,i]=e.icon,o=`${i}`;return{width:t,path:o,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){C.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:i}=e;switch(C.debug2("Received data update",t,i),t){case M.EVENT_UPDATED:{this.currentSeries+=1,this.setState(n=>{const{layout:r,revision:a}=n;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:i,layout:r,revision:a+1}});const{onUpdate:o}=this.props;o({isLoading:!this.isLoadedFired});break}case M.EVENT_LOADFINISHED:{const{onUpdate:o}=this.props;this.isLoadedFired=!0,o({isLoading:!1});break}case M.EVENT_DISCONNECT:{const{onDisconnect:o}=this.props;o();break}case M.EVENT_RECONNECT:{const{onReconnect:o}=this.props;o();break}case M.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case M.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case M.EVENT_DOWNSAMPLENEEDED:case M.EVENT_DOWNSAMPLEFAILED:{const o=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:o});const{onError:n}=this.props;n(new Error(o));break}default:C.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=F.getLayoutRanges(t);!z(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(C.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(C.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:o}=this.props;if(i!=null){const n=i.reduce((r,{name:a,visible:c})=>a!=null&&c==="legendonly"?[...r,a]:r,[]);o({hiddenSeries:n})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){C.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:o,model:n}=this.props;n.setDimensions(t),o&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=se.getColumnFormats(e),i=se.getDateTimeFormatterOptions(e),{decimalFormatOptions:o={},integerFormatOptions:n={}}=e;(!z(this.columnFormats,t)||!z(this.dateTimeFormatterOptions,i)||!z(this.decimalFormatOptions,o)||!z(this.integerFormatOptions,n))&&(this.columnFormats=se.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=o,this.integerFormatOptions=n,this.updateFormatter())}updateFormatter(){const{model:e}=this.props,t=new Ae(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){const e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(i=>{C.debug("Unable to resize, promise rejected",i)})}render(){const{PlotComponent:e}=this,{data:t,downsamplingError:i,isDownsampleFinished:o,isDownsampleInProgress:n,isDownsamplingDisabled:r,layout:a,revision:c}=this.state,l=this.getCachedConfig(i,o,n,r,t??[]),h=t!=null;return W.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:h&&W.jsx(e,{ref:this.plot,data:t,layout:a,revision:c,config:l,onAfterPlot:this.handleAfterPlot,onError:C.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let Q=B;u(Q,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Te.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:he,onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Be=Q,D=ee.module("FigureChartModel"),oe=class extends M{constructor(e,t,i={},o=I){super(e);u(this,"chartUtils");u(this,"dh");u(this,"figure");u(this,"settings");u(this,"theme");u(this,"data");u(this,"layout");u(this,"seriesDataMap");u(this,"pendingSeries");u(this,"oneClicks");u(this,"filterColumnMap");u(this,"lastFilter");u(this,"isConnected");u(this,"seriesToProcess");u(this,"addPendingSeries",me(()=>{const e=F.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const o=t[i],n=this.figure.charts.find(r=>r.series.includes(o));this.addSeries(o,e,(n==null?void 0:n.showLegend)??null),o.subscribe()}this.pendingSeries=[]},oe.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",Z((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));u(this,"getValueTranslator",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.unwrapValue(o,i)}));u(this,"getValueParser",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.wrapValue(o,e,i)}));u(this,"getRangeParser",Z((e,t)=>i=>{let[o,n]=i;const r=this.getValueParser(e,t);return o=r(o),n=r(n),[o,n]}));u(this,"getAxisRangeParser",Z((e,t)=>i=>{const o=F.getSourceForAxis(e,i);return o!=null?this.getRangeParser(o.columnType,t):n=>n}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.dh=e,this.chartUtils=new F(e),this.figure=t,this.settings=i,this.theme=o,this.data=[];const n={data:{},layout:this.chartUtils.makeDefaultLayout(o)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:n},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=F.getAllAxes(this.figure),i=[];for(let r=0;r<e.length;r+=1){const a=e[r];for(let c=0;c<a.series.length;c+=1){const l=a.series[c];i.push(l.name),this.addSeries(l,t,a.showLegend)}}const n=[...this.seriesDataMap.keys()].filter(r=>i.indexOf(r)<0);for(let r=0;r<n.length;r+=1){const a=n[r];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const{dh:o}=this,n=F.groupArray(t,"type"),r=this.chartUtils.makeSeriesDataFromSeries(e,n,F.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,r),this.data=[...this.seriesDataMap.values()],e.plotStyle===o.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===o.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=F.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===o.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:c}=a;for(let l=0;l<c.length;l+=1)this.filterColumnMap.set(c[l].name,c[l]);this.oneClicks.push(a)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){D.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;this.figure.addEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){const{dh:e}=this;this.figure.removeEventListener(e.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(e.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(e.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(e.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(e.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){D.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){D.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){D.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){D.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;D.debug2("handleFigureUpdated",i);for(let n=0;n<i.length;n+=1){const r=i[n];D.debug2("handleFigureUpdated updating series",r.name);const{sources:a}=r;for(let c=0;c<a.length;c+=1){const l=a[c],{columnType:h,type:p}=l,g=this.getValueTranslator(h,this.formatter),m=t.getArray(r,p,g);this.setDataArrayForSeries(r,p,m)}this.seriesToProcess.delete(r.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(r)}const{data:o}=this;this.fireUpdate(o)}handleRequestFailed(e){D.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){D.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){D.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;D.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var o;super.setTitle(e);const t=((o=(e??"").match(/<br>/g))==null?void 0:o.length)??0,i=F.DEFAULT_MARGIN.t+t*F.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=F.DEFAULT_TITLE_PADDING.t+t*F.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{D.debug(`Assigning ${i}`,this.layout[i],t);const o=this.layout[i];o!=null?Object.assign(o,t):D.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:o,plotStyle:n}=e,r=this.seriesDataMap.get(o),a=this.chartUtils.getPlotlyProperty(n,t);r&&ue(r,a,i)}cleanSeries(e){const{dh:t}=this,{name:i,plotStyle:o}=e,n=this.seriesDataMap.get(i);if(n!=null){if(o===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:r,xHigh:a}=n;if(r&&a&&r.length===a.length){const c=[];for(let l=0;l<r.length;l+=1)c.push(a[l]-r[l]);n.width=c}}else if(o===t.plot.SeriesPlotStyle.LINE){const{x:r,xLow:a,xHigh:c,y:l,yLow:h,yHigh:p}=n;a&&c&&a!==r&&(n.error_x=F.getPlotlyErrorBars(r,a,c)),h&&p&&h!==l&&(n.error_y=F.getPlotlyErrorBars(l,h,p))}else if(o===t.plot.SeriesPlotStyle.TREEMAP){const{ids:r,labels:a}=n;r!==void 0&&a===void 0&&(n.labels=r)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){D.warn("Trying to set a filter, but no one click!");return}D.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:o}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(r=>{const a=e.get(r);this.lastFilter.get(r)!==a&&o.find(c=>c.name===r)!=null&&i.setValueForColumn(r,a)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let J=oe;u(J,"ADD_SERIES_DEBOUNCE",50);const ce=J;class ie{static async makeModelFromSettings(s,e,t,i=I){const o=await ie.makeFigureFromSettings(s,e,t);return new ce(s,o,e,i)}static async makeFigureFromSettings(s,e,t){const i=await t.copy();return i.applyCustomColumns(t.customColumns),i.applyFilter(t.filter),i.applySort(t.sort),s.plot.Figure.create(new F(s).makeFigureSettings(e,i))}static async makeModel(s,e,t,i=I){return new ce(s,t,e,i)}}const Xe=ie;const Y=ee.module("EmbedChart.App");async function ze(f,s,e){Y.info(`Fetching figure ${e}...`);const t={name:e,type:f.VariableType.FIGURE};return s.getObject(t)}function Qe(){const[f,s]=$.useState(),[e,t]=$.useState(),[i,o]=$.useState(!0),n=$.useMemo(()=>new URLSearchParams(window.location.search),[]),r=De(),a=Fe();$.useEffect(function(){async function h(){try{const p=n.get("name");if(p==null)throw new Error("No name param provided");Y.debug("Loading figure",p,"...");const g=await ze(a,r,p);Y.debug("Creating model...");const m=await Xe.makeModel(a,void 0,g);s(m),Y.debug("Figure successfully loaded!")}catch(p){Y.error("Unable to load figure",p),t(`${p}`)}o(!1)}h()},[a,r,n]);const c=f!=null;return W.jsxs("div",{className:"App",children:[c&&W.jsx(Be,{model:f}),!c&&W.jsx(Se,{isLoaded:c,isLoading:i,errorMessage:e??null}),W.jsx(be,{})]})}export{Qe as default};
|
|
2
|
+
//# sourceMappingURL=App-40b9035e.js.map
|