3 lines
8.7 KiB
JavaScript
3 lines
8.7 KiB
JavaScript
"use strict";(self.webpackChunktradingview=self.webpackChunktradingview||[]).push([[4674],{15511:(e,t,i)=>{i.d(t,{LineToolWithRelativePriceCoordinate:()=>m,getNoDataPosition:()=>P,getSeriesPosition:()=>x,positionToCoordinate:()=>h});var n,r,o=i(50151),s=i(8025),a=i(10568);function l(e,t,i){const n=e.barFunction();switch(e.style()){case 3:case 10:case 2:case 14:case 15:return n(t.value);default:return t.value[-1===i?3:2]}}function c(e){return e>=0?1:-1}function u(e,t){return-1===c(e)!==t?-1:1}function h(e,t,i,n){const r=Math.min(t,Math.max(0,1===n?i:t-i));return i-n*Math.abs(r*e/100)}function d(e,t,i){const n=e.index();return null===n?null:{index:n,price:t.coordinateToPrice(t.height()/2,i)}}function p(e,t){const i=e.data().bars(),n=i.first(),r=i.last();if(null===n||null===r)return null;let o;const a=t.index();if(null===a){if(void 0===t.time)return null;const e=t.time(),a=n.value[0],l=r.value[0];if(e<a-86400||e>l)return null;o=i.searchByTime(e,s.PlotRowSearchMode.NearestRight,4)}else o=i.search(a);return null===o?null:{index:o.index,price:l(e,o,c(t.position()))}}function P(e,t,i,n){const r=d(e,t,n);if(null===r)return null;const o=u(e.position(),t.isInverted());return{index:r.index,price:r.price,poleStartY:t.height(),visualDirection:1,positionPointDirection:o,startsOnSeriesData:!1,priceCoordinate:t.priceToCoordinate(r.price,n),indexCoordinate:i.indexToCoordinate(r.index)}}function x(e,t,i=!0){const n=p(e,t),r=e.priceScale(),s=e.model().timeScale(),a=(0,o.ensureNotNull)(e.firstValue());if(null===n)return P(t,r,s,a);let l=0;const c=e.properties().childs(),h=r.priceToCoordinate(n.price,a),d=u(t.position(),r.isInverted());if(i)switch(e.style()){case 16:l=1===d?c.hlcAreaStyle.childs().highLineWidth.value()/2:c.hlcAreaStyle.childs().lowLineWidth.value()/2;break;case 3:l=c.areaStyle.childs().linewidth.value()/2;break;case 2:l=c.lineStyle.childs().linewidth.value()/2;break;case 14:l=c.lineWithMarkersStyle.childs().linewidth.value()/2;break;case 15:l=c.steplineStyle.childs().linewidth.value()/2;break;case 10:const e=Math.abs(100-c.baselineStyle.childs().baseLevelPercentage.value());l=r.height()*e/100>h?c.baselineStyle.childs().topLineWidth.value()/2:c.baselineStyle.childs().bottomLineWidth.value()/2;break;case 1:case 9:case 8:case 12:case 4:case 7:l=3;break;case 0:l=c.barStyle.childs().thinBars.value()?3:Math.max(3,.25*s.barSpacing());break;case 11:l=c.rangeStyle.childs().thinBars.value()?3:Math.max(3,.25*s.barSpacing());break;case 5:l=Math.max(4,.25*s.barSpacing());break;case 6:l=Math.max(5,.25*s.barSpacing())}const x=h-d*l;return{index:n.index,price:n.price,poleStartY:x,visualDirection:d,positionPointDirection:d,startsOnSeriesData:!0,priceCoordinate:h,indexCoordinate:s.indexToCoordinate(n.index)}}!function(e){e[e.Label=0]="Label",e[e.Body=1]="Body"}(n||(n={})),function(e){e[e.OneDaySeconds=86400]="OneDaySeconds"}(r||(r={}));class m extends a.InplaceTextLineDataSource{constructor(){super(...arguments),this._startMovingAnchorY=NaN}priceSource(){return this.ownerSource()}editableTextProperties(){(0,
|
|
o.assert)(!1,"unexpected method call")}addPoint(e,t,i){return super.addPoint(this._updatePositionAndCorrectPoint(e),t,i)}setPoint(e,t,i,n){n?super.setPoint(e,t,i,n):(super.setPoint(e,this._updatePositionAndCorrectPoint(t,!this.isPhantom()&&!this._allowChangeAnchorHorizontally()),i),this._syncPosition())}setPointAndChangeIndex(e,t,i){super.setPoint(e,this._updatePositionAndCorrectPoint(t),i),this._syncPosition()}startMoving(e,t,i,n){n||(this._startMovingAnchorY=(0,o.ensureNotNull)(this._anchorYCoordinate())),super.startMoving(e,t,i)}move(e,t,i,n){const r=(0,o.ensureDefined)((0,o.ensureNotNull)(this.startMovingPoint()).logical),s=(0,o.ensureDefined)(e.logical);if(!n&&0===t){const e=this._points[0],t=s.index-r.index,i=(0,o.ensureNotNull)(this.priceScale()),n=(0,o.ensure)(this.ownerSource()?.firstValue()),a=i.priceToCoordinate(s.price,n)-i.priceToCoordinate(r.price,n),l=this._startMovingAnchorY+a,c=i.coordinateToPrice(l,n);this._updatePositionAndCorrectPoint({index:e.index+t,price:c})}super.move(e,t,i),n||this._syncPosition()}_allowChangeAnchorHorizontally(){return!1}_updatePositionAndCorrectPoint(e,t=!1){t&&(e.index=this._points[0].index);const i=this.priceSource();if(null===i)return e;const n=i.priceScale(),r=i.firstValue();if(null===n||n.isEmpty()||null===r)return e;const o=n.height();let s=o/2,a=e.price>=n.coordinateToPrice(s,r)?1:-1;const c=this._model.mainSeries();if(i===c){const t=c.data().search(this._baseSeriesIndexForPoint(e));if(null!==t){const i=l(c,t,-1),o=l(c,t,1);a=e.price>=i?1:-1,s=n.priceToCoordinate(1===a?o:i,r),e.price=1===a?Math.max(o,e.price):e.price}}const u=1===(-1===a!==n.isInverted()?-1:1)?s:o-s,h=n.priceToCoordinate(e.price,r),d=Math.min(o,Math.abs(h-s)),p=Math.max(0,Math.min(100,100*d/u))*a;return this.properties().childs().position.setValue(p),e}_baseSeriesIndexForPoint(e){return e.index}_syncPosition(){const e=this.linkKey().value();null!==e&&this._syncLineStyleChanges(e,{position:this.properties().childs().position.value()})}_anchorYCoordinate(){const e=this.priceSource();if(null===e)return null;const t=e.priceScale(),i=e.firstValue();if(null===t||t.isEmpty()||null===i)return null;const n=this._model.mainSeries(),r=this.customEvent();if(null===r)return null;let o=null;if(e===n&&(o=p(n,r)),null===o&&(o=d(r,t,i)),null===o)return null;const s=r.position(),a=t.priceToCoordinate(o.price,i);return h(s,t.height(),a,u(s,t.isInverted()))}}},28820:(e,t,i)=>{i.r(t),i.d(t,{LineToolSignpost:()=>d});var n=i(19625),r=i(32679),o=i(12988),s=i(29875),a=i(73305),l=i(15511);class c extends o.Property{constructor(e){super(),this._source=e,e.pointAdded().subscribe(this,(()=>this.fireChanged())),e.pointChanged().subscribe(this,(()=>this.fireChanged()))}value(){const e=this._source.properties().childs().position.value();return parseFloat(e.toFixed(2))}setValue(e){this._source.properties().childs().position.setValue(e),this._source.model().updateSource(this._source),this.fireChanged(),this._source.syncMultichartState({pricesChanged:!1,indexesChanged:!1})}}var u=i(20834)
|
|
;class h extends u.LineDataSourcePointIndexProperty{constructor(e,t){super(e,t),this._source=e}_setPointImpl(e){this._source.setPointAndChangeIndex(this._pointIndex,e)}}class d extends l.LineToolWithRelativePriceCoordinate{constructor(e,t=d.createProperties(e.backgroundTheme().spawnOwnership()),r,s){super(e,t,r,s),this._textColorProperty=new o.Property("transparent"),this._setTextColorByTheme=e=>{this._textColorProperty.setValue(e?(0,n.getHexColorByName)("color-cold-gray-200"):(0,n.getHexColorByName)("color-cold-gray-900"))},e.dark().subscribe(this._setTextColorByTheme,{callWithLast:!0}),Promise.all([i.e(2870),i.e(2211),i.e(1583)]).then(i.bind(i,93751)).then((t=>{this._setPaneViews([new t.SignpostPaneView(this,e,this._openTextEditor.bind(this),this._closeTextEditor.bind(this),this.onSelectionChange.bind(this))])}))}destroy(){this._model.dark().unsubscribe(this._setTextColorByTheme),super.destroy()}pointsCount(){return 1}name(){return"Signpost"}customEvent(){return{index:()=>this.points()[0]?.index??null,position:()=>this.properties().childs().position.value()}}showInObjectTree(){return!this.isPhantom()&&super.showInObjectTree()}isPhantom(){return this._model.isPhantomLine(this)}clonePositionOffset(){return{barOffset:1,xCoordOffset:0,yCoordOffset:0}}template(){const e=super.template(),t=this.properties().childs();return e.text=t.text.value(),e.position=t.position.value(),e}shouldBeRemovedOnDeselect(){const e=this._properties.childs();if(e.showImage.value())return!1;return""===e.text.value().trim()}editableTextProperties(){return{text:this.properties().childs().text,textColor:this._textColorProperty}}activateEditingOnCreation(){return!0}static createProperties(e,t){const i=new r.DefaultProperty({defaultName:"linetoolsignpost",state:t,theme:e});return this._configureProperties(i),i}_createPointProperty(e){super._createPointProperty(e);const t=this._pointsProperty.childs().points[e];t.removeProperty("price"),t.removeProperty("bar"),t.addChild("price",new c(this)),t.addChild("bar",new h(this,0))}_applyTemplateImpl(e){super._applyTemplateImpl(e),this.properties().childs().text.setValue(e.text),this.properties().childs().position.setValue(e.position)}_normalizePoint(e,t){return super._normalizePointWithoutOffset(e)??super._normalizePoint(e,t)}_getPropertyDefinitionsViewModelClass(){return Promise.all([i.e(3401),i.e(3889),i.e(8009),i.e(6204),i.e(1963),i.e(8537)]).then(i.bind(i,91051)).then((e=>e.SignpostDefinitionsViewModel))}static _configureProperties(e){s.LineDataSource._configureProperties(e),e.hasChild("text")||e.addChild("text",new o.Property("")),e.hasChild("position")||e.addChild("position",new o.Property(50)),e.addExcludedKey("text",1),e.addExcludedKey("position",1),e.addChild("backgroundsColors",new a.LineToolColorsProperty([e.childs().plateColor]))}}d.supportPhantomMode=!0}}]); |