k-line/dist8/assets/NewStyleDesign-DVG2STix.js

2 lines
11 KiB
JavaScript

import{s as H,r as e,K as Q,o as X,L as h,w as Y,M as ee,c as te,d as x,b as le,u as ae,J as ie}from"./index-BO9WyeNZ.js";import{u as se,a as oe}from"./usethemestore-BOyyPoG1.js";import{c as ne,a as re,b as P,d as ye,e as G,f as R}from"./computedInfo-DRxOaYt6.js";import{_ as ue}from"./_plugin-vue_export-helper-DlAUqK2U.js";const pe={class:"box"},de={class:"newk"},ce={class:"newd"},ve={__name:"NewStyleDesign",setup(xe){const j=ae(),J=se(),{theme:r}=H(J);let u=null;e(4);let D=e(null),p=null;e(0);let C=e(null),d=null;e(0);let E=e(null),c=null;e(0);let B=e(null),v=null;e(0),e([]);let M=e([]),y=e([]),n=e([]),V=e(null),g=e(null),b=e(null),m=e(null),A=e(null),F=e(null),Z=e(null),S=e(null),L=e(null),w=e(null),I=e(null),_=e(null),k=e(null),O=e(null);e();let N="http://localhost:8012/akshare";const $=async()=>(await oe({url:N+"/kdata",method:"get"})).data.message,T=e(null),U=e(null);let z=e([]),i=e([{id:1,name:"MACD",attId:"charts1",status:!1,options:{animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},dataZoom:[{type:"inside"},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:[]},yAxis:{type:"value"},series:[{name:"DIF",type:"line",itemStyle:{normal:{color:"rgba(204,102,0,1)"}},symbol:"none",data:[]},{name:"DEA",type:"line",itemStyle:{normal:{color:"rgba(0,128,255,1)"}},symbol:"none",data:[]},{name:"MACD",type:"bar",barWidth:"1",data:[]}]}},{id:2,name:"VOL",attId:"charts2",status:!1,options:{animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},dataZoom:[{type:"inside"},{type:"slider",show:!1}],xAxis:{type:"category",data:[]},yAxis:{type:"value",interval:10},series:[{name:"VOL",type:"bar",data:[]}]}},{id:3,name:"KDJ",attId:"charts3",status:!1,options:{animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},dataZoom:[{type:"inside",xAxisIndex:[0,0],start:20,end:100},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:[]},series:[{name:"K",type:"line",data:[],symbol:"none",smooth:!0},{name:"D",type:"line",data:[],symbol:"none",smooth:!0},{name:"J",type:"line",data:[],symbol:"none",smooth:!0}]}},{id:4,name:"RSI",attId:"charts4",status:!1,options:{animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},dataZoom:[{type:"inside",xAxisIndex:[0,0],start:20,end:100},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:[]},series:[{name:"rsi1",type:"line",data:[],symbol:"none",smooth:!0},{name:"rsi2",type:"line",data:[],symbol:"none",smooth:!0},{name:"rsi3",type:"line",data:[],symbol:"none",smooth:!0}]}}]);e([]),Q("group1");let f=e({});const W=async()=>{try{if(f.value=await $(),Object.keys(f.value.date).length==0){console.log("没有数据"),j.push("/thenew/nodata");return}M.value=[],y.value=[],n.value=[],V.value=[],g.value=[],b.value=[],m.value=[],A.value=[],F.value=[],Z.value=[],S.value=[],L.value=[],w.value=[],I.value=[],_.value=[],k.value=[],O.value=[],y.value=Object.values(f.value.date);let{open:l,close:a,low:s,high:o}=f.value;for(let t=0;t<Object.keys(l).length;t++)M.value.push([l[t],a[t],s[t],o[t]]),n.value.push(a[t]);V.value=ne(n.value,5),A.value=re(n.value),F.value=n.value.map(t=>parseFloat((t+A.value).toFixed(2))),Z.value=n.value.map(t=>parseFloat((t-A.value).toFixed(2))),g.value=P(n.value).dif,b.value=P(n.value).dea,m.value=P(n.value).macd,m.value=m.value.map(function(t){return{value:t,itemStyle:{color:t>=0?"#FF0000":"#00FF00"}}}),i.value[0].options.series[0].data=g.value,i.value[0].options.series[1].data=b.value,i.value[0].options.series[2].data=m.value,i.value[0].options.xAxis.data=y.value,O.value=ye(a,o,s),i.value[1].options.xAxis.data=y.value,i.value[1].options.series[0].data=O.value,S.value=G(f.value).kValues,L.value=G(f.value).dValues,w.value=G(f.value).jValues,i.value[2].options.series[0].data=S.value,i.value[2].options.series[1].data=L.value,i.value[2].options.series[2].data=w.value,i.value[2].options.xAxis.data=y.value,I.value=R(n.value),_.value=R(n.value,12),k.value=R(n.value,24),i.value[3].options.series[0].data=I.value,i.value[3].options.series[1].data=_.value,i.value[3].options.series[2].data=k.value,i.value[3].options.xAxis.data=y.value}catch(l){console.log(l)}};return X(async()=>{await W(),document.getElementById("main").removeAttribute("_echarts_instance_"),u=h(document.getElementById("main"));let l={animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"},animation:!1}},legend:{data:["KLine","MA5","BOLL1","BOLL2"],textStyle:{color:"#fff",fontSize:12}},grid:[{left:"3%",right:"3%",bottom:"10%",top:"12%"}],xAxis:[{type:"category",data:y.value,gridIndex:0,scale:!0,boundaryGap:!1,axisLine:{onZero:!1},splitLine:{show:!1},splitNumber:20,min:"dataMin",max:"dataMax",sampling:"lttb"}],yAxis:[{gridIndex:0,scale:!0,splitArea:{show:!1},splitLine:{lineStyle:{color:"white",opacity:.1}}}],dataZoom:[{type:"slider"},{type:"inside"}],series:[{name:"KLine",type:"candlestick",xAxisIndex:0,yAxisIndex:0,data:M.value,itemStyle:{normal:{color:"#ef232a",color0:"#14b143",borderColor:"#ef232a",borderColor0:"#14b143"}}},{name:"MA5",type:"line",xAxisIndex:0,yAxisIndex:0,data:V.value,symbol:"none",smooth:!0,lineStyle:{normal:{opacity:.8,width:2}}},{name:"BOLL1",type:"line",xAxisIndex:0,yAxisIndex:0,data:F.value,symbol:"none",smooth:!0,lineStyle:{normal:{opacity:.5,color:"red"}}},{name:"BOLL2",type:"line",xAxisIndex:0,yAxisIndex:0,data:Z.value,symbol:"none",smooth:!0,lineStyle:{normal:{opacity:.5,color:"green"}}}]};r.value||(l.legend.textStyle.color="#fff",l.yAxis[0].splitLine.lineStyle.color="#fff",l.yAxis[0].splitLine.lineStyle.opacity=.1),r.value&&(l.legend.textStyle.color="#000",l.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",l.yAxis[0].splitLine.lineStyle.opacity=.4),u.setOption(l),u.group="group1",window.addEventListener("resize",function(){u.resize()}),D.value.style.height=`${z.value[1]}px`,p=h(D.value);let a={animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{top:"10%",left:"3%",right:"3%",bottom:"20%"},dataZoom:[{type:"inside"},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:y.value},yAxis:[{type:"value",splitLine:{lineStyle:{color:"white",opacity:.1}}}],series:[{name:"DIF",type:"line",itemStyle:{normal:{color:"rgba(204,102,0,1)"}},symbol:"none",data:g.value},{name:"DEA",type:"line",itemStyle:{normal:{color:"rgba(0,128,255,1)"}},symbol:"none",data:b.value},{name:"MACD",type:"bar",barWidth:"1",data:m.value}]};r.value||(a.yAxis[0].splitLine.lineStyle.color="#fff",a.yAxis[0].splitLine.lineStyle.opacity=.1),r.value&&(a.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",a.yAxis[0].splitLine.lineStyle.opacity=.4),p.setOption(a),p.group="group1",window.addEventListener("resize",function(){p.resize()}),C.value.style.height=`${z.value[1]}px`,d=h(C.value);let s={animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{top:"10%",left:"3%",right:"3%",bottom:"20%"},dataZoom:[{type:"inside"},{type:"slider",show:!1}],xAxis:{type:"category",data:y.value},yAxis:[{type:"value",interval:10,splitLine:{lineStyle:{color:"white",opacity:.1}}}],series:[{name:"VOL",type:"bar",data:O.value}]};r.value||(s.yAxis[0].splitLine.lineStyle.color="#fff",s.yAxis[0].splitLine.lineStyle.opacity=.1),r.value&&(s.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",s.yAxis[0].splitLine.lineStyle.opacity=.4),d.setOption(s),d.group="group1",window.addEventListener("resize",function(){d.resize()}),E.value.style.height=`${z.value[1]}px`,c=h(E.value);let o={animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{top:"10%",left:"3%",right:"3%",bottom:"20%"},dataZoom:[{type:"inside",xAxisIndex:[0,0],start:20,end:100},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:y.value},yAxis:[{type:"value",splitLine:{lineStyle:{color:"white",opacity:.1}}}],series:[{name:"K",type:"line",data:S.value,symbol:"none",smooth:!0,lineStyle:{width:1}},{name:"D",type:"line",data:L.value,symbol:"none",smooth:!0,lineStyle:{width:1}},{name:"J",type:"line",data:w.value,symbol:"none",smooth:!0,lineStyle:{width:1}}]};r.value||(o.yAxis[0].splitLine.lineStyle.color="#fff",o.yAxis[0].splitLine.lineStyle.opacity=.1),r.value&&(o.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",o.yAxis[0].splitLine.lineStyle.opacity=.4),c.setOption(o),c.group="group1",window.addEventListener("resize",function(){c.resize()}),B.value.style.height=`${z.value[1]}px`,v=h(B.value);let t={animation:!1,tooltip:{trigger:"axis",axisPointer:{type:"cross",label:{backgroundColor:"#6a7985"}}},grid:{top:"10%",left:"3%",right:"3%",bottom:"20%"},dataZoom:[{type:"inside",xAxisIndex:[0,0],start:20,end:100},{type:"slider",show:!1}],xAxis:{type:"category",boundaryGap:!1,data:y.value},yAxis:[{type:"value",splitLine:{lineStyle:{color:"white",opacity:.1}}}],series:[{name:"rsi1",type:"line",data:I.value,symbol:"none",smooth:!0,lineStyle:{width:1}},{name:"rsi2",type:"line",data:_.value,symbol:"none",smooth:!0,lineStyle:{width:1}},{name:"rsi3",type:"line",data:k.value,symbol:"none",smooth:!0,lineStyle:{width:1}}]};r.value||(t.yAxis[0].splitLine.lineStyle.color="#fff",t.yAxis[0].splitLine.lineStyle.opacity=.1),r.value&&(t.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",t.yAxis[0].splitLine.lineStyle.opacity=.4),v.setOption(t),v.group="group1",window.addEventListener("resize",function(){v.resize()}),Y(()=>r.value,async(K,fe)=>{if(await ie(),console.log(K),K===!1)try{l.legend.textStyle.color="#fff",l.yAxis[0].splitLine.lineStyle.color="#fff",l.yAxis[0].splitLine.lineStyle.opacity=.1,a.yAxis[0].splitLine.lineStyle.color="#fff",a.yAxis[0].splitLine.lineStyle.opacity=.1,s.yAxis[0].splitLine.lineStyle.color="#fff",s.yAxis[0].splitLine.lineStyle.opacity=.1,o.yAxis[0].splitLine.lineStyle.color="#fff",o.yAxis[0].splitLine.lineStyle.opacity=.1,t.yAxis[0].splitLine.lineStyle.color="#fff",t.yAxis[0].splitLine.lineStyle.opacity=.1,u.setOption(l),p.setOption(a),d.setOption(s),c.setOption(o),v.setOption(t)}catch{}if(K===!0)try{l.legend.textStyle.color="#000",l.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",l.yAxis[0].splitLine.lineStyle.opacity=.4,a.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",a.yAxis[0].splitLine.lineStyle.opacity=.4,s.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",s.yAxis[0].splitLine.lineStyle.opacity=.4,o.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",o.yAxis[0].splitLine.lineStyle.opacity=.4,t.yAxis[0].splitLine.lineStyle.color="rgb(168, 168, 168)",t.yAxis[0].splitLine.lineStyle.opacity=.4,u.setOption(l),p.setOption(a),d.setOption(s),c.setOption(o),v.setOption(t)}catch{}})}),ee(()=>{u&&(window.removeEventListener("resize",function(){u.resize()}),u.dispose(),u=null),p&&(window.removeEventListener("resize",function(){p.resize()}),p.dispose(),p=null),d&&(window.removeEventListener("resize",function(){d.resize()}),d.dispose(),d=null),c&&(window.removeEventListener("resize",function(){c.resize()}),c.dispose(),c=null),v&&(window.removeEventListener("resize",function(){v.resize()}),v.dispose(),v=null)}),(l,a)=>(le(),te("div",pe,[x("div",{class:"chartsinfo",ref_key:"chartsInfo",ref:T},[x("div",de,[x("div",{id:"main",ref_key:"mKline",ref:U,class:"flex-item",style:{height:"100%"}},null,512)]),x("div",ce,[x("div",{id:"charts1",ref_key:"charts1",ref:D},null,512),x("div",{id:"charts2",ref_key:"charts2",ref:C},null,512),x("div",{id:"charts3",ref_key:"charts3",ref:E},null,512),x("div",{id:"charts4",ref_key:"charts4",ref:B},null,512)])],512)]))}},Ae=ue(ve,[["__scopeId","data-v-9bf0c95e"]]);export{Ae as default};