Files
ai/charting_library/bundles/line-tool-trend-line.9941c9f06153882d0f0c.js

4 lines
10 KiB
JavaScript

"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[4409,6800,7860,7715,8042],{55510:(e,t,r)=>{r.r(t),r.d(t,{LineToolArrow:()=>l});var i=r(47004),n=r(90450),s=r(68459);const o={...n.nonThemedFactoryDefaults,rightEnd:s.LineEnd.Arrow};class a extends n.LineToolTrendLinePropertiesImpl{static create(e,t,r){return n.LineToolTrendLinePropertiesImpl._createWithDefaults("linetoolarrow",e,o,n.themedFactoryDefaults,t,r)}}class l extends i.LineToolTrendLine{constructor(e,t,r,i){super(e,t??l.createProperties(e.backgroundTheme().spawnOwnership()),r,i)}name(){return"Arrow"}static createProperties(e,t){const r=a.create(e,t);return this._configureProperties(r),r}}},70005:(e,t,r)=>{r.r(t),r.d(t,{LineToolExtended:()=>a});var i=r(47004),n=r(90450);const s={...n.nonThemedFactoryDefaults,extendLeft:!0,extendRight:!0};class o extends n.LineToolTrendLinePropertiesImpl{static create(e,t,r){return n.LineToolTrendLinePropertiesImpl._createWithDefaults("linetoolextended",e,s,n.themedFactoryDefaults,t,r)}}class a extends i.LineToolTrendLine{constructor(e,t,r,i){super(e,t??a.createProperties(e.backgroundTheme().spawnOwnership()),r,i)}name(){return"Extended Line"}static createProperties(e,t){const r=o.create(e,t);return this._configureProperties(r),r}}},43825:(e,t,r)=>{r.r(t),r.d(t,{LineToolInfoLine:()=>d,LineToolInfoLineConst:()=>l});var i=r(47004),n=r(90450),s=r(45124);const o={...n.nonThemedFactoryDefaults,statsPosition:s.StatsPosition.Center,alwaysShowStats:!0,showPriceRange:!0,showPercentPriceRange:!0,showPipsPriceRange:!0,showBarsRange:!0,showDateTimeRange:!0,showDistance:!0,showAngle:!0};class a extends n.LineToolTrendLinePropertiesImpl{static create(e,t,r){return n.LineToolTrendLinePropertiesImpl._createWithDefaults("linetoolinfoline",e,o,n.themedFactoryDefaults,t,r)}}var l;!function(e){e.ConstructorName="LineToolInfoLine",e.Name="Info Line"}(l||(l={}));class d extends i.LineToolTrendLine{constructor(e,t,r,i){super(e,t??d.createProperties(e.backgroundTheme().spawnOwnership()),r,i)}pointsCount(){return 2}name(){return"Info Line"}static createProperties(e,t){const r=a.create(e,t);return this._configureProperties(r),r}}},89923:(e,t,r)=>{r.r(t),r.d(t,{LineToolRay:()=>a});var i=r(47004),n=r(90450);const s={...n.nonThemedFactoryDefaults,extendRight:!0};class o extends n.LineToolTrendLinePropertiesImpl{static create(e,t,r){return n.LineToolTrendLinePropertiesImpl._createWithDefaults("linetoolray",e,s,n.themedFactoryDefaults,t,r)}}class a extends i.LineToolTrendLine{constructor(e,t,r,i){super(e,t??a.createProperties(e.backgroundTheme().spawnOwnership()),r,i)}name(){return"Ray"}static createProperties(e,t){const r=o.create(e,t);return this._configureProperties(r),r}}},90450:(e,t,r)=>{r.d(t,{LineToolTrendLinePropertiesImpl:()=>y,nonThemedFactoryDefaults:()=>P,themedFactoryDefaults:()=>m});var i=r(11284),n=r(85842),s=r(25432),o=r(47097),a=r(95385),l=r(68459),d=r(45124),h=r(62565),c=r(88483),u=r(5829),p=r(93445),_=r(86371),T=r(17567);const g=(0,i.getHexColorByName)("color-tv-blue-500"),P={intervalsVisibilities:{
...c.intervalsVisibilitiesDefaults},linewidth:u.DEFAULT_LINE_TOOL_LINE_WIDTH,linestyle:h.LineStyle.Solid,extendLeft:!1,extendRight:!1,leftEnd:l.LineEnd.Normal,rightEnd:l.LineEnd.Normal,horzLabelsAlign:a.HorizontalAlign.Center,vertLabelsAlign:a.VerticalAlign.Bottom,fontsize:14,bold:!1,italic:!1,alwaysShowStats:!1,showMiddlePoint:!1,showPriceLabels:!1,showPriceRange:!1,showPercentPriceRange:!1,showPipsPriceRange:!1,showBarsRange:!1,showDateTimeRange:!1,showDistance:!1,showAngle:!1,statsPosition:d.StatsPosition.Right},x={linecolor:g,textcolor:g},m=new Map([[o.StdTheme.Light,x],[o.StdTheme.Dark,x]]),w=(0,p.extractThemedColors)((0,n.ensureDefined)(m.get(o.StdTheme.Light)),(0,n.ensureDefined)(m.get(o.StdTheme.Dark))),L=(0,p.extractAllPropertiesKeys)((0,n.ensureDefined)(m.get(o.StdTheme.Light))),f=(0,p.extractAllPropertiesKeys)(P),v=[...L,...f,"text"],b=[...new Set([...v,...s.commonLineToolPropertiesStateKeys])];class y extends _.LineDataSourceProperty{constructor(e){super(e),this.hasChild("text")||this.addProperty("text","")}static create(e,t,r){return y._createWithDefaults("linetooltrendline",e,P,m,t,r)}static _createWithDefaults(e,t,r,i,n,s){return new this({defaultName:e,factoryDefaultsSupplier:()=>(0,T.factoryDefaultsForCurrentTheme)(r,i),nonThemedDefaultsKeys:f,themedDefaultsKeys:L,allStateKeys:b,themedColors:w,templateKeys:v,replaceThemedColorsOnThemeChange:!0,state:n,theme:t,useUserPreferences:s})}}},47004:(e,t,r)=>{r.r(t),r.d(t,{Consts:()=>L,LineToolTrendLine:()=>v});var i=r(85842),n=r(33993),s=r(63212),o=r(91569),a=r(57415),l=r(91069),d=r(78792),h=r(61208),c=r(16965),u=r(79083),p=r(45124),_=r(71367),T=r(6353),g=r(14491),P=r(83077),x=r(35428),m=r(7955);class w extends x.TrendToolWithStatsPaneView{constructor(e,t,r,i,n,s){super(e,t,i,n,s),this._trendRenderer=new T.TrendLineRenderer,this._pane=r,this._labelRenderer=new c.LineToolTextRenderer(void 0,new P.HitTestResult(P.HitTarget.MovePoint,(0,m.inplaceEditHandlers)(this._tryActivateEditMode.bind(this,null)))),this._source.setAdditionalCursorData((()=>({color:this._source.editableTextStyle().cursorColor,rotationPoint:this._labelRenderer.rotation()??void 0,...this._labelRenderer.getTextInfo()})),this._labelRenderer.positionToCoordinate.bind(this._labelRenderer))}_getPointsForStats(){return[this._points[0],(0,i.ensureNotNull)(this._middlePoint),this._points[1]]}_updateImpl(e){this._renderer.clear(),this._invalidated=!1;const t=this._getOwnerSource();if(!t||this._pane&&!this._pane.sourcesByGroup().hasLineSource(this._source))return;const r=t.priceScale(),i=this._model.timeScale();if(!r||r.isEmpty()||i.isEmpty())return;const n=this._model.timeScale().visibleBarsStrictRange();if(null===n)return;const s=this._source.points();if(s.length<2)return;const o=s[0],c=s[1],T=this._source.properties().childs();if(o.index<n.firstBar()&&c.index<n.firstBar()&&!T.extendLeft.value()&&!T.extendRight.value())return;if(super._updateImpl(e),this._points.length<2)return
;T.showPriceRange.value()||T.showPercentPriceRange.value()||T.showPipsPriceRange.value()||T.showBarsRange.value()||T.showDateTimeRange.value()||T.showDistance.value()||T.showAngle.value()||(this._label=null,this._labelData&&(this._labelData.text=""));const x=this._points[0],m=this._points[1],{mediaSize:{width:w,height:L}}=e;let f;const v=T.text.value(),b=this._isTextEditMode(),y=this._placeHolderMode(!0);if(v||y||b){const e=x.x<m.x?x:m,t=e===x?m:x,r=T.vertLabelsAlign.value(),i=T.horzLabelsAlign.value();let n;n="left"===i?e.clone():"right"===i?t.clone():new a.Point((x.x+m.x)/2,(x.y+m.y)/2);const s=Math.atan((t.y-e.y)/(t.x-e.x));this._labelRenderer.setData({points:[n],text:this._textData(),color:this._textColor(),vertAlign:r,horzAlign:i,font:g.CHART_FONT_FAMILY,offsetX:0,offsetY:0,bold:T.bold.value(),italic:T.italic.value(),fontsize:T.fontsize.value(),forceTextAlign:!0,angle:s,decorator:y?u.PlusTextRendererDecorator.instance():void 0,...this._inplaceTextHighlight()}),this._labelRenderer.setCursorType(this._textCursorType()),this._renderer.append(this._labelRenderer),this._needLabelExclusionPath(this._labelRenderer)&&(f=(0,h.getTextBoundaries)(this._labelRenderer,w,L)??void 0),this._labelRenderer.isOutOfScreen(w,L)?this.closeTextEditor():this._updateInplaceText(this._labelRenderer.getTextInfo())}const R=T.linecolor.value(),S={points:this._points,color:R,linewidth:T.linewidth.value(),linestyle:T.linestyle.value(),extendleft:T.extendLeft.value(),extendright:T.extendRight.value(),leftend:T.leftEnd.value(),rightend:T.rightEnd.value(),excludeBoundaries:f?[f]:void 0};this._trendRenderer.setData(S),this._renderer.insert(this._trendRenderer,0);const D=(0,a.box)(new a.Point(0,0),new a.Point(w,L));let A=!1;T.statsPosition.value()===p.StatsPosition.Auto&&(A=(0,a.equalPoints)(x,m)?!(0,l.pointInBox)(x,D):null===(0,d.intersectLineSegmentAndBox)((0,a.lineSegment)(x,m),D));if(((this.isHoveredSource()||this.isSelectedSource())&&this.isEditMode()||T.alwaysShowStats.value())&&!A&&2===this._points.length&&this._renderer.append(this._updateAndReturnStatsRenderer(e)),this._middlePoint&&!b){const e=(this.isHoveredSource()||this.isSelectedSource())&&T.showMiddlePoint.value();this._renderer.append(new _.SelectionRenderer({points:[{point:this._middlePoint}],bgColors:this._lineAnchorColors([this._middlePoint]),color:R,visible:e&&this.areAnchorsVisible(),hittestResult:P.HitTarget.Regular,barSpacing:0}))}this.addAnchors(this._renderer),S.points.length>=2&&this._addAlertRenderer(this._renderer,S.points)}}var L,f=r(90450);!function(e){e[e.PointsCount=2]="PointsCount",e.Name="Trend Line"}(L||(L={}));class v extends s.InplaceTextLineDataSource{constructor(e,t,r,i){super(e,t??v.createProperties(e.backgroundTheme().spawnOwnership()),r,i)}destroy(){super.destroy()}pointsCount(){return 2}name(){return"Trend Line"}canHasAlert(){return!0}showPriceLabels(){return this._properties.childs().showPriceLabels.value()}createPriceAxisView(e){return new o.LineToolPriceAxisView(this,{pointIndex:e,
backgroundPropertyGetter:()=>this.showPriceLabels()?this._properties.childs().linecolor.value():null})}isForcedDrawPriceAxisLabel(){return this.showPriceLabels()}template(){const e=super.template();return e.text=this.properties().childs().text.value(),e}editableTextProperties(){const e=this.properties().childs();return{text:e.text,textColor:e.textcolor}}supportsTargetSignature(){return!1}isMultiPaneAvailable(){return this.supportsTargetSignature()}isMultiPaneEnabled(){return null!==this.targetSignature().value()}snapTo45DegreesAvailable(){return!0}static createProperties(e,t,r){return v._createPropertiesImpl(e,t,r)}_getPaneViews(e){return null!==this.targetSignature().value()||this._paneViews.has(e)||e&&!e.hasDataSource(this)||this._paneViews.set(e,[new w(this,this._model,e??null,this._openTextEditor.bind(this),this._closeTextEditor.bind(this))]),super._getPaneViews(e)}_getAlertPlots(){const e=this._linePointsToAlertPlot(this._points,null,this._properties.childs().extendLeft.value(),this._properties.childs().extendRight.value());return null===e?[]:[e]}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([r.e(1982),r.e(7686),r.e(2428),r.e(3920),r.e(9328)]).then(r.bind(r,44252))).TrendLineDefinitionsViewModel}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text||"")}_createSignatureSourcePaneViews(e){return[new w(this,this._model,null,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),e)]}static _createPropertiesImpl(e,t,r){const i=f.LineToolTrendLinePropertiesImpl.create(e,t,r);return this._configureProperties(i),i}static _configureProperties(e){super._configureProperties(e),e.addChild("textsColors",new n.LineToolColorsProperty([(0,i.ensureDefined)(e.child("textcolor"))]))}}}}]);