2 lines
5.1 KiB
JavaScript
2 lines
5.1 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[3314],{15399:(e,t,s)=>{s.d(t,{LevelsProperty:()=>_});var i=s(90054),n=s(16738),r=s(37265),o=s(32679),l=s(35039);const a={prefixes:[""],range:[0,0],names:["coeff","color","visible","linestyle","linewidth"],typecheck:{pack:()=>Object(),unpack:()=>[]}};function c(e,t,s,i){return i.push(s[t]),i}function u(e,t,s,i){return i[t]=s[e],i}function h(){return[]}function p(){return{}}function d(e,t,s){return s.prefixes.forEach((i=>{const n=i+"level";for(let i=s.range[0];i<=s.range[1];i++)if(e[n+i]&&(0,r.isSameType)(e[n+i],t.typecheck())){let r=t.tpl();s.names.forEach(((s,o)=>{r=t.fill(""+o,s,e[n+i],r)})),e[n+i]=r}})),e}function f(e,t,s){return s(e,{tpl:p,fill:u,typecheck:t.typecheck.unpack},t)}class _ extends o.DefaultProperty{constructor(e){const{levelsIterator:t=d,map:s={},...i}=e,n={...a,...s};i.state&&(i.state=f(i.state,n,t)),super(i),this._map=n,this._levelsIterator=t}state(e,t,s){const i=super.state(e,t);return s?i:(n=i,r=this._map,(0,this._levelsIterator)(n,{tpl:h,fill:c,typecheck:r.typecheck.pack},r));var n,r}preferences(){return(0,o.extractState)(this.state(this._excludedDefaultsKeys,void 0,!0),this._allDefaultsKeys)}applyTemplate(e,t){this.mergeAndFire((0,o.extractState)((0,n.default)((0,i.default)(t),f(e,this._map,this._levelsIterator)),this._allStateKeys,this._excludedTemplateKeys))}saveDefaults(){this._useUserPreferences&&(0,l.saveDefaults)(this._defaultName,this.preferences())}clone(){return new _(this._options())}merge(e,t){return super.merge(this._map?f(e,this._map,this._levelsIterator):e,t)}_options(){return{...super._options(),map:{...this._map},levelsIterator:this._levelsIterator}}}},90882:(e,t,s)=>{s.d(t,{LineToolFibWedgeBase:()=>l});var i=s(50151),n=s(86441),r=s(10568),o=s(64147);class l extends r.InplaceTextLineDataSource{constructor(){super(...arguments),this._hasEditableCoordinates=new o.WatchedValue(!1)}pointsCount(){return 3}setPoint(e,t){if(super.setPoint(e,t),!this._recursiveGuard)try{if(this._recursiveGuard=!0,2===e){const e=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[0]));let t=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[1]));const s=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[2])).subtract(e).length();let r=t.subtract(e);r.length()<=0&&(r=new n.Point(1,0)),t=e.add(r.normalized().scaled(s));const o=(0,i.ensureNotNull)(this.screenPointToPoint(t)),l=this._pointsProperty.childs().points[1];l.childs().price.setValue(o.price),l.childs().bar.setValue(o.index)}else{const e=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[0])),t=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let s=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[2]));const r=t.subtract(e).length();let o=s.subtract(e);o.length()<=0&&(o=new n.Point(1,0)),s=e.add(o.normalized().scaled(r));const l=(0,i.ensureNotNull)(this.screenPointToPoint(s)),a=this._pointsProperty.childs().points[2];a.childs().price.setValue(l.price),a.childs().bar.setValue(l.index)}}finally{this._recursiveGuard=!1}}
|
|
addPoint(e){if(2===this._points.length){const t=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[0])),s=(0,i.ensureNotNull)(this.pointToScreenPoint(this._points[1]));let n=(0,i.ensureNotNull)(this.pointToScreenPoint(e));const r=s.subtract(t).length(),o=n.subtract(t).normalized();n=t.add(o.scaled(r));const l=(0,i.ensureNotNull)(this.ownerSource()),a=(0,i.ensureNotNull)(l.firstValue()),c=(0,i.ensureNotNull)(this.priceScale()).coordinateToPrice(n.y,a);e={index:Math.round(this._model.timeScale().coordinateToIndex(n.x)),price:c}}return super.addPoint(e)}editableTextProperties(){(0,i.assert)(!1,"unexpected method call")}}},23591:(e,t,s)=>{s.r(t),s.d(t,{LineToolFibWedge:()=>p});var i=s(50151),n=s(11542),r=s(45126),o=s(90882),l=s(15399),a=s(73305),c=s(85719);const u=new r.TranslatedString("erase level line",n.t(null,void 0,s(77114)));var h;!function(e){e[e.LevelsCount=11]="LevelsCount"}(h||(h={}));class p extends o.LineToolFibWedgeBase{constructor(e,t,i,n){super(e,t??p.createProperties(e.backgroundTheme().spawnOwnership()),i,n),Promise.all([s.e(2870),s.e(2211),s.e(1583)]).then(s.bind(s,84417)).then((e=>{this._setPaneViews([new e.FibWedgePaneView(this,this._model)])}))}levelsCount(){return 11}isSynchronizable(){return!1}name(){return"Fib Wedge"}processErase(e,t){const s=(0,i.ensureDefined)(this.properties().child(`level${t}`));e.setProperty(s.childs().visible,!1,u,c.lineToolsDoNotAffectChartInvalidation)}static createProperties(e,t){const s=new l.LevelsProperty({defaultName:"linetoolfibwedge",state:t,map:{range:[1,11]},theme:e});return this._configureProperties(s),s}async _getPropertyDefinitionsViewModelClass(){return(await Promise.all([s.e(3401),s.e(3889),s.e(8009),s.e(6204),s.e(1963),s.e(8537)]).then(s.bind(s,49267))).FibWedgeDefinitionsViewModel}static _configureProperties(e){super._configureProperties(e);const t=[e.childs().trendline.childs().linewidth],s=[e.childs().trendline.childs().color];for(let n=1;n<=11;n++){const r=(0,i.ensureDefined)(e.child(`level${n}`));t.push(r.childs().linewidth),s.push(r.childs().color)}e.addChild("linesColors",new a.LineToolColorsProperty(s)),e.addChild("linesWidths",new a.LineToolWidthsProperty(t))}}}}]); |