st-comp 0.0.121 → 0.0.123

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/es/KlineNew.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";const t=require("vue"),B=require("./index.esm-94a95a2a.cjs"),L=require("./_plugin-vue_export-helper-f246444f.cjs"),z=require("./index-dc273ea2.cjs");require("./base-ec05f348.cjs");require("./el-tag-3b03d13e.cjs");const R=require("./el-select-928f8c19.cjs");require("./el-scrollbar-d1c3e7f7.cjs");require("./el-popper-f62316cd.cjs");const N=require("echarts");require("./use-form-common-props-1b84d8f4.cjs");require("./index-80a2b137.cjs");require("./castArray-a45823fe.cjs");require("./index-e1e83173.cjs");require("./event-61f49698.cjs");require("./scroll-41224831.cjs");require("./debounce-b2ff12bd.cjs");function $(_){const v=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(_){for(const A in _)if(A!=="default"){const h=Object.getOwnPropertyDescriptor(_,A);Object.defineProperty(v,A,h.get?h:{enumerable:!0,get:()=>_[A]})}}return v.default=_,Object.freeze(v)}const E=$(N),M=t.defineComponent({__name:"index",setup(_,{expose:v}){let A=!1,h=!0,y=[];const S=(f,u)=>f.length>u?f.slice(f.length-u):f;return v({initTalib:async()=>{if(!A)A=!0,await B.init("./talib.wasm"),h=!1,y.forEach(f=>{f()});else if(h)return new Promise(f=>{y.push(f)})},handleKeyDown:(f,u)=>{let{startValue:o,endValue:d,maxIndex:m}=u;if(f.code==="ArrowLeft"){if(o===0)return;o=o-1,d=d-1}else if(f.code==="ArrowRight"){if(d===m)return;o=o+1,d=d+1}else if(f.code==="ArrowUp"){if(d-o<5)return;const p=Math.floor((d-o)/2)+1;o=o+p,d-o<5&&(o=d-4)}else if(f.code==="ArrowDown"){const p=Math.min(500,d-o);o=o-p-1}return{startValue:o,endValue:d}},getDataZoomInfoByTime:f=>{const{showStartTime:u,showEndTime:o,xAxisData:d,maxShowDays:m}=f;let p=-1,e=-1,i={};return d.forEach((a,l)=>{const r=a.split(" ")[0];i[r]=i[r]||0,i[r]+=1,new Date(a)>=new Date(u)&&p===-1&&(p=l),new Date(a)<=new Date(o)&&(e=l)}),{startValue:p,endValue:e,maxValueSpan:Math.max(...Object.values(i))*m}},formatDataBySlide:f=>{const{originDrawData:u,addData:o,startTime:d,endTime:m}=f,{mainIndicator:p,mainIndicatorList:e,subIndicator:i,subIndicatorList:a,config:l,timeRange:r}=f,{loadAddCount:D,preLoadCount:F}=l;let x=[],b=[],V=[],w=[];d&&m?(x=o.filter(s=>new Date(s[0])>=new Date(d)&&new Date(s[0])<=new Date(m)),w=[...o]):m?(x=[...o.filter((s,n)=>n>=o.length-D&&new Date(r[0])<=new Date(s[0])&&new Date(s[0])<=new Date(r[1])),...u.originData],w=[...o,...u.originData]):d&&(x=[...u.originData,...o.filter((s,n)=>n>=F&&new Date(r[0])<=new Date(s[0])&&new Date(s[0])<=new Date(r[1]))],w=x),x.forEach((s,n)=>{b.push([s[1],s[4],s[3],s[2],n===0?0:x[n-1][4],s[6]]),V.push(s[0])});let c=[],g=[];const I={time:[],open:[],close:[],high:[],low:[],originData:w};let C=null,T=null;return w.forEach((s,n)=>{I.time.push(s[0]),I.open.push(s[1]),I.close.push(s[4]),I.high.push(s[2]),I.low.push(s[3]),s[0]===x[0][0]&&(C=n),s[0]===x[x.length-1][0]&&(T=n+1)}),c=e.find(({value:s})=>s===p).config.map(s=>{const{calculationFn:n}=s,k={time:[],open:[],close:[],high:[],low:[],originData:[]};return{...s,data:n?n(B.talib,I,k).slice(C,T):[]}}),g=a.find(({value:s})=>s===i).config.reduce((s,n)=>{const{source:k,calculationFn:q}=n;return k==="calculation"?[...s,{...n,data:q?q(B.talib,I).slice(C,T):[]}]:s},[]),{originData:x,candlestickData:b,mainIndicatorData:c,subIndicatorData:g,xAxisData:V,startTime:x[0][0],endTime:x[x.length-1][0],length:x.length}},formatDataByCount:f=>{const{originDrawData:u,addData:o,mainIndicator:d,mainIndicatorList:m,subIndicator:p,subIndicatorList:e,config:i}=f;let a={};const{addCount:l,preLoadCount:r}=i,D=[],F=[],x=[],b=[],V=[];let w=[],c=[];const g=o.filter((n,k)=>(D.push(n[0]),F.push(n[1]),x.push(n[4]),b.push(n[2]),V.push(n[3]),w.push(n[0]),c.push([n[1],n[4],n[3],n[2],k===0?0:o[k-1][4],n[6]]),o.length>=l+r-1?k>=r:!0));w=S(w,g.length),c=S(c,g.length);const I={time:D,open:F,close:x,high:b,low:V,originData:o},T=m.find(n=>n.value===d).config.map(n=>({...n,data:S(n.calculationFn?n.calculationFn(B.talib,I,{time:[],open:[],close:[],high:[],low:[],originData:[]}):[],w.length)}));let s=[];return p&&e&&(s=e.find(k=>k.value===p).config.reduce((k,q)=>q.source==="calculation"?[...k,{...q,data:S(q.calculationFn?q.calculationFn(B.talib,I):[],w.length)}]:k,[])),u.length?a={originData:[...g,...u.originData],xAxisData:[...w,...u.xAxisData],candlestickData:[...c,...u.candlestickData],mainIndicatorData:u.mainIndicatorData.map((n,k)=>({...n,data:[...T[k].data,...n.data]})),subIndicatorData:u.subIndicatorData.map((n,k)=>({...n,data:[...s[k].data,...n.data]}))}:a={originData:g,xAxisData:w,candlestickData:c,mainIndicatorData:T,subIndicatorData:s},a.length=a.xAxisData.length,a.startTime=a.xAxisData[0],a.endTime=a.xAxisData[a.length-1],a},fn:()=>{}}),(f,u)=>null}}),j={class:"kline-tips"},P=t.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(_){return(v,A)=>(t.openBlock(),t.createElementBlock("div",j,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(_.data,(h,y)=>(t.openBlock(),t.createElementBlock("div",{key:y,class:"kline-tips-item",style:t.normalizeStyle({color:h.color})},t.toDisplayString(h.label)+" "+t.toDisplayString(h.value),5))),128))]))}});const O=L._export_sfc(P,[["__scopeId","data-v-2a02e841"]]),K={class:"kline-tips"},U=t.defineComponent({__name:"index",props:{drawData:{type:Object,require:!0},activeIndex:{type:Number,require:!0}},setup(_){const{round:v,multiply:A,divide:h,subtract:y,formatValue:S}=z.x,f=_,u=t.computed(()=>{const{drawData:d,activeIndex:m}=f;if(d.candlestickData&&d.candlestickData[m]){const p=d.candlestickData[m],e=[{label:"开",value:v(p[0])},{label:"高",value:v(p[3])},{label:"低",value:v(p[2])},{label:"收",value:v(p[1])}];p[5]!==void 0&&e.push({label:"额",value:S(p[5])});const i=v(A(h(y(p[1],p[4]),Math.abs(p[4])),100));let a;return i>0?a="red":i<0&&(a="green"),e.push({label:"涨跌",value:`${i}%`,color:a}),e}return[]}),o=t.computed(()=>{var p;const{drawData:d,activeIndex:m}=f;return((p=d==null?void 0:d.mainIndicatorData)==null?void 0:p.map(e=>({label:e.key,value:v(e.data[m]),color:e.color})))||[]});return(d,m)=>(t.openBlock(),t.createElementBlock("div",K,[t.createVNode(O,{data:u.value},null,8,["data"]),t.createVNode(O,{data:o.value},null,8,["data"])]))}});const Z=L._export_sfc(U,[["__scopeId","data-v-a1302914"]]),Y={class:"klineSub"},H={class:"klineSub-tips"},G={key:0,class:"klineSub-tips-select"},J=t.defineComponent({__name:"index",props:{drawData:{type:Object,require:!0},activeIndex:{type:Number,require:!0},modelValue:{type:String,required:!0},subIndicatorList:{type:Array,required:!0},config:{type:Object,require:!0}},emits:["update:modelValue"],setup(_,{expose:v,emit:A}){const{round:h}=z.x;let y,S;const f=A,u=_,o=t.ref(),d=t.computed({get(){return u.modelValue},set(e){f("update:modelValue",e)}}),m=t.computed(()=>{const{drawData:e,activeIndex:i}=u,a=u.subIndicatorList.find(l=>l.value===d.value);return e.originData&&e.originData[i]?a.config.map(l=>{var D,F;let r="-";return l.source==="origin"?r=e.originData[i][l.dataIndex]||"-":l.source==="calculation"&&(r=(((F=(D=e.subIndicatorData)==null?void 0:D.find(b=>b.key===l.key))==null?void 0:F.data)||[])[i]),{label:l.key,color:l.color,value:r==="-"?r:h(r)}}):[]});t.onMounted(()=>{y=E.init(o.value);let e=!0;S=new ResizeObserver(()=>{if(e){e=null;return}y.resize()}),S.observe(o.value)}),t.onUnmounted(()=>{y.dispose(),S.disconnect(),S=null});const p=(e,i)=>{const a=e[i],l=i===0?e[i]:e[i-1];return a[0]===a[1]?a[0]>=l[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:a[1]>a[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return v({connect:e=>{E.connect([e,y])},draw:e=>{t.nextTick(()=>{var w;const{startValue:i,endValue:a,maxValueSpan:l}=e,{xAxisData:r,subIndicatorData:D,candlestickData:F,originData:x}=u.drawData,b=u.subIndicatorList.find(c=>c.value===d.value),V=[];if(b.series==="bar"){let c=[];b.source==="origin"?c=x.map(g=>g[b.dataIndex]):c=((w=D==null?void 0:D.find(g=>g.key===b.dataIndex))==null?void 0:w.data)||[],V.push({name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:c.map((g,I)=>b.color==="kline"?{value:g,itemStyle:p(F,I)}:b.color==="value"?{value:g,itemStyle:{color:g>=0?"#FF0000":"#00FFFF"}}:{value:g,itemStyle:{color:b.color}})})}D.forEach(c=>{if(c.series==="line"){let g=[];c.source==="origin"?g=x.map(I=>I[c.dataIndex]):c.source==="calculation"&&(g=c.data),V.push({xAxisIndex:0,yAxisIndex:c.yAxis==="right"?2:1,name:c.key,type:"line",silent:!0,symbol:"none",data:g,lineStyle:{width:1},itemStyle:{color:c.color}})}}),y.setOption({animation:!1,grid:{left:`${u.config.gridLeft}px`,top:"10px",right:`${u.config.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:i,endValue:a,maxValueSpan:l}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:c=>{const{axisDimension:g,value:I}=c;if(g==="x")return I;if(c.axisIndex===1)return String(h(I))}}},formatter:()=>""},xAxis:{type:"category",data:r,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{show:!0,formatter:c=>c}},yAxis:[{position:"right"},{position:"left",min:b.leftYAxisRange==="cover"?c=>c.min:null,max:b.leftYAxisRange==="cover"?c=>c.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:b.rightYAxisRange==="cover"?c=>c.min:null,max:b.rightYAxisRange==="cover"?c=>c.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:V},!0)})}}),(e,i)=>{const a=R.ElOption,l=R.ElSelect;return t.openBlock(),t.createElementBlock("div",Y,[t.createElementVNode("div",H,[m.value.length?(t.openBlock(),t.createElementBlock("div",G,[t.createVNode(l,{modelValue:d.value,"onUpdate:modelValue":i[0]||(i[0]=r=>d.value=r),size:"small","popper-class":"element-dark",class:"element-dark subIndicator"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(_.subIndicatorList,r=>(t.openBlock(),t.createBlock(a,{key:r.value,label:r.label,value:r.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):t.createCommentVNode("",!0),t.createVNode(O,{data:m.value},null,8,["data"])]),t.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:o},null,512)])}}});const Q=L._export_sfc(J,[["__scopeId","data-v-0a2f256e"]]),W=t.defineComponent({__name:"index",props:{data:{type:Array,default:()=>[]}},emits:["change"],setup(_,{expose:v,emit:A}){let h,y,S=null;const f=A,u=_,o=t.ref();t.watch(()=>u.data,()=>{p()},{deep:!0}),t.onMounted(()=>{h=E.init(o.value),d(),p();let e=!0;y=new ResizeObserver(()=>{if(e){e=null;return}h.resize()}),y.observe(o.value)}),t.onUnmounted(()=>{h.off("datazoom"),h.dispose(),y.disconnect(),y=null});const d=()=>{h.on("datazoom",e=>{e.dataZoomId&&(clearTimeout(S),S=setTimeout(()=>{const{data:i}=u,{start:a,end:l}=e,r=Math.floor(a*i.length/100),D=l===100?i.length-1:Math.floor(l*i.length/100);m(r,D),clearTimeout(S)},100))})},m=(e,i)=>{const a=u.data;if(a.length===0)return;const l=a[e][0].split(" ")[0],r=a[i][0].split(" ")[0];f("change",{startTime:`${l} 00:00:00`,endTime:`${r} 24:00:00`})},p=()=>{const{data:e}=u;if(e.length===0)return;const i=e.map(l=>l[0].split(" ")[0]),a=e.map(l=>l[1]);h.setOption({grid:{height:0,left:"80px",right:"80px"},xAxis:{type:"category",data:i,show:!1},yAxis:{type:"value"},series:[{data:a,type:"line"}]},!0)};return v({resetSlide:(e,i,a)=>{let l=-1,r=-1;u.data.forEach((D,F)=>{l===-1&&D[0]===e?l=F:l===-1&&new Date(D[0])>new Date(e)&&(l=F-1),(r===-1&&D[0]===i||r===-1&&new Date(D[0])>new Date(i))&&(r=F)}),r=r===-1?u.data.length-1:r,h.setOption({dataZoom:[{show:!0,startValue:l,endValue:r,maxValueSpan:a,textStyle:{color:"#ccc"}},{type:"inside",startValue:l,endValue:r,maxValueSpan:a}]})},resize:()=>{h==null||h.resize()}}),(e,i)=>(t.openBlock(),t.createElementBlock("div",{class:"klineSlide",ref_key:"slideChartRef",ref:o},null,512))}});const X=L._export_sfc(W,[["__scopeId","data-v-5008746a"]]),ee={install(_){_.component("st-klineUtils",M),_.component("st-klineSub",Q),_.component("st-klineTips",Z),_.component("st-klineSlide",X)}};module.exports=ee;
1
+ "use strict";const t=require("vue"),C=require("./index.esm-94a95a2a.cjs"),L=require("./_plugin-vue_export-helper-f246444f.cjs"),z=require("./index-dc273ea2.cjs");require("./base-ec05f348.cjs");require("./el-tag-3b03d13e.cjs");const R=require("./el-select-928f8c19.cjs");require("./el-scrollbar-d1c3e7f7.cjs");require("./el-popper-f62316cd.cjs");const $=require("echarts");require("./use-form-common-props-1b84d8f4.cjs");require("./index-80a2b137.cjs");require("./castArray-a45823fe.cjs");require("./index-e1e83173.cjs");require("./event-61f49698.cjs");require("./scroll-41224831.cjs");require("./debounce-b2ff12bd.cjs");function N(D){const x=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(D){for(const S in D)if(S!=="default"){const g=Object.getOwnPropertyDescriptor(D,S);Object.defineProperty(x,S,g.get?g:{enumerable:!0,get:()=>D[S]})}}return x.default=D,Object.freeze(x)}const E=N($),M=t.defineComponent({__name:"index",setup(D,{expose:x}){let S=!1,g=!0,y=[];const w=(h,u)=>h.length>u?h.slice(h.length-u):h;return x({initTalib:async()=>{if(!S)S=!0,await C.init("./talib.wasm"),g=!1,y.forEach(h=>{h()});else if(g)return new Promise(h=>{y.push(h)})},handleKeyDown:(h,u)=>{let{startValue:r,endValue:d,maxIndex:f}=u;if(h.code==="ArrowLeft"){if(r===0)return;r=r-1,d=d-1}else if(h.code==="ArrowRight"){if(d===f)return;r=r+1,d=d+1}else if(h.code==="ArrowUp"){if(d-r<5)return;const p=Math.floor((d-r)/2)+1;r=r+p,d-r<5&&(r=d-4)}else if(h.code==="ArrowDown"){const p=Math.min(500,d-r);r=r-p-1}return{startValue:r,endValue:d}},getDataZoomInfoByTime:h=>{const{showStartTime:u,showEndTime:r,xAxisData:d,maxShowDays:f}=h;let p=-1,e=-1,i={};return d.forEach((a,n)=>{const l=a.split(" ")[0];i[l]=i[l]||0,i[l]+=1,new Date(a)>=new Date(u)&&p===-1&&(p=n),new Date(a)<=new Date(r)&&(e=n)}),{startValue:p,endValue:e,maxValueSpan:Math.max(...Object.values(i))*f}},formatDataBySlide:h=>{const{originDrawData:u,addData:r,startTime:d,endTime:f}=h,{mainIndicator:p,mainIndicatorList:e,subIndicator:i,subIndicatorList:a,config:n,timeRange:l}=h,{loadAddCount:b,preLoadCount:F}=n;let m=[],v=[],V=[],k=[];d&&f?(m=r.filter(s=>new Date(s[0])>=new Date(d)&&new Date(s[0])<=new Date(f)),k=[...r]):f?(m=[...r.filter((s,o)=>o>=r.length-b&&new Date(l[0])<=new Date(s[0])&&new Date(s[0])<=new Date(l[1])),...u.originData],k=[...r,...u.originData]):d&&(m=[...u.originData,...r.filter((s,o)=>o>=F&&new Date(l[0])<=new Date(s[0])&&new Date(s[0])<=new Date(l[1]))],k=m),m.forEach((s,o)=>{v.push([s[1],s[4],s[3],s[2],o===0?0:m[o-1][4],s[6]]),V.push(s[0])});let c=[],_=[];const I={time:[],open:[],close:[],high:[],low:[],originData:k};let B=null,T=null;return k.forEach((s,o)=>{I.time.push(s[0]),I.open.push(s[1]),I.close.push(s[4]),I.high.push(s[2]),I.low.push(s[3]),s[0]===m[0][0]&&(B=o),s[0]===m[m.length-1][0]&&(T=o+1)}),c=e.find(({value:s})=>s===p).config.map(s=>{const{calculationFn:o}=s,A={time:[],open:[],close:[],high:[],low:[],originData:[]};return{...s,data:o?o(C.talib,I,A).slice(B,T):[]}}),_=a.find(({value:s})=>s===i).config.reduce((s,o)=>{const{source:A,calculationFn:q}=o;return A==="calculation"?[...s,{...o,data:q?q(C.talib,I).slice(B,T):[]}]:s},[]),{originData:m,candlestickData:v,mainIndicatorData:c,subIndicatorData:_,xAxisData:V,startTime:m[0][0],endTime:m[m.length-1][0],length:m.length}},formatDataByCount:h=>{const{originDrawData:u,addData:r,mainIndicator:d,mainIndicatorList:f,subIndicator:p,subIndicatorList:e,config:i}=h;let a={};const{addCount:n,preLoadCount:l}=i,b=[],F=[],m=[],v=[],V=[];let k=[],c=[];const _=r.filter((o,A)=>(b.push(o[0]),F.push(o[1]),m.push(o[4]),v.push(o[2]),V.push(o[3]),k.push(o[0]),c.push([o[1],o[4],o[3],o[2],A===0?0:r[A-1][4],o[6]]),r.length>=n+l-1?A>=l:!0));k=w(k,_.length),c=w(c,_.length);const I={time:b,open:F,close:m,high:v,low:V,originData:r},T=f.find(o=>o.value===d).config.map(o=>({...o,data:w(o.calculationFn?o.calculationFn(C.talib,I,{time:[],open:[],close:[],high:[],low:[],originData:[]}):[],k.length)}));let s=[];return p&&e&&(s=e.find(A=>A.value===p).config.reduce((A,q)=>q.source==="calculation"?[...A,{...q,data:w(q.calculationFn?q.calculationFn(C.talib,I):[],k.length)}]:A,[])),u.length?a={originData:[..._,...u.originData],xAxisData:[...k,...u.xAxisData],candlestickData:[...c,...u.candlestickData],mainIndicatorData:u.mainIndicatorData.map((o,A)=>({...o,data:[...T[A].data,...o.data]})),subIndicatorData:u.subIndicatorData.map((o,A)=>({...o,data:[...s[A].data,...o.data]}))}:a={originData:_,xAxisData:k,candlestickData:c,mainIndicatorData:T,subIndicatorData:s},a.length=a.xAxisData.length,a.startTime=a.xAxisData[0],a.endTime=a.xAxisData[a.length-1],a},fn:()=>{}}),(h,u)=>null}}),j={class:"kline-tips"},P=t.defineComponent({__name:"index",props:{data:{type:Array,require:!0}},setup(D){return(x,S)=>(t.openBlock(),t.createElementBlock("div",j,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(D.data,(g,y)=>(t.openBlock(),t.createElementBlock("div",{key:y,class:"kline-tips-item",style:t.normalizeStyle({color:g.color})},t.toDisplayString(g.label)+" "+t.toDisplayString(g.value),5))),128))]))}});const O=L._export_sfc(P,[["__scopeId","data-v-2a02e841"]]),K={class:"kline-tips"},U=t.defineComponent({__name:"index",props:{drawData:{type:Object,require:!0},candlestickData:{type:Array,default:()=>null},mainIndicatorData:{type:Array,default:()=>null},activeIndex:{type:Number,require:!0}},setup(D){const{round:x,multiply:S,divide:g,subtract:y,formatValue:w}=z.x,h=D,u=t.computed(()=>{const{drawData:d,activeIndex:f,candlestickData:p}=h;if(p!=null&&p.length&&p[f]){let e;return p[f][6]>0?e="red":p[f][6]<0&&(e="green"),[{label:"开",value:x(p[f][0])},{label:"高",value:x(p[f][3])},{label:"低",value:x(p[f][2])},{label:"收",value:x(p[f][1])},{label:"额",value:w(p[f][4])},{label:"涨跌",value:`${x(p[f][6])}%`,color:e}]}else if(d.candlestickData&&d.candlestickData[f]){const e=d.candlestickData[f],i=[{label:"开",value:x(e[0])},{label:"高",value:x(e[3])},{label:"低",value:x(e[2])},{label:"收",value:x(e[1])}];e[5]!==void 0&&i.push({label:"额",value:w(e[5])});const a=x(S(g(y(e[1],e[4]),Math.abs(e[4])),100));let n;return a>0?n="red":a<0&&(n="green"),i.push({label:"涨跌",value:`${a}%`,color:n}),i}return[]}),r=t.computed(()=>{var p;const{drawData:d,activeIndex:f}=h;return((p=d==null?void 0:d.mainIndicatorData)==null?void 0:p.map(e=>({label:e.key,value:x(e.data[f]),color:e.color})))||[]});return(d,f)=>(t.openBlock(),t.createElementBlock("div",K,[t.createVNode(O,{data:u.value},null,8,["data"]),t.createVNode(O,{data:r.value},null,8,["data"])]))}});const Z=L._export_sfc(U,[["__scopeId","data-v-234f3f41"]]),Y={class:"klineSub"},H={class:"klineSub-tips"},G={key:0,class:"klineSub-tips-select"},J=t.defineComponent({__name:"index",props:{drawData:{type:Object,require:!0},activeIndex:{type:Number,require:!0},modelValue:{type:String,required:!0},subIndicatorList:{type:Array,required:!0},config:{type:Object,require:!0}},emits:["update:modelValue"],setup(D,{expose:x,emit:S}){const{round:g}=z.x;let y,w;const h=S,u=D,r=t.ref(),d=t.computed({get(){return u.modelValue},set(e){h("update:modelValue",e)}}),f=t.computed(()=>{const{drawData:e,activeIndex:i}=u,a=u.subIndicatorList.find(n=>n.value===d.value);return e.originData&&e.originData[i]?a.config.map(n=>{var b,F;let l="-";return n.source==="origin"?l=e.originData[i][n.dataIndex]||"-":n.source==="calculation"&&(l=(((F=(b=e.subIndicatorData)==null?void 0:b.find(v=>v.key===n.key))==null?void 0:F.data)||[])[i]),{label:n.key,color:n.color,value:l==="-"?l:g(l)}}):[]});t.onMounted(()=>{y=E.init(r.value);let e=!0;w=new ResizeObserver(()=>{if(e){e=null;return}y.resize()}),w.observe(r.value)}),t.onUnmounted(()=>{y.dispose(),w.disconnect(),w=null});const p=(e,i)=>{const a=e[i],n=i===0?e[i]:e[i-1];return a[0]===a[1]?a[0]>=n[1]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}:a[1]>a[0]?{color:"transparent",borderColor:"#FF0000"}:{color:"#00FFFF"}};return x({connect:e=>{E.connect([e,y])},draw:e=>{t.nextTick(()=>{var k;const{startValue:i,endValue:a,maxValueSpan:n}=e,{xAxisData:l,subIndicatorData:b,candlestickData:F,originData:m}=u.drawData,v=u.subIndicatorList.find(c=>c.value===d.value),V=[];if(v.series==="bar"){let c=[];v.source==="origin"?c=m.map(_=>_[v.dataIndex]):c=((k=b==null?void 0:b.find(_=>_.key===v.dataIndex))==null?void 0:k.data)||[],V.push({name:"subMain",xAxisIndex:0,yAxisIndex:1,type:"bar",silent:!0,symbol:"none",data:c.map((_,I)=>v.color==="kline"?{value:_,itemStyle:p(F,I)}:v.color==="value"?{value:_,itemStyle:{color:_>=0?"#FF0000":"#00FFFF"}}:{value:_,itemStyle:{color:v.color}})})}b.forEach(c=>{if(c.series==="line"){let _=[];c.source==="origin"?_=m.map(I=>I[c.dataIndex]):c.source==="calculation"&&(_=c.data),V.push({xAxisIndex:0,yAxisIndex:c.yAxis==="right"?2:1,name:c.key,type:"line",silent:!0,symbol:"none",data:_,lineStyle:{width:1},itemStyle:{color:c.color}})}}),y.setOption({animation:!1,grid:{left:`${u.config.gridLeft}px`,top:"10px",right:`${u.config.gridRight}px`,bottom:"20px"},dataZoom:[{type:"inside",startValue:i,endValue:a,maxValueSpan:n}],tooltip:{trigger:"axis",appendToBody:!0,confine:!0,axisPointer:{type:"cross",label:{rich:{},formatter:c=>{const{axisDimension:_,value:I}=c;if(_==="x")return I;if(c.axisIndex===1)return String(g(I))}}},formatter:()=>""},xAxis:{type:"category",data:l,axisLine:{show:!0},splitLine:{show:!1},axisLabel:{show:!0,formatter:c=>c}},yAxis:[{position:"right"},{position:"left",min:v.leftYAxisRange==="cover"?c=>c.min:null,max:v.leftYAxisRange==="cover"?c=>c.max:null,splitNumber:1,axisLine:{show:!0},splitLine:{show:!0,lineStyle:{type:"dotted",color:"#333"}}},{position:"right",min:v.rightYAxisRange==="cover"?c=>c.min:null,max:v.rightYAxisRange==="cover"?c=>c.max:null,splitNumber:1,axisLine:{show:!1},splitLine:{show:!1},axisLabel:{show:!1}}],series:V},!0)})}}),(e,i)=>{const a=R.ElOption,n=R.ElSelect;return t.openBlock(),t.createElementBlock("div",Y,[t.createElementVNode("div",H,[f.value.length?(t.openBlock(),t.createElementBlock("div",G,[t.createVNode(n,{modelValue:d.value,"onUpdate:modelValue":i[0]||(i[0]=l=>d.value=l),size:"small","popper-class":"element-dark",class:"element-dark subIndicator"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(D.subIndicatorList,l=>(t.openBlock(),t.createBlock(a,{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])])):t.createCommentVNode("",!0),t.createVNode(O,{data:f.value},null,8,["data"])]),t.createElementVNode("div",{class:"klineSub-chart",ref_key:"subChartRef",ref:r},null,512)])}}});const Q=L._export_sfc(J,[["__scopeId","data-v-0a2f256e"]]),W=t.defineComponent({__name:"index",props:{data:{type:Array,default:()=>[]}},emits:["change"],setup(D,{expose:x,emit:S}){let g,y,w=null;const h=S,u=D,r=t.ref();t.watch(()=>u.data,()=>{p()},{deep:!0}),t.onMounted(()=>{g=E.init(r.value),d(),p();let e=!0;y=new ResizeObserver(()=>{if(e){e=null;return}g.resize()}),y.observe(r.value)}),t.onUnmounted(()=>{g.off("datazoom"),g.dispose(),y.disconnect(),y=null});const d=()=>{g.on("datazoom",e=>{e.dataZoomId&&(clearTimeout(w),w=setTimeout(()=>{const{data:i}=u,{start:a,end:n}=e,l=Math.floor(a*i.length/100),b=n===100?i.length-1:Math.floor(n*i.length/100);f(l,b),clearTimeout(w)},100))})},f=(e,i)=>{const a=u.data;if(a.length===0)return;const n=a[e][0].split(" ")[0],l=a[i][0].split(" ")[0];h("change",{startTime:`${n} 00:00:00`,endTime:`${l} 24:00:00`})},p=()=>{const{data:e}=u;if(e.length===0)return;const i=e.map(n=>n[0].split(" ")[0]),a=e.map(n=>n[1]);g.setOption({grid:{height:0,left:"80px",right:"80px"},xAxis:{type:"category",data:i,show:!1},yAxis:{type:"value"},series:[{data:a,type:"line"}]},!0)};return x({resetSlide:(e,i,a)=>{let n=-1,l=-1;u.data.forEach((b,F)=>{n===-1&&b[0]===e?n=F:n===-1&&new Date(b[0])>new Date(e)&&(n=F-1),(l===-1&&b[0]===i||l===-1&&new Date(b[0])>new Date(i))&&(l=F)}),l=l===-1?u.data.length-1:l,g.setOption({dataZoom:[{show:!0,startValue:n,endValue:l,maxValueSpan:a,textStyle:{color:"#ccc"}},{type:"inside",startValue:n,endValue:l,maxValueSpan:a}]})},resize:()=>{g==null||g.resize()}}),(e,i)=>(t.openBlock(),t.createElementBlock("div",{class:"klineSlide",ref_key:"slideChartRef",ref:r},null,512))}});const X=L._export_sfc(W,[["__scopeId","data-v-5008746a"]]),ee={install(D){D.component("st-klineUtils",M),D.component("st-klineSub",Q),D.component("st-klineTips",Z),D.component("st-klineSlide",X)}};module.exports=ee;