hqchart 1.1.13640 → 1.1.13652

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hqchart",
3
- "version": "1.1.13640",
3
+ "version": "1.1.13652",
4
4
  "description": "HQChart - H5, 微信小程序 沪深/港股/数字货币/期货/美股 K线图(kline),走势图,缩放,拖拽,十字光标,画图工具,截图,筹码图. 分析家语法,通达信语法,(麦语法),第3方数据对接",
5
5
  "main": "lib/main.js",
6
6
  "scripts": {
@@ -48701,6 +48701,11 @@ HQData.NetworkFilter=function(data, callback)
48701
48701
  HQData.RequestMinuteDaysData(data, callback);
48702
48702
  break;
48703
48703
 
48704
+ case "MinuteChartContainer::RequestPopMinuteData": //弹出分时图数据
48705
+ //HQChart使用教程29-走势图如何对接第3方数据2-最新分时数据 格式跟这个一样
48706
+ HQData.RequestPopMinuteData(data, callback);
48707
+ break;
48708
+
48704
48709
  //HQChart使用教程30-K线图如何对接第3方数据1
48705
48710
  case 'KLineChartContainer::RequestHistoryData': //日线全量数据下载
48706
48711
  //HQChart使用教程30-K线图如何对接第3方数据2-日K数据
@@ -48805,39 +48810,93 @@ HQData.RequestMinuteData=function(data, callback)
48805
48810
  var symbol=data.Request.Data.symbol[0]; //请求的股票代码
48806
48811
  var callcation=data.Request.Data.callcation; //集合竞价
48807
48812
  console.log(`[HQData::RequestMinuteData] Symbol=${symbol}`);
48813
+
48814
+ setTimeout(()=>{
48815
+ var srcStock=MINUTE_1DAY_DATA.stock[0];
48816
+ var stockItem={ date:srcStock.date, minute:srcStock.minute, yclose:srcStock.yclose, symbol:srcStock.symbol, name:srcStock.name };
48817
+ if (callcation.Before)
48818
+ {
48819
+ var before=
48820
+ [
48821
+ //[交易时间, 价格,成交量, 成交金额, 日期(可选,YYYYMMDD)],
48822
+ [915, srcStock.yclose,0,0],
48823
+ [916, srcStock.yclose+0.01,0,0],
48824
+ [917, srcStock.yclose+0.03,0,0],
48825
+ [918, srcStock.yclose+0.02,0,0],
48826
+ [919, srcStock.yclose+0.02,0,0],
48827
+ [920, srcStock.yclose+0.01,0,0],
48828
+ [921, srcStock.yclose,0,0],
48829
+ [922, srcStock.yclose-0.02,0,0],
48830
+ [923, srcStock.yclose-0.03,0,0],
48831
+ [924, srcStock.yclose,0,0],
48832
+ [925, srcStock.yclose,0,0],
48833
+ ];
48834
+
48835
+ var beforeinfo={ totalcount:11, ver:1.0 };
48836
+
48837
+ stockItem.before=before;
48838
+ stockItem.beforeinfo=beforeinfo;
48839
+ }
48840
+
48841
+ var hqchartData={code:0, stock:[stockItem] };
48808
48842
 
48809
- var srcStock=MINUTE_1DAY_DATA.stock[0];
48810
- var stockItem={ date:srcStock.date, minute:srcStock.minute, yclose:srcStock.yclose, symbol:srcStock.symbol, name:srcStock.name };
48811
- if (callcation.Before)
48812
- {
48813
- var before=
48814
- [
48815
- //[交易时间, 价格,成交量, 成交金额, 日期(可选,YYYYMMDD)],
48816
- [915, srcStock.yclose,0,0],
48817
- [916, srcStock.yclose+0.01,0,0],
48818
- [917, srcStock.yclose+0.03,0,0],
48819
- [918, srcStock.yclose+0.02,0,0],
48820
- [919, srcStock.yclose+0.02,0,0],
48821
- [920, srcStock.yclose+0.01,0,0],
48822
- [921, srcStock.yclose,0,0],
48823
- [922, srcStock.yclose-0.02,0,0],
48824
- [923, srcStock.yclose-0.03,0,0],
48825
- [924, srcStock.yclose,0,0],
48826
- [925, srcStock.yclose,0,0],
48827
- ];
48828
48843
 
48829
- var beforeinfo={ totalcount:11, ver:1.0 };
48844
+ callback(hqchartData);
48845
+ }, 50);
48846
+ }
48830
48847
 
48831
- stockItem.before=before;
48832
- stockItem.beforeinfo=beforeinfo;
48833
- }
48848
+ HQData.RequestPopMinuteData=function(data, callback)
48849
+ {
48850
+ data.PreventDefault=true;
48851
+ var symbol=data.Request.Data.symbol[0]; //请求的股票代码
48852
+ var date=data.Request.Data.date;
48853
+ var callcation=data.Request.Data.callcation; //集合竞价
48854
+ console.log(`[HQData::RequestPopMinuteData] Symbol=${symbol} Date=${date}`);
48834
48855
 
48835
- var hqchartData={code:0, stock:[stockItem] };
48836
-
48856
+ setTimeout(()=>{
48857
+ var srcStock=MINUTE_1DAY_DATA.stock[0];
48858
+ var stockItem={ date:date, minute:[], yclose:srcStock.yclose, symbol:srcStock.symbol, name:srcStock.symbol, IsHistoryMinute:true };
48859
+ if (callcation.Before)
48860
+ {
48861
+ var before=
48862
+ [
48863
+ //[交易时间, 价格,成交量, 成交金额, 日期(可选,YYYYMMDD)],
48864
+ [915, srcStock.yclose,0,0],
48865
+ [916, srcStock.yclose+0.01,0,0],
48866
+ [917, srcStock.yclose+0.03,0,0],
48867
+ [918, srcStock.yclose+0.02,0,0],
48868
+ [919, srcStock.yclose+0.02,0,0],
48869
+ [920, srcStock.yclose+0.01,0,0],
48870
+ [921, srcStock.yclose,0,0],
48871
+ [922, srcStock.yclose-0.02,0,0],
48872
+ [923, srcStock.yclose-0.03,0,0],
48873
+ [924, srcStock.yclose,0,0],
48874
+ [925, srcStock.yclose,0,0],
48875
+ ];
48837
48876
 
48838
- callback(hqchartData);
48877
+ var beforeinfo={ totalcount:11, ver:1.0 };
48878
+
48879
+ stockItem.before=before;
48880
+ stockItem.beforeinfo=beforeinfo;
48881
+ }
48882
+
48883
+ for(var i=0;i<srcStock.minute.length;++i)
48884
+ {
48885
+ var item=srcStock.minute[i];
48886
+ var newItem=CloneData(item);
48887
+ newItem.date=date;
48888
+
48889
+ stockItem.minute.push(newItem);
48890
+ }
48891
+
48892
+ var hqchartData={code:0, stock:[stockItem] };
48893
+
48894
+
48895
+ callback(hqchartData);
48896
+ }, 50);
48839
48897
  }
48840
48898
 
48899
+
48841
48900
  HQData.RequestMinuteDaysData=function(data, callback)
48842
48901
  {
48843
48902
  data.PreventDefault=true;
@@ -0,0 +1,268 @@
1
+ /*
2
+ Copyright (c) 2018 jones
3
+
4
+ http://www.apache.org/licenses/LICENSE-2.0
5
+
6
+ 开源项目 https://github.com/jones2000/HQChart
7
+
8
+ jones_2000@163.com
9
+
10
+ K线点击弹出指定日期分时图
11
+ */
12
+
13
+
14
+ function JSPopMinuteChart()
15
+ {
16
+ this.DivDialog=null;
17
+ this.DivInfoText=null;
18
+ this.HQChart=null;
19
+ this.DragTitle=null;
20
+ this.Date=null;
21
+ this.ID=Guid();
22
+
23
+ this.Minute=
24
+ {
25
+ Option:JSPopMinuteChart.GetMinuteOption(),
26
+ JSChart:null,
27
+ Date:null,
28
+ }
29
+
30
+ this.Inital=function(hqchart)
31
+ {
32
+ this.HQChart=hqchart;
33
+ }
34
+
35
+ this.Create=function()
36
+ {
37
+ var divDom=document.createElement('div');
38
+ divDom.className='jchart_pop_minute_dailog';
39
+ divDom.id=this.ID;
40
+ divDom.style["background-color"]=g_JSChartResource.PopMinuteChart.BGColor;
41
+ divDom.style["border-color"]=g_JSChartResource.PopMinuteChart.BorderColor;
42
+
43
+ var divTitle=document.createElement("div");
44
+ divTitle.className='jschart_pop_minute_chart_Title_Div';
45
+ divTitle.onmousedown=(e)=>{ this.OnMouseDownTitle(e); }
46
+ divDom.appendChild(divTitle);
47
+
48
+ var divInfoText=document.createElement("div");
49
+ divInfoText.className="";
50
+ divInfoText.innerText="分时图";
51
+ this.DivInfoText=divInfoText;
52
+ divTitle.appendChild(divInfoText);
53
+
54
+ var divClose=document.createElement("div");
55
+ divClose.className='jschart_pop_minute_chart_Close_Div';
56
+ divClose.innerText="x";
57
+ divClose.onmousedown=(e)=>{ this.Close(e); }
58
+ divTitle.appendChild(divClose);
59
+
60
+
61
+ var divChart=document.createElement('div');
62
+ divChart.className='jschart_pop_minute_chart';
63
+ divDom.appendChild(divChart);
64
+
65
+ this.DivDialog=divDom;
66
+
67
+ var chart=JSChart.Init(divChart);
68
+ this.Minute.JSChart=chart;
69
+ this.Minute.Option.OnCreatedCallback=(chart)=>{ this.OnCreateHQChart(chart); }
70
+ this.Minute.Option.NetworkFilter=(data, callback)=>{ this.NetworkFilter(data, callback); }
71
+ chart.SetOption(this.Minute.Option); //设置K线配置
72
+
73
+ document.body.appendChild(divDom);
74
+ }
75
+
76
+ this.NetworkFilter=function(data, callback)
77
+ {
78
+ if (!this.HQChart || !this.HQChart.NetworkFilter) return;
79
+
80
+ if (data.Name== 'MinuteChartContainer::RequestMinuteData') //分时图数据对接
81
+ {
82
+ data.Request.Data.date=this.Date;
83
+ data.Name="MinuteChartContainer::RequestPopMinuteData";
84
+ data.Explain="指定日期分时数据"
85
+ };
86
+
87
+ this.HQChart.NetworkFilter(data, callback);
88
+ }
89
+
90
+ this.OnCreateHQChart=function(chart)
91
+ {
92
+
93
+ }
94
+
95
+ this.Destroy=function()
96
+ {
97
+ document.body.remove(this.DivDialog);
98
+ this.DivDialog=null;
99
+ this.DivInfoText=null;
100
+ this.Minute.JSChart=null;
101
+ }
102
+
103
+ this.IsShow=function()
104
+ {
105
+ if (!this.DivDialog) return false;
106
+
107
+ return this.DivDialog.style.visibility==='visible';
108
+ }
109
+
110
+ this.Show=function(data, x,y)
111
+ {
112
+ if (!this.DivDialog) this.Create();
113
+ if (!data.Symbol || !IFrameSplitOperator.IsPlusNumber(data.Date));
114
+
115
+ this.Date=data.Date;
116
+ var name=data.Symbol;
117
+ if (data.Name) name=data.Name;
118
+ var title=`${name} ${IFrameSplitOperator.FormatDateString(data.Date)} 分时图`
119
+ this.DivInfoText.innerText=title;
120
+
121
+ if (this.Minute.JSChart)
122
+ {
123
+ this.Minute.JSChart.ChangeSymbol(data.Symbol);
124
+ }
125
+
126
+ //超出窗口调整位置
127
+ var height=this.DivDialog.offsetHeight;
128
+ var width=this.DivDialog.offsetWidth;
129
+ var xRight=window.innerWidth-5;
130
+ var ybottom=window.innerHeight-5;
131
+ if (x+width>xRight) x=xRight-width;
132
+ if (y+height>ybottom) y=ybottom-height;
133
+
134
+ this.DivDialog.style.visibility='visible';
135
+ this.DivDialog.style.top = y + "px";
136
+ this.DivDialog.style.left = x + "px";
137
+ }
138
+
139
+ this.Close=function(e)
140
+ {
141
+ if (!this.DivDialog) return;
142
+
143
+ this.DivDialog.style.visibility='hidden';
144
+ }
145
+
146
+ this.OnMouseDownTitle=function(e)
147
+ {
148
+ if (!this.DivDialog) return;
149
+
150
+ var dragData={ X:e.clientX, Y:e.clientY };
151
+ dragData.YOffset=e.clientX - this.DivDialog.offsetLeft;
152
+ dragData.XOffset=e.clientY - this.DivDialog.offsetTop;
153
+ this.DragTitle=dragData;
154
+
155
+ document.onmousemove=(e)=>{ this.DocOnMouseMoveTitle(e); }
156
+ document.onmouseup=(e)=>{ this.DocOnMouseUpTitle(e); }
157
+ }
158
+
159
+ this.DocOnMouseMoveTitle=function(e)
160
+ {
161
+ if (!this.DragTitle) return;
162
+
163
+ var left = e.clientX - this.DragTitle.YOffset;
164
+ var top = e.clientY - this.DragTitle.XOffset;
165
+
166
+ var right=left+this.DivDialog.offsetWidth;
167
+ var bottom=top+ this.DivDialog.offsetHeight;
168
+
169
+ if ((right+5)>=window.innerWidth) left=window.innerWidth-this.DivDialog.offsetWidth-5;
170
+ if ((bottom+5)>=window.innerHeight) top=window.innerHeight-this.DivDialog.offsetHeight-5;
171
+
172
+ this.DivDialog.style.left = left + 'px';
173
+ this.DivDialog.style.top = top + 'px';
174
+
175
+ if(e.preventDefault) e.preventDefault();
176
+ }
177
+
178
+ this.DocOnMouseUpTitle=function(e)
179
+ {
180
+ this.DragTitle=null;
181
+ this.onmousemove = null;
182
+ this.onmouseup = null;
183
+ }
184
+
185
+ this.ReloadResource=function(option)
186
+ {
187
+ if (!this.DivDialog) return;
188
+
189
+ this.DivDialog.style["background-color"]=g_JSChartResource.PopMinuteChart.BGColor;
190
+ this.DivDialog.style["border-color"]=g_JSChartResource.PopMinuteChart.BorderColor;
191
+
192
+ if (this.Minute.JSChart) this.Minute.JSChart.ReloadResource(option);
193
+ }
194
+ }
195
+
196
+
197
+ JSPopMinuteChart.GetMinuteOption=function()
198
+ {
199
+ var option=
200
+ {
201
+ Type:'分钟走势图', //创建图形类型
202
+ Windows: //窗口指标
203
+ [
204
+ //{ Index:"VOL" },
205
+ //{ Index:"RSI" }
206
+ ],
207
+
208
+ Symbol:null, // cf1909.czc
209
+ IsAutoUpdate:false, //是自动更新数据
210
+ AutoUpdateFrequency:10000, //数据更新频率
211
+ DayCount:1, //1 最新交易日数据 >1 多日走势图
212
+ IsShowRightMenu:false, //是否显示右键菜单
213
+
214
+ EnableSelectRect:true,
215
+ EnableZoomIndexWindow:true,
216
+ EnableResize:true,
217
+
218
+ //BeforeOpen:{IsShow:true, Width:120, IsShowMultiDay:true, MulitiDayWidth:100, },
219
+ //AfterClose:{IsShow:true, Width:100, IsShowMultiDay:true, MulitiDayWidth:50, ShareVol:2 }, //ShareVol:0=盘后成交量独立坐标, 1==盘后成交量主图共用 2==盘后成交量盘前共用
220
+
221
+ CorssCursorInfo:{ Left:2, Right:1, Bottom:1 },
222
+
223
+ MinuteLine:
224
+ {
225
+
226
+ },
227
+
228
+ MinuteTitle:
229
+ {
230
+ IsShowTime:true,
231
+ IsShowName:false,
232
+ IsShowDate:true,
233
+ IsShowVolTitle:true,
234
+ //IsAlwaysShowLastData:true,
235
+ IsTitleShowLatestData:true,
236
+ },
237
+
238
+ MinuteVol:
239
+ {
240
+ BarColorType:1,
241
+ },
242
+
243
+ //Language:'EN',
244
+
245
+ Border: //边框
246
+ {
247
+ Left:20, //左边间距
248
+ Right:20, //右边间距
249
+ Top:25,
250
+ Bottom:25,
251
+
252
+ AutoLeft:{ Blank:10, MinWidth:60 },
253
+ AutoRight:{ Blank:10, MinWidth:60 },
254
+ },
255
+
256
+ Frame: //子框架设置
257
+ [
258
+ { SplitCount:5 },
259
+ { SplitCount:3 },
260
+ { SplitCount:3 },
261
+ ],
262
+ }
263
+
264
+ return option;
265
+ }
266
+
267
+
268
+